// SPDX-License-Identifier: BSD-3-Clause-Clear /* * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved. * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
*/
switch (ru_phy) { case RU_26:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_26; break; case RU_52:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_52; break; case RU_106:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_106; break; case RU_242:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_242; break; case RU_484:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_484; break; case RU_996:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_996; break; default:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_26; break;
}
switch (ru_tones) { case 26:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_26; break; case 52:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_52; break; case 106:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_106; break; case 242:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_242; break; case 484:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_484; break; case 996:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_996; break; case (996 * 2):
ret = NL80211_RATE_INFO_HE_RU_ALLOC_2x996; break; default:
ret = NL80211_RATE_INFO_HE_RU_ALLOC_26; break;
}
switch (sgi) { case RX_MSDU_START_SGI_0_8_US:
ret = NL80211_RATE_INFO_HE_GI_0_8; break; case RX_MSDU_START_SGI_1_6_US:
ret = NL80211_RATE_INFO_HE_GI_1_6; break; case RX_MSDU_START_SGI_3_2_US:
ret = NL80211_RATE_INFO_HE_GI_3_2; break; default:
ret = NL80211_RATE_INFO_HE_GI_0_8; break;
}
return ret;
}
u8 ath11k_mac_bw_to_mac80211_bw(u8 bw)
{
u8 ret = 0;
switch (bw) { case ATH11K_BW_20:
ret = RATE_INFO_BW_20; break; case ATH11K_BW_40:
ret = RATE_INFO_BW_40; break; case ATH11K_BW_80:
ret = RATE_INFO_BW_80; break; case ATH11K_BW_160:
ret = RATE_INFO_BW_160; break;
}
return ret;
}
enum ath11k_supported_bw ath11k_mac_mac80211_bw_to_ath11k_bw(enum rate_info_bw bw)
{ switch (bw) { case RATE_INFO_BW_20: return ATH11K_BW_20; case RATE_INFO_BW_40: return ATH11K_BW_40; case RATE_INFO_BW_80: return ATH11K_BW_80; case RATE_INFO_BW_160: return ATH11K_BW_160; default: return ATH11K_BW_20;
}
}
int ath11k_mac_hw_ratecode_to_legacy_rate(u8 hw_rc, u8 preamble, u8 *rateidx,
u16 *rate)
{ /* As default, it is OFDM rates */ int i = ATH11K_MAC_FIRST_OFDM_RATE_IDX; int max_rates_idx = ath11k_g_rates_size;
if (preamble == WMI_RATE_PREAMBLE_CCK) {
hw_rc &= ~ATH11k_HW_RATECODE_CCK_SHORT_PREAM_MASK;
i = 0;
max_rates_idx = ATH11K_MAC_FIRST_OFDM_RATE_IDX;
}
while (i < max_rates_idx) { if (hw_rc == ath11k_legacy_rates[i].hw_value) {
*rateidx = i;
*rate = ath11k_legacy_rates[i].bitrate; return 0;
}
i++;
}
return -EINVAL;
}
staticint get_num_chains(u32 mask)
{ int num_chains = 0;
while (mask) { if (mask & BIT(0))
num_chains++;
mask >>= 1;
}
return num_chains;
}
u8 ath11k_mac_bitrate_to_idx(conststruct ieee80211_supported_band *sband,
u32 bitrate)
{ int i;
for (i = 0; i < sband->n_bitrates; i++) if (sband->bitrates[i].bitrate == bitrate) return i;
return 0;
}
static u32
ath11k_mac_max_ht_nss(const u8 *ht_mcs_mask)
{ int nss;
for (nss = IEEE80211_HT_MCS_MASK_LEN - 1; nss >= 0; nss--) if (ht_mcs_mask[nss]) return nss + 1;
return 1;
}
static u32
ath11k_mac_max_vht_nss(const u16 *vht_mcs_mask)
{ int nss;
for (nss = NL80211_VHT_NSS_MAX - 1; nss >= 0; nss--) if (vht_mcs_mask[nss]) return nss + 1;
return 1;
}
static u32
ath11k_mac_max_he_nss(const u16 *he_mcs_mask)
{ int nss;
for (nss = NL80211_HE_NSS_MAX - 1; nss >= 0; nss--) if (he_mcs_mask[nss]) return nss + 1;
return 1;
}
static u8 ath11k_parse_mpdudensity(u8 mpdudensity)
{ /* 802.11n D2.0 defined values for "Minimum MPDU Start Spacing": * 0 for no restriction * 1 for 1/4 us * 2 for 1/2 us * 3 for 1 us * 4 for 2 us * 5 for 4 us * 6 for 8 us * 7 for 16 us
*/ switch (mpdudensity) { case 0: return 0; case 1: case 2: case 3: /* Our lower layer calculations limit our precision to * 1 microsecond
*/ return 1; case 4: return 2; case 5: return 4; case 6: return 8; case 7: return 16; default: return 0;
}
}
if (WARN_ON(pdev_id > ab->num_radios)) return NULL;
for (i = 0; i < ab->num_radios; i++) { if (ab->fw_mode == ATH11K_FIRMWARE_MODE_FTM)
pdev = &ab->pdevs[i]; else
pdev = rcu_dereference(ab->pdevs_active[i]);
for (i = 0; i < ab->num_radios; i++) {
pdev = &ab->pdevs[i];
ar = pdev->ar;
list_for_each_entry(arvif, &ar->arvifs, list) { if (arvif->is_up) return arvif;
}
}
if (WARN_ON(ath11k_mac_vif_chan(vif, &def))) return pdev_id;
band = def.chan->band;
for (i = 0; i < ab->target_pdev_count; i++) { if (ath11k_mac_band_match(band, ab->target_pdev_ids[i].supported_bands)) return ab->target_pdev_ids[i].pdev_id;
}
/* FIXME Set min_tx_power to ab->target_caps.hw_min_tx_power. * But since the received value in svcrdy is same as hw_max_tx_power, * we can set ar->min_tx_power to 0 currently until * this is fixed in firmware
*/
ar->min_tx_power = 0;
/* Enable RTS/CTS protection for sw retries (when legacy stations * are in BSS) or by default only for second rate series. * TODO: Check if we need to enable CTS 2 Self in any case
*/
rts_cts = WMI_USE_RTS_CTS;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, rts_cts); if (ret)
ath11k_warn(ar->ab, "failed to recalculate rts/cts prot for vdev %d: %d\n",
arvif->vdev_id, ret);
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_STA_KICKOUT_TH,
ATH11K_KICKOUT_THRESHOLD,
ar->pdev->pdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to set kickout threshold on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
param = WMI_VDEV_PARAM_AP_KEEPALIVE_MIN_IDLE_INACTIVE_TIME_SECS;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param,
ATH11K_KEEPALIVE_MIN_IDLE); if (ret) {
ath11k_warn(ar->ab, "failed to set keepalive minimum idle time on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
param = WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_IDLE_INACTIVE_TIME_SECS;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param,
ATH11K_KEEPALIVE_MAX_IDLE); if (ret) {
ath11k_warn(ar->ab, "failed to set keepalive maximum idle time on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
param = WMI_VDEV_PARAM_AP_KEEPALIVE_MAX_UNRESPONSIVE_TIME_SECS;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param,
ATH11K_KEEPALIVE_MAX_UNRESPONSIVE); if (ret) {
ath11k_warn(ar->ab, "failed to set keepalive maximum unresponsive time on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
ret = ath11k_wmi_vdev_stop(ar, vdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to stop monitor vdev %i after start failure: %d\n",
vdev_id, ret); return ret;
}
ret = ath11k_mac_vdev_setup_sync(ar); if (ret) {
ath11k_warn(ar->ab, "failed to synchronize setup for vdev %i stop: %d\n",
vdev_id, ret); return ret;
}
return -EIO;
}
staticint ath11k_mac_monitor_vdev_stop(struct ath11k *ar)
{ int ret;
lockdep_assert_held(&ar->conf_mutex);
reinit_completion(&ar->vdev_setup_done);
ret = ath11k_wmi_vdev_stop(ar, ar->monitor_vdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to request monitor vdev %i stop: %d\n",
ar->monitor_vdev_id, ret); return ret;
}
ret = ath11k_mac_vdev_setup_sync(ar); if (ret) {
ath11k_warn(ar->ab, "failed to synchronize monitor vdev %i stop: %d\n",
ar->monitor_vdev_id, ret); return ret;
}
ret = ath11k_wmi_vdev_down(ar, ar->monitor_vdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to put down monitor vdev %i: %d\n",
ar->monitor_vdev_id, ret); return ret;
}
ar->num_started_vdevs++;
ret = ath11k_dp_tx_htt_monitor_mode_ring_config(ar, false); if (ret) {
ath11k_warn(ar->ab, "failed to configure htt monitor mode ring during start: %d",
ret); return ret;
}
ret = ath11k_dp_tx_htt_monitor_mode_ring_config(ar, true); if (ret) {
ath11k_warn(ar->ab, "failed to configure htt monitor mode ring during stop: %d",
ret); return ret;
}
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "monitor stopped ret %d\n", ret);
ret = ath11k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id, psmode); if (ret) {
ath11k_warn(ar->ab, "failed to set sta power save mode %d for vdev %d: %d\n",
psmode, arvif->vdev_id, ret); return ret;
}
return 0;
}
staticint ath11k_mac_config_ps(struct ath11k *ar)
{ struct ath11k_vif *arvif; int ret = 0;
lockdep_assert_held(&ar->conf_mutex);
list_for_each_entry(arvif, &ar->arvifs, list) {
ret = ath11k_mac_vif_setup_ps(arvif); if (ret) {
ath11k_warn(ar->ab, "failed to setup powersave: %d\n", ret); break;
}
}
return ret;
}
staticint ath11k_mac_op_config(struct ieee80211_hw *hw, int radio_idx, u32 changed)
{ struct ath11k *ar = hw->priv; struct ieee80211_conf *conf = &hw->conf; int ret = 0;
mutex_lock(&ar->conf_mutex);
if (changed & IEEE80211_CONF_CHANGE_MONITOR) { if (conf->flags & IEEE80211_CONF_MONITOR) {
set_bit(ATH11K_FLAG_MONITOR_CONF_ENABLED, &ar->monitor_flags);
if (test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED,
&ar->monitor_flags)) goto out;
ret = ath11k_mac_monitor_vdev_create(ar); if (ret) {
ath11k_warn(ar->ab, "failed to create monitor vdev: %d",
ret); goto out;
}
ret = ath11k_mac_monitor_start(ar); if (ret) {
ath11k_warn(ar->ab, "failed to start monitor: %d",
ret); goto err_mon_del;
}
} else {
clear_bit(ATH11K_FLAG_MONITOR_CONF_ENABLED, &ar->monitor_flags);
if (!test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED,
&ar->monitor_flags)) goto out;
ret = ath11k_mac_monitor_stop(ar); if (ret) {
ath11k_warn(ar->ab, "failed to stop monitor: %d",
ret); goto out;
}
ret = ath11k_mac_monitor_vdev_delete(ar); if (ret) {
ath11k_warn(ar->ab, "failed to delete monitor vdev: %d",
ret); goto out;
}
}
}
ret = ath11k_wmi_p2p_go_bcn_ie(ar, arvif->vdev_id, p2p_ie); if (ret) {
ath11k_warn(ar->ab, "failed to submit P2P GO bcn ie for vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
if (arvif->vdev_subtype != WMI_VDEV_SUBTYPE_P2P_GO) return ret;
ret = ath11k_mac_setup_bcn_p2p_ie(arvif, bcn); if (ret) {
ath11k_warn(ab, "failed to setup P2P GO bcn ie: %d\n",
ret); return ret;
}
/* P2P IE is inserted by firmware automatically (as * configured above) so remove it from the base beacon * template to avoid duplicate P2P IEs in beacon frames.
*/
ret = ath11k_mac_remove_vendor_ie(bcn, WLAN_OUI_WFA,
WLAN_OUI_TYPE_WFA_P2P,
offsetof(struct ieee80211_mgmt,
u.beacon.variable)); if (ret) {
ath11k_warn(ab, "failed to remove P2P vendor ie: %d\n",
ret); return ret;
}
staticint ath11k_mac_setup_bcn_tmpl_ema(struct ath11k_vif *arvif, struct ath11k_vif *tx_arvif)
{ struct ieee80211_ema_beacons *beacons; int ret = 0; bool nontx_vif_params_set = false;
u32 params = 0;
u8 i = 0;
beacons = ieee80211_beacon_get_template_ema_list(tx_arvif->ar->hw,
tx_arvif->vif, 0); if (!beacons || !beacons->cnt) {
ath11k_warn(arvif->ar->ab, "failed to get ema beacon templates from mac80211\n"); return -EPERM;
}
if (tx_arvif == arvif) { if (ath11k_mac_set_vif_params(tx_arvif, beacons->bcn[0].skb)) return -EINVAL;
} else {
arvif->wpaie_present = tx_arvif->wpaie_present;
}
for (i = 0; i < beacons->cnt; i++) { if (tx_arvif != arvif && !nontx_vif_params_set)
nontx_vif_params_set =
ath11k_mac_set_nontx_vif_params(tx_arvif, arvif,
beacons->bcn[i].skb);
ret = ath11k_wmi_bcn_tmpl(tx_arvif->ar, tx_arvif->vdev_id,
&beacons->bcn[i].offs,
beacons->bcn[i].skb, params); if (ret) {
ath11k_warn(tx_arvif->ar->ab, "failed to set ema beacon template id %i error %d\n",
i, ret); break;
}
}
ieee80211_beacon_free_ema_list(beacons);
if (tx_arvif != arvif && !nontx_vif_params_set) return -EINVAL; /* Profile not found in the beacons */
if (arvif->vdev_type != WMI_VDEV_TYPE_AP) return 0;
/* Target does not expect beacon templates for the already up * non-transmitting interfaces, and results in a crash if sent.
*/
tx_arvif = ath11k_mac_get_tx_arvif(arvif); if (tx_arvif) { if (arvif != tx_arvif && arvif->is_up) return 0;
if (vif->bss_conf.color_change_active)
ieee80211_beacon_update_cntdwn(vif, 0);
ath11k_mac_setup_bcn_tmpl(arvif);
}
staticvoid ath11k_control_beaconing(struct ath11k_vif *arvif, struct ieee80211_bss_conf *info)
{ struct ath11k *ar = arvif->ar; struct ath11k_vif *tx_arvif; int ret = 0;
lockdep_assert_held(&arvif->ar->conf_mutex);
if (!info->enable_beacon) {
ret = ath11k_wmi_vdev_down(ar, arvif->vdev_id); if (ret)
ath11k_warn(ar->ab, "failed to down vdev_id %i: %d\n",
arvif->vdev_id, ret);
arvif->is_up = false; return;
}
/* Install the beacon template to the FW */
ret = ath11k_mac_setup_bcn_tmpl(arvif); if (ret) {
ath11k_warn(ar->ab, "failed to update bcn tmpl during vdev up: %d\n",
ret); return;
}
arvif->aid = 0;
ether_addr_copy(arvif->bssid, info->bssid);
tx_arvif = ath11k_mac_get_tx_arvif(arvif);
ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
arvif->bssid,
tx_arvif ? tx_arvif->bssid : NULL,
info->bssid_index,
1 << info->bssid_indicator); if (ret) {
ath11k_warn(ar->ab, "failed to bring up vdev %d: %i\n",
arvif->vdev_id, ret); return;
}
/* Firmware doesn't report beacon loss events repeatedly. If AP probe * (done by mac80211) succeeds but beacons do not resume then it * doesn't make sense to continue operation. Queue connection loss work * which can be cancelled when beacon is received.
*/
ieee80211_queue_delayed_work(hw, &arvif->connection_loss_work,
ATH11K_CONNECTION_LOSS_HZ);
}
/* As firmware handles this two flags (IEEE80211_HT_CAP_SGI_20 * and IEEE80211_HT_CAP_SGI_40) for enabling SGI, we reset * both flags if guard interval is Default GI
*/ if (arvif->bitrate_mask.control[band].gi == NL80211_TXRATE_DEFAULT_GI)
arg->peer_ht_caps &= ~(IEEE80211_HT_CAP_SGI_20 |
IEEE80211_HT_CAP_SGI_40);
if (arvif->bitrate_mask.control[band].gi != NL80211_TXRATE_FORCE_LGI) { if (ht_cap->cap & (IEEE80211_HT_CAP_SGI_20 |
IEEE80211_HT_CAP_SGI_40))
arg->peer_rate_caps |= WMI_HOST_RC_SGI_FLAG;
}
for (i = 0, n = 0, max_nss = 0; i < IEEE80211_HT_MCS_MASK_LEN * 8; i++) if ((ht_cap->mcs.rx_mask[i / 8] & BIT(i % 8)) &&
(ht_mcs_mask[i / 8] & BIT(i % 8))) {
max_nss = (i / 8) + 1;
arg->peer_ht_rates.rates[n++] = i;
}
/* This is a workaround for HT-enabled STAs which break the spec * and have no HT capabilities RX mask (no HT RX MCS map). * * As per spec, in section 20.3.5 Modulation and coding scheme (MCS), * MCS 0 through 7 are mandatory in 20MHz with 800 ns GI at all STAs. * * Firmware asserts if such situation occurs.
*/ if (n == 0) {
arg->peer_ht_rates.num_rates = 8; for (i = 0; i < arg->peer_ht_rates.num_rates; i++)
arg->peer_ht_rates.rates[i] = i;
} else {
arg->peer_ht_rates.num_rates = n;
arg->peer_nss = min(sta->deflink.rx_nss, max_nss);
}
switch (idx_limit) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
mcs = IEEE80211_VHT_MCS_SUPPORT_0_7; break; case 8:
mcs = IEEE80211_VHT_MCS_SUPPORT_0_8; break; case 9:
mcs = IEEE80211_VHT_MCS_SUPPORT_0_9; break; default:
WARN_ON(1);
fallthrough; case -1:
mcs = IEEE80211_VHT_MCS_NOT_SUPPORTED; break;
}
switch (nss_ratio_info) { case WMI_NSS_RATIO_1BY2_NSS:
max_sup_nss = max_nss >> 1; break; case WMI_NSS_RATIO_3BY4_NSS:
ath11k_warn(ar->ab, "WMI_NSS_RATIO_3BY4_NSS not supported\n"); break; case WMI_NSS_RATIO_1_NSS:
max_sup_nss = max_nss; break; case WMI_NSS_RATIO_2_NSS:
ath11k_warn(ar->ab, "WMI_NSS_RATIO_2_NSS not supported\n"); break; default:
ath11k_warn(ar->ab, "invalid nss ratio received from firmware: %d\n",
nss_ratio_info); break;
}
/* Workaround: Some Netgear/Linksys 11ac APs set Rx A-MPDU factor to * zero in VHT IE. Using it would result in degraded throughput. * arg->peer_max_mpdu at this point contains HT max_mpdu so keep * it if VHT max_mpdu is smaller.
*/
arg->peer_max_mpdu = max(arg->peer_max_mpdu,
(1U << (IEEE80211_HT_MAX_AMPDU_FACTOR +
ampdu_factor)) - 1);
if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_80)
arg->bw_80 = true;
if (sta->deflink.bandwidth == IEEE80211_STA_RX_BW_160)
arg->bw_160 = true;
vht_nss = ath11k_mac_max_vht_nss(vht_mcs_mask);
if (vht_nss > sta->deflink.rx_nss) {
user_rate_valid = false; for (nss_idx = sta->deflink.rx_nss - 1; nss_idx >= 0; nss_idx--) { if (vht_mcs_mask[nss_idx]) {
user_rate_valid = true; break;
}
}
}
if (!user_rate_valid) {
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "setting vht range mcs value to peer supported nss %d for peer %pM\n",
sta->deflink.rx_nss, sta->addr);
vht_mcs_mask[sta->deflink.rx_nss - 1] = vht_mcs_mask[vht_nss - 1];
}
/* Calculate peer NSS capability from VHT capabilities if STA * supports VHT.
*/ for (i = 0, max_nss = 0; i < NL80211_VHT_NSS_MAX; i++) {
vht_mcs = __le16_to_cpu(vht_cap->vht_mcs.rx_mcs_map) >>
(2 * i) & 3;
/* In IPQ8074 platform, VHT mcs rate 10 and 11 is enabled by default. * VHT mcs rate 10 and 11 is not supported in 11ac standard. * so explicitly disable the VHT MCS rate 10 and 11 in 11ac mode.
*/
arg->tx_mcs_set &= ~IEEE80211_VHT_MCS_SUPPORT_0_11_MASK;
arg->tx_mcs_set |= IEEE80211_DISABLE_VHT_MCS_SUPPORT_0_11;
if ((arg->tx_mcs_set & IEEE80211_VHT_MCS_NOT_SUPPORTED) ==
IEEE80211_VHT_MCS_NOT_SUPPORTED)
arg->peer_vht_caps &= ~IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
/* Supported HE-MCS and NSS Set of peer he_cap is intersection with self he_cp */
mcs_160_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_160);
mcs_80_map = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80);
/* Initialize rx_mcs_160 to 9 which is an invalid value */
rx_mcs_160 = 9; if (support_160) { for (i = 7; i >= 0; i--) {
u8 mcs_160 = (mcs_160_map >> (2 * i)) & 3;
if (mcs_160 != IEEE80211_VHT_MCS_NOT_SUPPORTED) {
rx_mcs_160 = i + 1; break;
}
}
}
/* Initialize rx_mcs_80 to 9 which is an invalid value */
rx_mcs_80 = 9; for (i = 7; i >= 0; i--) {
u8 mcs_80 = (mcs_80_map >> (2 * i)) & 3;
if (mcs_80 != IEEE80211_VHT_MCS_NOT_SUPPORTED) {
rx_mcs_80 = i + 1; break;
}
}
if (support_160)
max_nss = min(rx_mcs_80, rx_mcs_160); else
max_nss = rx_mcs_80;
/* the top most byte is used to indicate BSS color info */
arg->peer_he_ops &= 0xffffff;
/* As per section 26.6.1 11ax Draft5.0, if the Max AMPDU Exponent Extension * in HE cap is zero, use the arg->peer_max_mpdu as calculated while parsing * VHT caps(if VHT caps is present) or HT caps (if VHT caps is not present). * * For non-zero value of Max AMPDU Extponent Extension in HE MAC caps, * if a HE STA sends VHT cap and HE cap IE in assoc request then, use * MAX_AMPDU_LEN_FACTOR as 20 to calculate max_ampdu length. * If a HE STA that does not send VHT cap, but HE and HT cap in assoc * request, then use MAX_AMPDU_LEN_FACTOR as 16 to calculate max_ampdu * length.
*/
ampdu_factor = u8_get_bits(he_cap->he_cap_elem.mac_cap_info[3],
IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK);
for (nss = 0; nss <= arg->peer_ppet.numss_m1; nss++) { for (ru = 0; ru < 4; ru++) {
u32 val = 0; int i;
if ((arg->peer_ppet.ru_bit_mask & BIT(ru)) == 0) continue; for (i = 0; i < 6; i++) {
val >>= 1;
val |= ((he_cap->ppe_thres[bit / 8] >>
(bit % 8)) & 0x1) << 5;
bit++;
}
arg->peer_ppet.ppet16_ppet8_ru3_ru0[nss] |=
val << (ru * 6);
}
}
}
if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_RES)
arg->twt_responder = true; if (he_cap->he_cap_elem.mac_cap_info[0] & IEEE80211_HE_MAC_CAP0_TWT_REQ)
arg->twt_requester = true;
he_nss = ath11k_mac_max_he_nss(he_mcs_mask);
if (he_nss > sta->deflink.rx_nss) {
user_rate_valid = false; for (nss_idx = sta->deflink.rx_nss - 1; nss_idx >= 0; nss_idx--) { if (he_mcs_mask[nss_idx]) {
user_rate_valid = true; break;
}
}
}
if (!user_rate_valid) {
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "setting he range mcs value to peer supported nss %d for peer %pM\n",
sta->deflink.rx_nss, sta->addr);
he_mcs_mask[sta->deflink.rx_nss - 1] = he_mcs_mask[he_nss - 1];
}
switch (sta->deflink.bandwidth) { case IEEE80211_STA_RX_BW_160: if (he_cap->he_cap_elem.phy_cap_info[0] &
IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_80PLUS80_MHZ_IN_5G) {
v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80p80);
v = ath11k_peer_assoc_h_he_limit(v, he_mcs_mask);
arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v;
v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80p80);
arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80_80] = v;
v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_160);
v = ath11k_peer_assoc_h_he_limit(v, he_mcs_mask);
arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_160] = v;
arg->peer_he_mcs_count++; if (!he_tx_mcs)
he_tx_mcs = v;
fallthrough;
default:
v = le16_to_cpu(he_cap->he_mcs_nss_supp.rx_mcs_80);
arg->peer_he_rx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v;
v = le16_to_cpu(he_cap->he_mcs_nss_supp.tx_mcs_80);
v = ath11k_peer_assoc_h_he_limit(v, he_mcs_mask);
arg->peer_he_tx_mcs_set[WMI_HECAP_TXRX_MCS_NSS_IDX_80] = v;
arg->peer_he_mcs_count++; if (!he_tx_mcs)
he_tx_mcs = v; break;
}
/* Calculate peer NSS capability from HE capabilities if STA * supports HE.
*/ for (i = 0, max_nss = 0; i < NL80211_HE_NSS_MAX; i++) {
he_mcs = he_tx_mcs >> (2 * i) & 3;
/* In case of fixed rates, MCS Range in he_tx_mcs might have * unsupported range, with he_mcs_mask set, so check either of them * to find nss.
*/ if (he_mcs != IEEE80211_HE_MCS_NOT_SUPPORTED ||
he_mcs_mask[i])
max_nss = i + 1;
}
arg->peer_nss = min(sta->deflink.rx_nss, max_nss);
/* From IEEE Std 802.11ax-2021 - Section 10.12.2: An HE STA shall be capable of * receiving A-MPDU where the A-MPDU pre-EOF padding length is up to the value * indicated by the Maximum A-MPDU Length Exponent Extension field in the HE * Capabilities element and the Maximum A-MPDU Length Exponent field in HE 6 GHz * Band Capabilities element in the 6 GHz band. * * Here, we are extracting the Max A-MPDU Exponent Extension from HE caps and * factor is the Maximum A-MPDU Length Exponent from HE 6 GHZ Band capability.
*/
ampdu_factor = FIELD_GET(IEEE80211_HE_MAC_CAP3_MAX_AMPDU_LEN_EXP_MASK,
he_cap->he_cap_elem.mac_cap_info[3]) +
FIELD_GET(IEEE80211_HE_6GHZ_CAP_MAX_AMPDU_LEN_EXP,
arg->peer_he_caps_6ghz);
param = WMI_VDEV_PARAM_SET_HEMU_MODE;
value = 0; if (arvif->vif->bss_conf.he_su_beamformer) {
value |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE); if (arvif->vif->bss_conf.he_mu_beamformer &&
arvif->vdev_type == WMI_VDEV_TYPE_AP)
value |= FIELD_PREP(HE_MODE_MU_TX_BFER, HE_MU_BFER_ENABLE);
}
if (arvif->vif->type != NL80211_IFTYPE_MESH_POINT) {
value |= FIELD_PREP(HE_MODE_DL_OFDMA, HE_DL_MUOFDMA_ENABLE) |
FIELD_PREP(HE_MODE_UL_OFDMA, HE_UL_MUOFDMA_ENABLE);
if (arvif->vif->bss_conf.he_full_ul_mumimo)
value |= FIELD_PREP(HE_MODE_UL_MUMIMO, HE_UL_MUMIMO_ENABLE);
if (arvif->vif->bss_conf.he_su_beamformee)
value |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
}
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, value); if (ret) {
ath11k_warn(ar->ab, "failed to set vdev %d HE MU mode: %d\n",
arvif->vdev_id, ret); returnfalse;
}
param = WMI_VDEV_PARAM_SET_HE_SOUNDING_MODE;
value = FIELD_PREP(HE_VHT_SOUNDING_MODE, HE_VHT_SOUNDING_MODE_ENABLE) |
FIELD_PREP(HE_TRIG_NONTRIG_SOUNDING_MODE,
HE_TRIG_NONTRIG_SOUNDING_MODE_ENABLE);
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
param, value); if (ret) {
ath11k_warn(ar->ab, "failed to set vdev %d sounding mode: %d\n",
arvif->vdev_id, ret); returnfalse;
} returntrue;
}
if (HECAP_PHY_ULMUMIMO_GET(he_cap_elem.phy_cap_info)) if (HECAP_PHY_ULMUMIMO_GET(he_cap->he_cap_elem.phy_cap_info))
hemode |= FIELD_PREP(HE_MODE_UL_MUMIMO,
HE_UL_MUMIMO_ENABLE);
if (FIELD_GET(HE_MODE_MU_TX_BFEE, hemode))
hemode |= FIELD_PREP(HE_MODE_SU_TX_BFEE, HE_SU_BFEE_ENABLE);
if (FIELD_GET(HE_MODE_MU_TX_BFER, hemode))
hemode |= FIELD_PREP(HE_MODE_SU_TX_BFER, HE_SU_BFER_ENABLE);
}
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param, hemode); if (ret) {
ath11k_warn(ar->ab, "failed to submit vdev param txbf 0x%x: %d\n",
hemode, ret); returnfalse;
}
if (!ath11k_mac_vif_recalc_sta_he_txbf(ar, vif, &he_cap)) {
ath11k_warn(ar->ab, "failed to recalc he txbf for vdev %i on bss %pM\n",
arvif->vdev_id, bss_conf->bssid); return;
}
peer_arg.is_assoc = true;
ret = ath11k_wmi_send_peer_assoc_cmd(ar, &peer_arg); if (ret) {
ath11k_warn(ar->ab, "failed to run peer assoc for %pM vdev %i: %d\n",
bss_conf->bssid, arvif->vdev_id, ret); return;
}
if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) {
ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
bss_conf->bssid, arvif->vdev_id); return;
}
ret = ath11k_setup_peer_smps(ar, arvif, bss_conf->bssid,
&ap_sta->deflink.ht_cap,
le16_to_cpu(ap_sta->deflink.he_6ghz_capa.capa)); if (ret) {
ath11k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n",
arvif->vdev_id, ret); return;
}
if (is_auth) {
ret = ath11k_wmi_set_peer_param(ar, arvif->bssid,
arvif->vdev_id,
WMI_PEER_AUTHORIZE,
1); if (ret)
ath11k_warn(ar->ab, "Unable to authorize BSS peer: %d\n", ret);
}
ret = ath11k_wmi_send_obss_spr_cmd(ar, arvif->vdev_id,
&bss_conf->he_obss_pd); if (ret)
ath11k_warn(ar->ab, "failed to set vdev %i OBSS PD parameters: %d\n",
arvif->vdev_id, ret);
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
WMI_VDEV_PARAM_DTIM_POLICY,
WMI_DTIM_POLICY_STICK); if (ret)
ath11k_warn(ar->ab, "failed to set vdev %d dtim policy: %d\n",
arvif->vdev_id, ret);
hw_rate_code = ath11k_mac_get_rate_hw_value(bitrate); if (hw_rate_code < 0) {
ath11k_warn(ar->ab, "bitrate not supported %d\n", bitrate); return;
}
vdev_param = WMI_VDEV_PARAM_MGMT_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param,
hw_rate_code); if (ret)
ath11k_warn(ar->ab, "failed to set mgmt tx rate %d\n", ret);
/* For WCN6855, firmware will clear this param when vdev starts, hence * cache it here so that we can reconfigure it once vdev starts.
*/
ar->hw_rate_code = hw_rate_code;
vdev_param = WMI_VDEV_PARAM_BEACON_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, vdev_param,
hw_rate_code); if (ret)
ath11k_warn(ar->ab, "failed to set beacon tx rate %d\n", ret);
}
/* Set and enable SRG/non-SRG OBSS PD Threshold */
param_id = WMI_PDEV_PARAM_SET_CMD_OBSS_PD_THRESHOLD; if (test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags)) {
ret = ath11k_wmi_pdev_set_param(ar, param_id, 0, pdev_id); if (ret)
ath11k_warn(ar->ab, "failed to set obss_pd_threshold for pdev: %u\n",
pdev_id); return ret;
}
if (test_bit(WMI_TLV_SERVICE_SRG_SRP_SPATIAL_REUSE_SUPPORT,
ar->ab->wmi_ab.svc_map)) {
param_val |= ATH11K_OBSS_PD_THRESHOLD_IN_DBM;
param_val |= FIELD_PREP(GENMASK(15, 8), srg_th);
} else {
non_srg_th -= ATH11K_DEFAULT_NOISE_FLOOR; /* SRG not supported and threshold in dB */
param_val &= ~(ATH11K_OBSS_PD_SRG_EN |
ATH11K_OBSS_PD_THRESHOLD_IN_DBM);
}
param_val |= (non_srg_th & GENMASK(7, 0));
ret = ath11k_wmi_pdev_set_param(ar, param_id, param_val, pdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to set obss_pd_threshold for pdev: %u\n",
pdev_id); return ret;
}
/* Enable OBSS PD for all access category */
param_id = WMI_PDEV_PARAM_SET_CMD_OBSS_PD_PER_AC;
param_val = 0xf;
ret = ath11k_wmi_pdev_set_param(ar, param_id, param_val, pdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to set obss_pd_per_ac for pdev: %u\n",
pdev_id); return ret;
}
/* Set SR Prohibit */
param_id = WMI_PDEV_PARAM_ENABLE_SR_PROHIBIT;
param_val = !!(he_obss_pd->sr_ctrl &
IEEE80211_HE_SPR_HESIGA_SR_VAL15_ALLOWED);
ret = ath11k_wmi_pdev_set_param(ar, param_id, param_val, pdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to set sr_prohibit for pdev: %u\n",
pdev_id); return ret;
}
if (!test_bit(WMI_TLV_SERVICE_SRG_SRP_SPATIAL_REUSE_SUPPORT,
ar->ab->wmi_ab.svc_map)) return 0;
/* Set SRG BSS Color Bitmap */
memcpy(bitmap, he_obss_pd->bss_color_bitmap, sizeof(bitmap));
ret = ath11k_wmi_pdev_set_srg_bss_color_bitmap(ar, bitmap); if (ret) {
ath11k_warn(ar->ab, "failed to set bss_color_bitmap for pdev: %u\n",
pdev_id); return ret;
}
/* Set SRG Partial BSSID Bitmap */
memcpy(bitmap, he_obss_pd->partial_bssid_bitmap, sizeof(bitmap));
ret = ath11k_wmi_pdev_set_srg_patial_bssid_bitmap(ar, bitmap); if (ret) {
ath11k_warn(ar->ab, "failed to set partial_bssid_bitmap for pdev: %u\n",
pdev_id); return ret;
}
memset(bitmap, 0xff, sizeof(bitmap));
/* Enable all BSS Colors for SRG */
ret = ath11k_wmi_pdev_srg_obss_color_enable_bitmap(ar, bitmap); if (ret) {
ath11k_warn(ar->ab, "failed to set srg_color_en_bitmap pdev: %u\n",
pdev_id); return ret;
}
/* Enable all partial BSSID mask for SRG */
ret = ath11k_wmi_pdev_srg_obss_bssid_enable_bitmap(ar, bitmap); if (ret) {
ath11k_warn(ar->ab, "failed to set srg_bssid_en_bitmap pdev: %u\n",
pdev_id); return ret;
}
/* Enable all BSS Colors for non-SRG */
ret = ath11k_wmi_pdev_non_srg_obss_color_enable_bitmap(ar, bitmap); if (ret) {
ath11k_warn(ar->ab, "failed to set non_srg_color_en_bitmap pdev: %u\n",
pdev_id); return ret;
}
/* Enable all partial BSSID mask for non-SRG */
ret = ath11k_wmi_pdev_non_srg_obss_bssid_enable_bitmap(ar, bitmap); if (ret) {
ath11k_warn(ar->ab, "failed to set non_srg_bssid_en_bitmap pdev: %u\n",
pdev_id); return ret;
}
if (changed & BSS_CHANGED_BEACON_INT) {
arvif->beacon_interval = info->beacon_int;
param_id = WMI_VDEV_PARAM_BEACON_INTERVAL;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
param_id,
arvif->beacon_interval); if (ret)
ath11k_warn(ar->ab, "Failed to set beacon interval for VDEV: %d\n",
arvif->vdev_id); else
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "Beacon interval: %d set for VDEV: %d\n",
arvif->beacon_interval, arvif->vdev_id);
}
if (changed & BSS_CHANGED_BEACON) {
param_id = WMI_PDEV_PARAM_BEACON_TX_MODE;
param_value = WMI_BEACON_STAGGERED_MODE;
ret = ath11k_wmi_pdev_set_param(ar, param_id,
param_value, ar->pdev->pdev_id); if (ret)
ath11k_warn(ar->ab, "Failed to set beacon mode for VDEV: %d\n",
arvif->vdev_id); else
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "Set staggered beacon mode for VDEV: %d\n",
arvif->vdev_id);
if (!arvif->do_not_send_tmpl || !arvif->bcca_zero_sent) {
ret = ath11k_mac_setup_bcn_tmpl(arvif); if (ret)
ath11k_warn(ar->ab, "failed to update bcn template: %d\n",
ret);
}
if (arvif->bcca_zero_sent)
arvif->do_not_send_tmpl = true; else
arvif->do_not_send_tmpl = false;
if (vif->bss_conf.he_support) {
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
WMI_VDEV_PARAM_BA_MODE,
WMI_BA_MODE_BUFFER_SIZE_256); if (ret)
ath11k_warn(ar->ab, "failed to set BA BUFFER SIZE 256 for vdev: %d\n",
arvif->vdev_id); else
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "Set BA BUFFER SIZE 256 for VDEV: %d\n",
arvif->vdev_id);
}
}
if (changed & (BSS_CHANGED_BEACON_INFO | BSS_CHANGED_BEACON)) {
arvif->dtim_period = info->dtim_period;
param_id = WMI_VDEV_PARAM_DTIM_PERIOD;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
param_id,
arvif->dtim_period);
if (ret)
ath11k_warn(ar->ab, "Failed to set dtim period for VDEV %d: %i\n",
arvif->vdev_id, ret); else
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "DTIM period: %d set for VDEV: %d\n",
arvif->dtim_period, arvif->vdev_id);
}
vdev_param = WMI_VDEV_PARAM_MCAST_DATA_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, rate); if (ret)
ath11k_warn(ar->ab, "failed to set mcast rate on vdev %i: %d\n",
arvif->vdev_id, ret);
vdev_param = WMI_VDEV_PARAM_BCAST_DATA_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, rate); if (ret)
ath11k_warn(ar->ab, "failed to set bcast rate on vdev %i: %d\n",
arvif->vdev_id, ret);
}
if (changed & BSS_CHANGED_BASIC_RATES &&
!ath11k_mac_vif_chan(arvif->vif, &def))
ath11k_recalculate_mgmt_rate(ar, vif, &def);
if (changed & BSS_CHANGED_TWT) { struct wmi_twt_enable_params twt_params = {};
if (changed & BSS_CHANGED_HE_OBSS_PD)
ath11k_mac_config_obss_pd(ar, &info->he_obss_pd);
if (changed & BSS_CHANGED_HE_BSS_COLOR) { if (vif->type == NL80211_IFTYPE_AP) {
ret = ath11k_wmi_send_obss_color_collision_cfg_cmd(
ar, arvif->vdev_id, info->he_bss_color.color,
ATH11K_BSS_COLOR_COLLISION_DETECTION_AP_PERIOD_MS,
info->he_bss_color.enabled); if (ret)
ath11k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n",
arvif->vdev_id, ret);
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
param_id,
param_value); if (ret)
ath11k_warn(ar->ab, "failed to set bss color param on vdev %i: %d\n",
arvif->vdev_id, ret);
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "bss color param 0x%x set on vdev %i\n",
param_value, arvif->vdev_id);
} elseif (vif->type == NL80211_IFTYPE_STATION) {
ret = ath11k_wmi_send_bss_color_change_enable_cmd(ar,
arvif->vdev_id,
1); if (ret)
ath11k_warn(ar->ab, "failed to enable bss color change on vdev %i: %d\n",
arvif->vdev_id, ret);
ret = ath11k_wmi_send_obss_color_collision_cfg_cmd(
ar, arvif->vdev_id, 0,
ATH11K_BSS_COLOR_COLLISION_DETECTION_STA_PERIOD_MS, 1); if (ret)
ath11k_warn(ar->ab, "failed to set bss color collision on vdev %i: %d\n",
arvif->vdev_id, ret);
}
}
if (changed & BSS_CHANGED_FTM_RESPONDER &&
arvif->ftm_responder != info->ftm_responder &&
test_bit(WMI_TLV_SERVICE_RTT, ar->ab->wmi_ab.svc_map) &&
(vif->type == NL80211_IFTYPE_AP ||
vif->type == NL80211_IFTYPE_MESH_POINT)) {
arvif->ftm_responder = info->ftm_responder;
param = WMI_VDEV_PARAM_ENABLE_DISABLE_RTT_RESPONDER_ROLE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, param,
arvif->ftm_responder); if (ret)
ath11k_warn(ar->ab, "Failed to set ftm responder %i: %d\n",
arvif->vdev_id, ret);
}
if (changed & BSS_CHANGED_FILS_DISCOVERY ||
changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP)
ath11k_mac_fils_discovery(arvif, info);
/* TODO: Fill other STOP Params */
arg.pdev_id = ar->pdev->pdev_id;
ret = ath11k_wmi_send_scan_stop_cmd(ar, &arg); if (ret) {
ath11k_warn(ar->ab, "failed to stop wmi scan: %d\n", ret); goto out;
}
ret = wait_for_completion_timeout(&ar->scan.completed, 3 * HZ); if (ret == 0) {
ath11k_warn(ar->ab, "failed to receive scan abort comple: timed out\n");
ret = -ETIMEDOUT;
} elseif (ret > 0) {
ret = 0;
}
out: /* Scan state should be updated upon scan completion but in case * firmware fails to deliver the event (for whatever reason) it is * desired to clean up scan state anyway. Firmware may have just * dropped the scan completion event delivery due to transport pipe * being overflown with data and/or it can recover on its own before * next scan request is submitted.
*/
spin_lock_bh(&ar->data_lock); if (ar->scan.state != ATH11K_SCAN_IDLE)
__ath11k_mac_scan_finish(ar);
spin_unlock_bh(&ar->data_lock);
return ret;
}
staticvoid ath11k_scan_abort(struct ath11k *ar)
{ int ret;
lockdep_assert_held(&ar->conf_mutex);
spin_lock_bh(&ar->data_lock);
switch (ar->scan.state) { case ATH11K_SCAN_IDLE: /* This can happen if timeout worker kicked in and called * abortion while scan completion was being processed.
*/ break; case ATH11K_SCAN_STARTING: case ATH11K_SCAN_ABORTING:
ath11k_warn(ar->ab, "refusing scan abortion due to invalid scan state: %d\n",
ar->scan.state); break; case ATH11K_SCAN_RUNNING:
ar->scan.state = ATH11K_SCAN_ABORTING;
spin_unlock_bh(&ar->data_lock);
ret = ath11k_scan_stop(ar); if (ret)
ath11k_warn(ar->ab, "failed to abort scan: %d\n", ret);
if (ath11k_spectral_get_mode(ar) == ATH11K_SPECTRAL_BACKGROUND)
ath11k_spectral_reset_buffer(ar);
ret = ath11k_wmi_send_scan_start_cmd(ar, arg); if (ret) return ret;
if (test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ar->ab->wmi_ab.svc_map)) {
timeout = 5 * HZ;
if (ar->supports_6ghz)
timeout += 5 * HZ;
}
ret = wait_for_completion_timeout(&ar->scan.started, timeout); if (ret == 0) {
ret = ath11k_scan_stop(ar); if (ret)
ath11k_warn(ar->ab, "failed to stop scan: %d\n", ret);
return -ETIMEDOUT;
}
/* If we failed to start the scan, return error code at * this point. This is probably due to some issue in the * firmware, but no need to wedge the driver due to that...
*/
spin_lock_bh(&ar->data_lock); if (ar->scan.state == ATH11K_SCAN_IDLE) {
spin_unlock_bh(&ar->data_lock); return -EINVAL;
}
spin_unlock_bh(&ar->data_lock);
/* Firmwares advertising the support of triggering 11D algorithm * on the scan results of a regular scan expects driver to send * WMI_11D_SCAN_START_CMDID before sending WMI_START_SCAN_CMDID. * With this feature, separate 11D scan can be avoided since * regdomain can be determined with the scan results of the * regular scan.
*/ if (ar->state_11d == ATH11K_11D_PREPARING &&
test_bit(WMI_TLV_SERVICE_SUPPORT_11D_FOR_HOST_SCAN,
ar->ab->wmi_ab.svc_map))
ath11k_mac_11d_scan_start(ar, arvif->vdev_id);
mutex_lock(&ar->conf_mutex);
spin_lock_bh(&ar->data_lock); switch (ar->scan.state) { case ATH11K_SCAN_IDLE:
reinit_completion(&ar->scan.started);
reinit_completion(&ar->scan.completed);
ar->scan.state = ATH11K_SCAN_STARTING;
ar->scan.is_roc = false;
ar->scan.vdev_id = arvif->vdev_id;
ret = 0; break; case ATH11K_SCAN_STARTING: case ATH11K_SCAN_RUNNING: case ATH11K_SCAN_ABORTING:
ret = -EBUSY; break;
}
spin_unlock_bh(&ar->data_lock);
for (i = 0; i < arg->num_chan; i++) { if (test_bit(WMI_TLV_SERVICE_SCAN_CONFIG_PER_CHANNEL,
ar->ab->wmi_ab.svc_map)) {
arg->chan_list[i] =
u32_encode_bits(req->channels[i]->center_freq,
WMI_SCAN_CONFIG_PER_CHANNEL_MASK);
/* If NL80211_SCAN_FLAG_COLOCATED_6GHZ is set in scan * flags, then scan all PSC channels in 6 GHz band and * those non-PSC channels where RNR IE is found during * the legacy 2.4/5 GHz scan. * If NL80211_SCAN_FLAG_COLOCATED_6GHZ is not set, * then all channels in 6 GHz will be scanned.
*/ if (req->channels[i]->band == NL80211_BAND_6GHZ &&
req->flags & NL80211_SCAN_FLAG_COLOCATED_6GHZ &&
!cfg80211_channel_is_psc(req->channels[i]))
arg->chan_list[i] |=
WMI_SCAN_CH_FLAG_SCAN_ONLY_IF_RNR_FOUND;
} else {
arg->chan_list[i] = req->channels[i]->center_freq;
}
}
}
for (i = 0; i < ARRAY_SIZE(peer->keys); i++) { if (!peer->keys[i]) continue;
/* key flags are not required to delete the key */
ret = ath11k_install_key(arvif, peer->keys[i],
DISABLE_KEY, addr, flags); if (ret < 0 && first_errno == 0)
first_errno = ret;
if (ret < 0)
ath11k_warn(ab, "failed to remove peer key %d: %d\n",
i, ret);
/* the peer should not disappear in mid-way (unless FW goes awry) since * we already hold conf_mutex. we just make sure its there now.
*/
spin_lock_bh(&ab->base_lock);
peer = ath11k_peer_find(ab, arvif->vdev_id, peer_addr);
/* flush the fragments cache during key (re)install to * ensure all frags in the new frag list belong to the same key.
*/ if (peer && sta && cmd == SET_KEY)
ath11k_peer_frags_flush(ar, peer);
spin_unlock_bh(&ab->base_lock);
if (!peer) { if (cmd == SET_KEY) {
ath11k_warn(ab, "cannot install key for non-existent peer %pM\n",
peer_addr);
ret = -EOPNOTSUPP; gotoexit;
} else { /* if the peer doesn't exist there is no key to disable * anymore
*/ gotoexit;
}
}
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "%s for peer %pM on vdev %d flags 0x%X, type = %d, num_sta %d\n",
cmd == SET_KEY ? "SET_KEY" : "DEL_KEY", peer_addr, arvif->vdev_id,
flags, arvif->vdev_type, arvif->num_stations);
/* Allow group key clearing only in AP mode when no stations are * associated. There is a known race condition in firmware where * group addressed packets may be dropped if the key is cleared * and immediately set again during rekey. * * During GTK rekey, mac80211 issues a clear key (if the old key * exists) followed by an install key operation for same key * index. This causes ath11k to send two WMI commands in quick * succession: one to clear the old key and another to install the * new key in the same slot. * * Under certain conditions—especially under high load or time * sensitive scenarios, firmware may process these commands * asynchronously in a way that firmware assumes the key is * cleared whereas hardware has a valid key. This inconsistency * between hardware and firmware leads to group addressed packet * drops after rekey. * Only setting the same key again can restore a valid key in * firmware and allow packets to be transmitted. * * There is a use case where an AP can transition from Secure mode * to open mode without a vdev restart by just deleting all * associated peers and clearing key, Hence allow clear key for * that case alone. Mark arvif->reinstall_group_keys in such cases * and reinstall the same key when the first peer is added, * allowing firmware to recover from the race if it had occurred.
*/
peer_arg.is_assoc = true;
ret = ath11k_wmi_send_peer_assoc_cmd(ar, &peer_arg); if (ret) {
ath11k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n",
sta->addr, arvif->vdev_id, ret); return ret;
}
if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ)) {
ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
sta->addr, arvif->vdev_id); return -ETIMEDOUT;
}
/* If single VHT/HE rate is configured (by set_bitrate_mask()), * peer_assoc will disable VHT/HE. This is now enabled by a peer specific * fixed param. * Note that all other rates and NSS will be disabled for this peer.
*/ if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) {
ret = ath11k_mac_set_peer_vht_fixed_rate(arvif, sta, mask,
band); if (ret) return ret;
} elseif (sta->deflink.he_cap.has_he && num_he_rates == 1) {
ret = ath11k_mac_set_peer_he_fixed_rate(arvif, sta, mask,
band); if (ret) return ret;
} elseif (sta->deflink.ht_cap.ht_supported && num_ht_rates == 1) {
ret = ath11k_mac_set_peer_ht_fixed_rate(arvif, sta, mask,
band); if (ret) return ret;
}
/* Re-assoc is run only to update supported rates for given station. It * doesn't make much sense to reconfigure the peer completely.
*/ if (reassoc) return 0;
ret = ath11k_setup_peer_smps(ar, arvif, sta->addr,
&sta->deflink.ht_cap,
le16_to_cpu(sta->deflink.he_6ghz_capa.capa)); if (ret) {
ath11k_warn(ar->ab, "failed to setup peer SMPS for vdev %d: %d\n",
arvif->vdev_id, ret); return ret;
}
if (!sta->wme) {
arvif->num_legacy_stations++;
ret = ath11k_recalc_rtscts_prot(arvif); if (ret) return ret;
}
if (sta->wme && sta->uapsd_queues) {
ret = ath11k_peer_assoc_qos_ap(ar, arvif, sta); if (ret) {
ath11k_warn(ar->ab, "failed to set qos params for STA %pM for vdev %i: %d\n",
sta->addr, arvif->vdev_id, ret); return ret;
}
}
return 0;
}
staticint ath11k_station_disassoc(struct ath11k *ar, struct ieee80211_vif *vif, struct ieee80211_sta *sta)
{ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif); int ret = 0;
lockdep_assert_held(&ar->conf_mutex);
if (!sta->wme) {
arvif->num_legacy_stations--;
ret = ath11k_recalc_rtscts_prot(arvif); if (ret) return ret;
}
ret = ath11k_clear_peer_keys(arvif, sta->addr); if (ret) {
ath11k_warn(ar->ab, "failed to clear all peer keys for vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
} return 0;
}
if (bw > bw_prev) { /* BW is upgraded. In this case we send WMI_PEER_PHYMODE * followed by WMI_PEER_CHWIDTH
*/
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "BW upgrade for sta %pM new BW %d, old BW %d\n",
sta->addr, bw, bw_prev);
if (err)
ath11k_warn(ar->ab, "failed to update STA %pM peer bw %d: %d\n",
sta->addr, bw, err);
} else { /* BW is downgraded. In this case we send WMI_PEER_CHWIDTH * followed by WMI_PEER_PHYMODE
*/
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "BW downgrade for sta %pM new BW %d,old BW %d\n",
sta->addr, bw, bw_prev);
/* Peer_assoc_prepare will reject vht rates in * bitrate_mask if its not available in range format and * sets vht tx_rateset as unsupported. So multiple VHT MCS * setting(eg. MCS 4,5,6) per peer is not supported here. * But, Single rate in VHT mask can be set as per-peer * fixed rate. But even if any HT rates are configured in * the bitrate mask, device will not switch to those rates * when per-peer Fixed rate is set. * TODO: Check RATEMASK_CMDID to support auto rates selection * across HT/VHT and for multiple VHT MCS support.
*/ if (sta->deflink.vht_cap.vht_supported && num_vht_rates == 1) {
ath11k_mac_set_peer_vht_fixed_rate(arvif, sta, mask,
band);
} elseif (sta->deflink.he_cap.has_he && num_he_rates == 1) {
ath11k_mac_set_peer_he_fixed_rate(arvif, sta, mask,
band);
} elseif (sta->deflink.ht_cap.ht_supported && num_ht_rates == 1) {
ath11k_mac_set_peer_ht_fixed_rate(arvif, sta, mask,
band);
} else { /* If the peer is non-VHT/HE or no fixed VHT/HE rate * is provided in the new bitrate mask we set the * other rates using peer_assoc command. Also clear * the peer fixed rate settings as it has higher proprity * than peer assoc
*/
err = ath11k_wmi_set_peer_param(ar, sta->addr,
arvif->vdev_id,
WMI_PEER_PARAM_FIXED_RATE,
WMI_FIXED_RATE_NONE); if (err)
ath11k_warn(ar->ab, "failed to disable peer fixed rate for sta %pM: %d\n",
sta->addr, err);
peer_arg.is_assoc = false;
err = ath11k_wmi_send_peer_assoc_cmd(ar, &peer_arg); if (err)
ath11k_warn(ar->ab, "failed to run peer assoc for STA %pM vdev %i: %d\n",
sta->addr, arvif->vdev_id, err);
if (!wait_for_completion_timeout(&ar->peer_assoc_done, 1 * HZ))
ath11k_warn(ar->ab, "failed to get peer assoc conf event for %pM vdev %i\n",
sta->addr, arvif->vdev_id);
}
}
if (sta->deflink.txpwr.type == NL80211_TX_POWER_AUTOMATIC) {
txpwr = 0;
} else {
txpwr = sta->deflink.txpwr.power; if (!txpwr) return -EINVAL;
}
if (txpwr > ATH11K_TX_POWER_MAX_VAL || txpwr < ATH11K_TX_POWER_MIN_VAL) return -EINVAL;
mutex_lock(&ar->conf_mutex);
ret = ath11k_wmi_set_peer_param(ar, sta->addr, arvif->vdev_id,
WMI_PEER_USE_FIXED_PWR, txpwr); if (ret) {
ath11k_warn(ar->ab, "failed to set tx power for station ret: %d\n",
ret); goto out;
}
if (changed & IEEE80211_RC_NSS_CHANGED)
arsta->nss = sta->deflink.rx_nss;
if (changed & IEEE80211_RC_SMPS_CHANGED) {
smps = WMI_PEER_SMPS_PS_NONE;
switch (sta->deflink.smps_mode) { case IEEE80211_SMPS_AUTOMATIC: case IEEE80211_SMPS_OFF:
smps = WMI_PEER_SMPS_PS_NONE; break; case IEEE80211_SMPS_STATIC:
smps = WMI_PEER_SMPS_STATIC; break; case IEEE80211_SMPS_DYNAMIC:
smps = WMI_PEER_SMPS_DYNAMIC; break; default:
ath11k_warn(ar->ab, "Invalid smps %d in sta rc update for %pM\n",
sta->deflink.smps_mode, sta->addr);
smps = WMI_PEER_SMPS_PS_NONE; break;
}
arsta->smps = smps;
}
arsta->changed |= changed;
spin_unlock_bh(&ar->data_lock);
ieee80211_queue_work(hw, &arsta->update_wk);
}
staticint ath11k_conf_tx_uapsd(struct ath11k *ar, struct ieee80211_vif *vif,
u16 ac, bool enable)
{ struct ath11k_vif *arvif = ath11k_vif_to_arvif(vif);
u32 value = 0; int ret = 0;
if (arvif->vdev_type != WMI_VDEV_TYPE_STA) return 0;
switch (ac) { case IEEE80211_AC_VO:
value = WMI_STA_PS_UAPSD_AC3_DELIVERY_EN |
WMI_STA_PS_UAPSD_AC3_TRIGGER_EN; break; case IEEE80211_AC_VI:
value = WMI_STA_PS_UAPSD_AC2_DELIVERY_EN |
WMI_STA_PS_UAPSD_AC2_TRIGGER_EN; break; case IEEE80211_AC_BE:
value = WMI_STA_PS_UAPSD_AC1_DELIVERY_EN |
WMI_STA_PS_UAPSD_AC1_TRIGGER_EN; break; case IEEE80211_AC_BK:
value = WMI_STA_PS_UAPSD_AC0_DELIVERY_EN |
WMI_STA_PS_UAPSD_AC0_TRIGGER_EN; break;
}
if (enable)
arvif->u.sta.uapsd |= value; else
arvif->u.sta.uapsd &= ~value;
ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
WMI_STA_PS_PARAM_UAPSD,
arvif->u.sta.uapsd); if (ret) {
ath11k_warn(ar->ab, "could not set uapsd params %d\n", ret); gotoexit;
}
if (arvif->u.sta.uapsd)
value = WMI_STA_PS_RX_WAKE_POLICY_POLL_UAPSD; else
value = WMI_STA_PS_RX_WAKE_POLICY_WAKE;
ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
WMI_STA_PS_PARAM_RX_WAKE_POLICY,
value); if (ret)
ath11k_warn(ar->ab, "could not set rx wake param %d\n", ret);
switch (ac) { case IEEE80211_AC_VO:
p = &arvif->muedca_params.ac_vo; break; case IEEE80211_AC_VI:
p = &arvif->muedca_params.ac_vi; break; case IEEE80211_AC_BE:
p = &arvif->muedca_params.ac_be; break; case IEEE80211_AC_BK:
p = &arvif->muedca_params.ac_bk; break; default:
ath11k_warn(ar->ab, "error ac: %d", ac); return -EINVAL;
}
switch (ac) { case IEEE80211_AC_VO:
p = &arvif->wmm_params.ac_vo; break; case IEEE80211_AC_VI:
p = &arvif->wmm_params.ac_vi; break; case IEEE80211_AC_BE:
p = &arvif->wmm_params.ac_be; break; case IEEE80211_AC_BK:
p = &arvif->wmm_params.ac_bk; break;
}
ret = ath11k_wmi_send_wmm_update_cmd_tlv(ar, arvif->vdev_id,
&arvif->wmm_params,
WMI_WMM_PARAM_TYPE_LEGACY); if (ret) {
ath11k_warn(ar->ab, "failed to set wmm params: %d\n", ret); gotoexit;
}
if (params->mu_edca) {
ret = ath11k_mac_op_conf_tx_mu_edca(hw, vif, link_id, ac,
params); if (ret) {
ath11k_warn(ar->ab, "failed to set mu_edca params: %d\n", ret); gotoexit;
}
}
ret = ath11k_conf_tx_uapsd(ar, vif, ac, params->uapsd);
if (ret)
ath11k_warn(ar->ab, "failed to set sta uapsd: %d\n", ret);
/* Enable Sounding Dimension Field only if SU BF is enabled */ if (subfer) { if (sound_dim > (ar->num_tx_chains - 1))
sound_dim = ar->num_tx_chains - 1;
/* Enable Beamformee STS Field only if SU BF is enabled */ if (subfee) {
nsts <<= IEEE80211_VHT_CAP_BEAMFORMEE_STS_SHIFT;
nsts &= IEEE80211_VHT_CAP_BEAMFORMEE_STS_MASK;
*vht_cap |= nsts;
}
}
staticint ath11k_check_chain_mask(struct ath11k *ar, u32 ant, bool is_tx_ant)
{ /* TODO: Check the request chainmask against the supported * chainmask table which is advertised in extented_service_ready event
*/
return 0;
}
staticvoid ath11k_gen_ppe_thresh(struct ath11k_ppe_threshold *fw_ppet,
u8 *he_ppet)
{ int nss, ru;
u8 bit = 7;
while ((skb = skb_dequeue(&ar->wmi_mgmt_tx_queue)) != NULL) {
skb_cb = ATH11K_SKB_CB(skb); if (!skb_cb->vif) {
ath11k_warn(ar->ab, "no vif found for mgmt frame\n");
ath11k_mgmt_over_wmi_tx_drop(ar, skb); continue;
}
if (test_bit(ATH11K_FLAG_CRASH_FLUSH, &ar->ab->dev_flags)) return -ESHUTDOWN;
/* Drop probe response packets when the pending management tx * count has reached a certain threshold, so as to prioritize * other mgmt packets like auth and assoc to be sent on time * for establishing successful connections.
*/ if (is_prb_rsp &&
atomic_read(&ar->num_pending_mgmt_tx) > ATH11K_PRB_RSP_DROP_THRESHOLD) {
ath11k_warn(ar->ab, "dropping probe response as pending queue is almost full\n"); return -ENOSPC;
}
if (skb_queue_len_lockless(q) >= ATH11K_TX_MGMT_NUM_PENDING_MAX) {
ath11k_warn(ar->ab, "mgmt tx queue is full\n"); return -ENOSPC;
}
staticint ath11k_mac_config_mon_status_default(struct ath11k *ar, bool enable)
{ struct htt_rx_ring_tlv_filter tlv_filter = {}; struct ath11k_base *ab = ar->ab; int i, ret = 0;
u32 ring_id;
if (enable) {
tlv_filter = ath11k_mac_mon_status_filter_default; if (ath11k_debugfs_rx_filter(ar))
tlv_filter.rx_filter = ath11k_debugfs_rx_filter(ar);
}
for (i = 0; i < ab->hw_params.num_rxdma_per_pdev; i++) {
ring_id = ar->dp.rx_mon_status_refill_ring[i].refill_buf_ring.ring_id;
ret = ath11k_dp_tx_htt_rx_filter_setup(ar->ab, ring_id,
ar->dp.mac_id + i,
HAL_RXDMA_MONITOR_STATUS,
DP_RX_BUFFER_SIZE,
&tlv_filter);
}
if (enable && !ar->ab->hw_params.rxdma1_enable)
mod_timer(&ar->ab->mon_reap_timer, jiffies +
msecs_to_jiffies(ATH11K_MON_TIMER_INTERVAL));
return ret;
}
staticvoid ath11k_mac_wait_reconfigure(struct ath11k_base *ab)
{ int recovery_start_count;
switch (ar->state) { case ATH11K_STATE_OFF:
ar->state = ATH11K_STATE_ON; break; case ATH11K_STATE_RESTARTING:
ar->state = ATH11K_STATE_RESTARTED;
ath11k_mac_wait_reconfigure(ab); break; case ATH11K_STATE_RESTARTED: case ATH11K_STATE_WEDGED: case ATH11K_STATE_ON: case ATH11K_STATE_FTM:
WARN_ON(1);
ret = -EINVAL; goto err;
}
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_PMF_QOS,
1, pdev->pdev_id);
if (ret) {
ath11k_err(ar->ab, "failed to enable PMF QOS: (%d\n", ret); goto err;
}
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_DYNAMIC_BW, 1,
pdev->pdev_id); if (ret) {
ath11k_err(ar->ab, "failed to enable dynamic bw: %d\n", ret); goto err;
}
if (test_bit(WMI_TLV_SERVICE_SPOOF_MAC_SUPPORT, ar->wmi->wmi_ab->svc_map)) {
ret = ath11k_wmi_scan_prob_req_oui(ar, ar->mac_addr); if (ret) {
ath11k_err(ab, "failed to set prob req oui: %i\n", ret); goto err;
}
}
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_ARP_AC_OVERRIDE,
0, pdev->pdev_id); if (ret) {
ath11k_err(ab, "failed to set ac override for ARP: %d\n",
ret); goto err;
}
ret = ath11k_wmi_send_dfs_phyerr_offload_enable_cmd(ar, pdev->pdev_id); if (ret) {
ath11k_err(ab, "failed to offload radar detection: %d\n",
ret); goto err;
}
ret = ath11k_dp_tx_htt_h2t_ppdu_stats_req(ar,
HTT_PPDU_STATS_TAG_DEFAULT); if (ret) {
ath11k_err(ab, "failed to req ppdu stats: %d\n", ret); goto err;
}
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_MESH_MCAST_ENABLE,
1, pdev->pdev_id);
if (ret) {
ath11k_err(ar->ab, "failed to enable MESH MCAST ENABLE: (%d\n", ret); goto err;
}
/* Configure monitor status ring with default rx_filter to get rx status * such as rssi, rx_duration.
*/
ret = ath11k_mac_config_mon_status_default(ar, true); if (ret) {
ath11k_err(ab, "failed to configure monitor status ring with default rx_filter: (%d)\n",
ret); goto err;
}
/* Configure the hash seed for hash based reo dest ring selection */
ath11k_wmi_pdev_lro_cfg(ar, ar->pdev->pdev_id);
/* allow device to enter IMPS */ if (ab->hw_params.idle_ps) {
ret = ath11k_wmi_pdev_set_param(ar, WMI_PDEV_PARAM_IDLE_PS_CONFIG,
1, pdev->pdev_id); if (ret) {
ath11k_err(ab, "failed to enable idle ps: %d\n", ret); goto err;
}
}
mutex_lock(&ar->conf_mutex);
ret = ath11k_mac_config_mon_status_default(ar, false); if (ret)
ath11k_err(ar->ab, "failed to clear rx_filter for monitor status ring: (%d)\n",
ret);
if (!test_bit(WMI_TLV_SERVICE_MBSS_PARAM_IN_VDEV_START_SUPPORT,
ar->ab->wmi_ab.svc_map)) {
ret = ath11k_mac_setup_vdev_params_mbssid(arvif,
¶ms->mbssid_flags,
¶ms->mbssid_tx_vdev_id); if (ret) return ret;
}
if (vif->type == NL80211_IFTYPE_AP &&
ar->num_peers > (ar->max_num_peers - 1)) {
ath11k_warn(ab, "failed to create vdev due to insufficient peer entry resource in firmware\n");
ret = -ENOBUFS; goto err;
}
if (ar->num_created_vdevs > (TARGET_NUM_VDEVS(ab) - 1)) {
ath11k_warn(ab, "failed to create vdev %u, reached max vdev limit %d\n",
ar->num_created_vdevs, TARGET_NUM_VDEVS(ab));
ret = -EBUSY; goto err;
}
nss = get_num_chains(ar->cfg_tx_chainmask) ? : 1;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
WMI_VDEV_PARAM_NSS, nss); if (ret) {
ath11k_warn(ab, "failed to set vdev %d chainmask 0x%x, nss %d :%d\n",
arvif->vdev_id, ar->cfg_tx_chainmask, nss, ret); goto err_vdev_del;
}
switch (arvif->vdev_type) { case WMI_VDEV_TYPE_AP:
peer_param.vdev_id = arvif->vdev_id;
peer_param.peer_addr = vif->addr;
peer_param.peer_type = WMI_PEER_TYPE_DEFAULT;
ret = ath11k_peer_create(ar, arvif, NULL, &peer_param); if (ret) {
ath11k_warn(ab, "failed to vdev %d create peer for AP: %d\n",
arvif->vdev_id, ret); goto err_vdev_del;
}
ret = ath11k_mac_set_kickout(arvif); if (ret) {
ath11k_warn(ar->ab, "failed to set vdev %i kickout parameters: %d\n",
arvif->vdev_id, ret); goto err_peer_del;
}
ath11k_mac_11d_scan_stop_all(ar->ab); break; case WMI_VDEV_TYPE_STA:
param_id = WMI_STA_PS_PARAM_RX_WAKE_POLICY;
param_value = WMI_STA_PS_RX_WAKE_POLICY_WAKE;
ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
param_id, param_value); if (ret) {
ath11k_warn(ar->ab, "failed to set vdev %d RX wake policy: %d\n",
arvif->vdev_id, ret); goto err_peer_del;
}
param_id = WMI_STA_PS_PARAM_TX_WAKE_THRESHOLD;
param_value = WMI_STA_PS_TX_WAKE_THRESHOLD_ALWAYS;
ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
param_id, param_value); if (ret) {
ath11k_warn(ar->ab, "failed to set vdev %d TX wake threshold: %d\n",
arvif->vdev_id, ret); goto err_peer_del;
}
param_id = WMI_STA_PS_PARAM_PSPOLL_COUNT;
param_value = WMI_STA_PS_PSPOLL_COUNT_NO_MAX;
ret = ath11k_wmi_set_sta_ps_param(ar, arvif->vdev_id,
param_id, param_value); if (ret) {
ath11k_warn(ar->ab, "failed to set vdev %d pspoll count: %d\n",
arvif->vdev_id, ret); goto err_peer_del;
}
ret = ath11k_wmi_pdev_set_ps_mode(ar, arvif->vdev_id,
WMI_STA_PS_MODE_DISABLED); if (ret) {
ath11k_warn(ar->ab, "failed to disable vdev %d ps mode: %d\n",
arvif->vdev_id, ret); goto err_peer_del;
}
if (test_bit(WMI_TLV_SERVICE_11D_OFFLOAD, ab->wmi_ab.svc_map)) {
reinit_completion(&ar->completed_11d_scan);
ar->state_11d = ATH11K_11D_PREPARING;
} break; case WMI_VDEV_TYPE_MONITOR:
set_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags); break; default: break;
}
arvif->txpower = vif->bss_conf.txpower;
ret = ath11k_mac_txpower_recalc(ar); if (ret) goto err_peer_del;
param_id = WMI_VDEV_PARAM_RTS_THRESHOLD;
param_value = ar->hw->wiphy->rts_threshold;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
param_id, param_value); if (ret) {
ath11k_warn(ar->ab, "failed to set rts threshold for vdev %d: %d\n",
arvif->vdev_id, ret);
}
ath11k_dp_vdev_tx_attach(ar, arvif);
if (vif->type != NL80211_IFTYPE_MONITOR &&
test_bit(ATH11K_FLAG_MONITOR_CONF_ENABLED, &ar->monitor_flags)) {
ret = ath11k_mac_monitor_vdev_create(ar); if (ret)
ath11k_warn(ar->ab, "failed to create monitor vdev during add interface: %d",
ret);
}
if (ath11k_wmi_supports_6ghz_cc_ext(ar)) { struct cur_regulatory_info *reg_info;
ret = ath11k_spectral_vif_stop(arvif); if (ret)
ath11k_warn(ab, "failed to stop spectral for vdev %i: %d\n",
arvif->vdev_id, ret);
if (arvif->vdev_type == WMI_VDEV_TYPE_STA)
ath11k_mac_11d_scan_stop(ar);
if (arvif->vdev_type == WMI_VDEV_TYPE_AP) {
ret = ath11k_peer_delete(ar, arvif->vdev_id, vif->addr); if (ret)
ath11k_warn(ab, "failed to submit AP self-peer removal on vdev %d: %d\n",
arvif->vdev_id, ret);
}
ret = ath11k_mac_vdev_delete(ar, arvif); if (ret) {
ath11k_warn(ab, "failed to delete vdev %d: %d\n",
arvif->vdev_id, ret); goto err_vdev_del;
}
if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
clear_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags);
ar->monitor_vdev_id = -1;
} elseif (test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags) &&
!test_bit(ATH11K_FLAG_MONITOR_STARTED, &ar->monitor_flags)) {
ret = ath11k_mac_monitor_vdev_delete(ar); if (ret) /* continue even if there's an error */
ath11k_warn(ar->ab, "failed to delete vdev monitor during remove interface: %d",
ret);
}
for (i = 0; i < ab->hw_params.max_tx_ring; i++) {
spin_lock_bh(&ab->dp.tx_ring[i].tx_idr_lock);
idr_for_each(&ab->dp.tx_ring[i].txbuf_idr,
ath11k_mac_vif_unref, vif);
spin_unlock_bh(&ab->dp.tx_ring[i].tx_idr_lock);
}
/* Recalc txpower for remaining vdev */
ath11k_mac_txpower_recalc(ar);
/* TODO: recalc traffic pause state based on the available vdevs */
mutex_unlock(&ar->conf_mutex);
}
/* FIXME: Has to be verified. */ #define SUPPORTED_FILTERS \
(FIF_ALLMULTI | \
FIF_CONTROL | \
FIF_PSPOLL | \
FIF_OTHER_BSS | \
FIF_BCN_PRBRESP_PROMISC | \
FIF_PROBE_REQ | \
FIF_FCSFAIL)
staticint ath11k_mac_op_set_antenna(struct ieee80211_hw *hw, int radio_idx,
u32 tx_ant, u32 rx_ant)
{ struct ath11k *ar = hw->priv; int ret;
mutex_lock(&ar->conf_mutex);
ret = __ath11k_set_antenna(ar, tx_ant, rx_ant);
mutex_unlock(&ar->conf_mutex);
return ret;
}
staticint ath11k_mac_op_ampdu_action(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_ampdu_params *params)
{ struct ath11k *ar = hw->priv; int ret = -EINVAL;
mutex_lock(&ar->conf_mutex);
switch (params->action) { case IEEE80211_AMPDU_RX_START:
ret = ath11k_dp_rx_ampdu_start(ar, params); break; case IEEE80211_AMPDU_RX_STOP:
ret = ath11k_dp_rx_ampdu_stop(ar, params); break; case IEEE80211_AMPDU_TX_START: case IEEE80211_AMPDU_TX_STOP_CONT: case IEEE80211_AMPDU_TX_STOP_FLUSH: case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT: case IEEE80211_AMPDU_TX_OPERATIONAL: /* Tx A-MPDU aggregation offloaded to hw/fw so deny mac80211 * Tx aggregation requests.
*/
ret = -EOPNOTSUPP; break;
}
spin_lock_bh(&ar->data_lock); /* TODO: In case of there is one more channel context left, populate * rx_channel with the channel of that remaining channel context.
*/
ar->rx_channel = NULL;
spin_unlock_bh(&ar->data_lock);
ret = ath11k_wmi_vdev_start(ar, &arg, restart); if (ret) {
ath11k_warn(ar->ab, "failed to %s WMI vdev %i\n",
restart ? "restart" : "start", arg.vdev_id); return ret;
}
ret = ath11k_mac_vdev_setup_sync(ar); if (ret) {
ath11k_warn(ab, "failed to synchronize setup for vdev %i %s: %d\n",
arg.vdev_id, restart ? "restart" : "start", ret); return ret;
}
/* TODO: For now we only set TPC power here. However when * channel changes, say CSA, it should be updated again.
*/ if (ath11k_mac_supports_station_tpc(ar, arvif, chandef)) {
ath11k_mac_fill_reg_tpc_info(ar, arvif->vif, &arvif->chanctx);
ath11k_wmi_send_vdev_set_tpc_power(ar, arvif->vdev_id,
&arvif->reg_tpc_info);
}
/* Enable CAC Flag in the driver by checking the all sub-channel's DFS * state as NL80211_DFS_USABLE which indicates CAC needs to be * done before channel usage. This flags is used to drop rx packets. * during CAC.
*/ /* TODO Set the flag for other interface types as required */ if (arvif->vdev_type == WMI_VDEV_TYPE_AP && ctx->radar_enabled &&
cfg80211_chandef_dfs_usable(ar->hw->wiphy, chandef)) {
set_bit(ATH11K_CAC_RUNNING, &ar->dev_flags);
dfs_cac_time = cfg80211_chandef_dfs_cac_time(ar->hw->wiphy,
chandef);
ath11k_dbg(ab, ATH11K_DBG_MAC, "cac started dfs_cac_time %u center_freq %d center_freq1 %d for vdev %d\n",
dfs_cac_time, arg.channel.freq, chandef->center_freq1,
arg.vdev_id);
}
ret = ath11k_mac_set_txbf_conf(arvif); if (ret)
ath11k_warn(ab, "failed to set txbf conf for vdev %d: %d\n",
arvif->vdev_id, ret);
ret = ath11k_wmi_vdev_stop(ar, arvif->vdev_id); if (ret) {
ath11k_warn(ar->ab, "failed to stop WMI vdev %i: %d\n",
arvif->vdev_id, ret); goto err;
}
ret = ath11k_mac_vdev_setup_sync(ar); if (ret) {
ath11k_warn(ar->ab, "failed to synchronize setup for vdev %i: %d\n",
arvif->vdev_id, ret); goto err;
}
staticvoid
ath11k_mac_update_vif_chan(struct ath11k *ar, struct ieee80211_vif_chanctx_switch *vifs, int n_vifs)
{ struct ath11k_base *ab = ar->ab; struct ath11k_vif *arvif, *tx_arvif; int ret; int i; bool monitor_vif = false;
lockdep_assert_held(&ar->conf_mutex);
/* Associated channel resources of all relevant vdevs * should be available for the channel switch now.
*/
/* TODO: Update ar->rx_channel */
for (i = 0; i < n_vifs; i++) {
arvif = ath11k_vif_to_arvif(vifs[i].vif);
if (WARN_ON(!arvif->is_started)) continue;
/* change_chanctx can be called even before vdev_up from * ieee80211_start_ap->ieee80211_vif_use_channel-> * ieee80211_recalc_radar_chanctx. * * Firmware expect vdev_restart only if vdev is up. * If vdev is down then it expect vdev_stop->vdev_start.
*/ if (arvif->is_up) {
ret = ath11k_mac_vdev_restart(arvif, vifs[i].new_ctx); if (ret) {
ath11k_warn(ab, "failed to restart vdev %d: %d\n",
arvif->vdev_id, ret); continue;
}
} else {
ret = ath11k_mac_vdev_stop(arvif); if (ret) {
ath11k_warn(ab, "failed to stop vdev %d: %d\n",
arvif->vdev_id, ret); continue;
}
ret = ath11k_mac_vdev_start(arvif, vifs[i].new_ctx); if (ret)
ath11k_warn(ab, "failed to start vdev %d: %d\n",
arvif->vdev_id, ret);
continue;
}
ret = ath11k_mac_setup_bcn_tmpl(arvif); if (ret)
ath11k_warn(ab, "failed to update bcn tmpl during csa: %d\n",
ret);
tx_arvif = ath11k_mac_get_tx_arvif(arvif);
ret = ath11k_wmi_vdev_up(arvif->ar, arvif->vdev_id, arvif->aid,
arvif->bssid,
tx_arvif ? tx_arvif->bssid : NULL,
arvif->vif->bss_conf.bssid_index,
1 << arvif->vif->bss_conf.bssid_indicator); if (ret) {
ath11k_warn(ab, "failed to bring vdev up %d: %d\n",
arvif->vdev_id, ret); continue;
}
}
/* Restart the internal monitor vdev on new channel */ if (!monitor_vif &&
test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) {
ret = ath11k_mac_monitor_stop(ar); if (ret) {
ath11k_warn(ar->ab, "failed to stop monitor during vif channel update: %d",
ret); return;
}
ret = ath11k_mac_monitor_start(ar); if (ret) {
ath11k_warn(ar->ab, "failed to start monitor during vif channel update: %d",
ret); return;
}
}
}
/* This shouldn't really happen because channel switching should use * switch_vif_chanctx().
*/ if (WARN_ON(changed & IEEE80211_CHANCTX_CHANGE_CHANNEL)) goto unlock;
if (changed & IEEE80211_CHANCTX_CHANGE_WIDTH ||
changed & IEEE80211_CHANCTX_CHANGE_RADAR)
ath11k_mac_update_active_vif_chan(ar, ctx);
/* It is to get the lowest channel number's center frequency of the chan. * For example, * bandwidth=40 MHz, center frequency is 5965, lowest channel is 1 * with center frequency 5955, its diff is 5965 - 5955 = 10. * bandwidth=80 MHz, center frequency is 5985, lowest channel is 1 * with center frequency 5955, its diff is 5985 - 5955 = 30. * bandwidth=160 MHz, center frequency is 6025, lowest channel is 1 * with center frequency 5955, its diff is 6025 - 5955 = 70.
*/ switch (chan_def->width) { case NL80211_CHAN_WIDTH_160:
diff_seq = 70; break; case NL80211_CHAN_WIDTH_80: case NL80211_CHAN_WIDTH_80P80:
diff_seq = 30; break; case NL80211_CHAN_WIDTH_40:
diff_seq = 10; break; default:
diff_seq = 0;
}
/* It is to get the center frequency of the specific bandwidth. * start_seq means the lowest channel number's center frequency. * seq 0/1/2/3 means 20 MHz/40 MHz/80 MHz/160 MHz&80P80. * For example, * lowest channel is 1, its center frequency 5955, * center frequency is 5955 when bandwidth=20 MHz, its diff is 5955 - 5955 = 0. * lowest channel is 1, its center frequency 5955, * center frequency is 5965 when bandwidth=40 MHz, its diff is 5965 - 5955 = 10. * lowest channel is 1, its center frequency 5955, * center frequency is 5985 when bandwidth=80 MHz, its diff is 5985 - 5955 = 30. * lowest channel is 1, its center frequency 5955, * center frequency is 6025 when bandwidth=160 MHz, its diff is 6025 - 5955 = 70.
*/ if (chan_def->width == NL80211_CHAN_WIDTH_80P80 && seq == 3) return chan_def->center_freq2;
staticvoid ath11k_mac_get_psd_channel(struct ath11k *ar,
u16 step_freq,
u16 *start_freq,
u16 *center_freq,
u8 i, struct ieee80211_channel **temp_chan,
s8 *tx_power)
{ /* It is to get the center frequency for each 20 MHz. * For example, if the chan is 160 MHz and center frequency is 6025, * then it include 8 channels, they are 1/5/9/13/17/21/25/29, * channel number 1's center frequency is 5955, it is parameter start_freq. * parameter i is the step of the 8 channels. i is 0~7 for the 8 channels. * the channel 1/5/9/13/17/21/25/29 maps i=0/1/2/3/4/5/6/7, * and maps its center frequency is 5955/5975/5995/6015/6035/6055/6075/6095, * the gap is 20 for each channel, parameter step_freq means the gap. * after get the center frequency of each channel, it is easy to find the * struct ieee80211_channel of it and get the max_reg_power.
*/
*center_freq = *start_freq + i * step_freq;
*temp_chan = ieee80211_get_channel(ar->hw->wiphy, *center_freq);
*tx_power = (*temp_chan)->max_reg_power;
}
staticvoid ath11k_mac_get_eirp_power(struct ath11k *ar,
u16 *start_freq,
u16 *center_freq,
u8 i, struct ieee80211_channel **temp_chan, struct cfg80211_chan_def *def,
s8 *tx_power)
{ /* It is to get the center frequency for 20 MHz/40 MHz/80 MHz/ * 160 MHz&80P80 bandwidth, and then plus 10 to the center frequency, * it is the center frequency of a channel number. * For example, when configured channel number is 1. * center frequency is 5965 when bandwidth=40 MHz, after plus 10, it is 5975, * then it is channel number 5. * center frequency is 5985 when bandwidth=80 MHz, after plus 10, it is 5995, * then it is channel number 9. * center frequency is 6025 when bandwidth=160 MHz, after plus 10, it is 6035, * then it is channel number 17. * after get the center frequency of each channel, it is easy to find the * struct ieee80211_channel of it and get the max_reg_power.
*/
*center_freq = ath11k_mac_get_seg_freq(def, *start_freq, i);
/* For the 20 MHz, its center frequency is same with same channel */ if (i != 0)
*center_freq += 10;
for (pwr_lvl_idx = 0; pwr_lvl_idx < num_pwr_levels; pwr_lvl_idx++) { /* STA received TPE IE*/ if (is_tpe_present) { /* local power is PSD power*/ if (chan->flags & IEEE80211_CHAN_PSD) { /* Connecting AP is psd power */ if (reg_tpc_info->is_psd_power) {
is_psd_power = true;
ath11k_mac_get_psd_channel(ar, 20,
&start_freq,
¢er_freq,
pwr_lvl_idx,
&temp_chan,
&tx_power);
psd_power = temp_chan->psd;
eirp_power = tx_power;
max_tx_power[pwr_lvl_idx] =
min_t(s8,
psd_power,
reg_tpc_info->tpe[pwr_lvl_idx]); /* Connecting AP is not psd power */
} else {
ath11k_mac_get_eirp_power(ar,
&start_freq,
¢er_freq,
pwr_lvl_idx,
&temp_chan,
&ctx->def,
&tx_power);
psd_power = temp_chan->psd; /* convert psd power to EIRP power based * on channel width
*/
tx_power =
min_t(s8, tx_power,
psd_power + 13 + pwr_lvl_idx * 3);
max_tx_power[pwr_lvl_idx] =
min_t(s8,
tx_power,
reg_tpc_info->tpe[pwr_lvl_idx]);
} /* local power is not PSD power */
} else { /* Connecting AP is psd power */ if (reg_tpc_info->is_psd_power) {
is_psd_power = true;
ath11k_mac_get_psd_channel(ar, 20,
&start_freq,
¢er_freq,
pwr_lvl_idx,
&temp_chan,
&tx_power);
eirp_power = tx_power;
max_tx_power[pwr_lvl_idx] =
reg_tpc_info->tpe[pwr_lvl_idx]; /* Connecting AP is not psd power */
} else {
ath11k_mac_get_eirp_power(ar,
&start_freq,
¢er_freq,
pwr_lvl_idx,
&temp_chan,
&ctx->def,
&tx_power);
max_tx_power[pwr_lvl_idx] =
min_t(s8,
tx_power,
reg_tpc_info->tpe[pwr_lvl_idx]);
}
} /* STA not received TPE IE */
} else { /* local power is PSD power*/ if (chan->flags & IEEE80211_CHAN_PSD) {
is_psd_power = true;
ath11k_mac_get_psd_channel(ar, 20,
&start_freq,
¢er_freq,
pwr_lvl_idx,
&temp_chan,
&tx_power);
psd_power = temp_chan->psd;
eirp_power = tx_power;
max_tx_power[pwr_lvl_idx] = psd_power;
} else {
ath11k_mac_get_eirp_power(ar,
&start_freq,
¢er_freq,
pwr_lvl_idx,
&temp_chan,
&ctx->def,
&tx_power);
max_tx_power[pwr_lvl_idx] = tx_power;
}
}
if (is_psd_power) { /* If AP local power constraint is present */ if (pwr_reduction)
eirp_power = eirp_power - pwr_reduction;
/* If firmware updated max tx power is non zero, then take * the min of firmware updated ap tx power * and max power derived from above mentioned parameters.
*/
ath11k_dbg(ab, ATH11K_DBG_MAC, "eirp power : %d firmware report power : %d\n",
eirp_power, ar->max_allowed_tx_power); /* Firmware reports lower max_allowed_tx_power during vdev * start response. In case of 6 GHz, firmware is not aware * of EIRP power unless driver sets EIRP power through WMI * TPC command. So radio which does not support idle power * save can set maximum calculated EIRP power directly to * firmware through TPC command without min comparison with * vdev start response's max_allowed_tx_power.
*/ if (ar->max_allowed_tx_power && ab->hw_params.idle_ps)
eirp_power = min_t(s8,
eirp_power,
ar->max_allowed_tx_power);
} else { /* If AP local power constraint is present */ if (pwr_reduction)
max_tx_power[pwr_lvl_idx] =
max_tx_power[pwr_lvl_idx] - pwr_reduction; /* If firmware updated max tx power is non zero, then take * the min of firmware updated ap tx power * and max power derived from above mentioned parameters.
*/ if (ar->max_allowed_tx_power && ab->hw_params.idle_ps)
max_tx_power[pwr_lvl_idx] =
min_t(s8,
max_tx_power[pwr_lvl_idx],
ar->max_allowed_tx_power);
}
reg_tpc_info->chan_power_info[pwr_lvl_idx].chan_cfreq = center_freq;
reg_tpc_info->chan_power_info[pwr_lvl_idx].tx_power =
max_tx_power[pwr_lvl_idx];
}
/* for QCA6390 bss peer must be created before vdev_start */ if (ab->hw_params.vdev_start_delay &&
arvif->vdev_type != WMI_VDEV_TYPE_AP &&
arvif->vdev_type != WMI_VDEV_TYPE_MONITOR &&
!ath11k_peer_find_by_vdev_id(ab, arvif->vdev_id)) {
memcpy(&arvif->chanctx, ctx, sizeof(*ctx));
ret = 0; goto out;
}
if (WARN_ON(arvif->is_started)) {
ret = -EBUSY; goto out;
}
if (arvif->vdev_type == WMI_VDEV_TYPE_MONITOR) {
ret = ath11k_mac_monitor_start(ar); if (ret) {
ath11k_warn(ar->ab, "failed to start monitor during vif channel context assignment: %d",
ret); goto out;
}
arvif->is_started = true; goto out;
}
if (!arvif->is_started) {
ret = ath11k_mac_vdev_start(arvif, ctx); if (ret) {
ath11k_warn(ab, "failed to start vdev %i addr %pM on freq %d: %d\n",
arvif->vdev_id, vif->addr,
ctx->def.chan->center_freq, ret); goto out;
}
arvif->is_started = true;
}
if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR &&
test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) {
ret = ath11k_mac_monitor_start(ar); if (ret) {
ath11k_warn(ar->ab, "failed to start monitor during vif channel context assignment: %d",
ret); goto out;
}
}
if (arvif->is_started) {
ret = ath11k_mac_vdev_stop(arvif); if (ret)
ath11k_warn(ab, "failed to stop vdev %i: %d\n",
arvif->vdev_id, ret);
arvif->is_started = false;
}
if (ab->hw_params.vdev_start_delay &&
arvif->vdev_type == WMI_VDEV_TYPE_MONITOR)
ath11k_wmi_vdev_down(ar, arvif->vdev_id);
if (arvif->vdev_type != WMI_VDEV_TYPE_MONITOR &&
ar->num_started_vdevs == 1 &&
test_bit(ATH11K_FLAG_MONITOR_VDEV_CREATED, &ar->monitor_flags)) {
ret = ath11k_mac_monitor_stop(ar); if (ret) /* continue even if there's an error */
ath11k_warn(ar->ab, "failed to stop monitor during vif channel context unassignment: %d",
ret);
}
if (arvif->vdev_type == WMI_VDEV_TYPE_STA)
ath11k_mac_11d_scan_start(ar, arvif->vdev_id);
staticint
ath11k_set_vdev_param_to_all_vifs(struct ath11k *ar, int param, u32 value)
{ struct ath11k_vif *arvif; int ret = 0;
mutex_lock(&ar->conf_mutex);
list_for_each_entry(arvif, &ar->arvifs, list) {
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "setting mac vdev %d param %d value %d\n",
param, arvif->vdev_id, value);
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
param, value); if (ret) {
ath11k_warn(ar->ab, "failed to set param %d for vdev %d: %d\n",
param, arvif->vdev_id, ret); break;
}
}
mutex_unlock(&ar->conf_mutex); return ret;
}
/* mac80211 stores device specific RTS/Fragmentation threshold value, * this is set interface specific to firmware from ath11k driver
*/ staticint ath11k_mac_op_set_rts_threshold(struct ieee80211_hw *hw, int radio_idx, u32 value)
{ struct ath11k *ar = hw->priv; int param_id = WMI_VDEV_PARAM_RTS_THRESHOLD;
staticint ath11k_mac_op_set_frag_threshold(struct ieee80211_hw *hw, int radio_idx, u32 value)
{ /* Even though there's a WMI vdev param for fragmentation threshold no * known firmware actually implements it. Moreover it is not possible to * rely frame fragmentation to mac80211 because firmware clears the * "more fragments" bit in frame control making it impossible for remote * devices to reassemble frames. * * Hence implement a dummy callback just to say fragmentation isn't * supported. This effectively prevents mac80211 from doing frame * fragmentation in software.
*/ return -EOPNOTSUPP;
}
staticint ath11k_mac_flush_tx_complete(struct ath11k *ar)
{ long time_left; int ret = 0;
time_left = wait_event_timeout(ar->dp.tx_empty_waitq,
(atomic_read(&ar->dp.num_tx_pending) == 0),
ATH11K_FLUSH_TIMEOUT); if (time_left == 0) {
ath11k_warn(ar->ab, "failed to flush transmit queue, data pkts pending %d\n",
atomic_read(&ar->dp.num_tx_pending));
ret = -ETIMEDOUT;
}
time_left = wait_event_timeout(ar->txmgmt_empty_waitq,
(atomic_read(&ar->num_pending_mgmt_tx) == 0),
ATH11K_FLUSH_TIMEOUT); if (time_left == 0) {
ath11k_warn(ar->ab, "failed to flush mgmt transmit queue, mgmt pkts pending %d\n",
atomic_read(&ar->num_pending_mgmt_tx));
ret = -ETIMEDOUT;
}
return ret;
}
int ath11k_mac_wait_tx_complete(struct ath11k *ar)
{
ath11k_mac_drain_tx(ar); return ath11k_mac_flush_tx_complete(ar);
}
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
WMI_VDEV_PARAM_SGI, he_gi); if (ret) {
ath11k_warn(ar->ab, "failed to set he gi %d: %d\n",
he_gi, ret); return ret;
} /* start from 1 */ if (he_ltf != 0xFF)
he_ltf += 1;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
WMI_VDEV_PARAM_HE_LTF, he_ltf); if (ret) {
ath11k_warn(ar->ab, "failed to set he ltf %d: %d\n",
he_ltf, ret); return ret;
}
if (!arvif->vif->bss_conf.he_support) {
vdev_param = WMI_VDEV_PARAM_FIXED_RATE;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, rate); if (ret) {
ath11k_warn(ar->ab, "failed to set fixed rate param 0x%02x: %d\n",
rate, ret); return ret;
}
}
vdev_param = WMI_VDEV_PARAM_NSS;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, nss); if (ret) {
ath11k_warn(ar->ab, "failed to set nss param %d: %d\n",
nss, ret); return ret;
}
vdev_param = WMI_VDEV_PARAM_LDPC;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, ldpc); if (ret) {
ath11k_warn(ar->ab, "failed to set ldpc param %d: %d\n",
ldpc, ret); return ret;
}
if (arvif->vif->bss_conf.he_support) { if (he_fixed_rate) {
ret = ath11k_mac_set_fixed_rate_gi_ltf(arvif, he_gi,
he_ltf); if (ret) {
ath11k_warn(ar->ab, "failed to set fixed rate gi ltf: %d\n",
ret); return ret;
}
} else {
ret = ath11k_mac_set_auto_rate_gi_ltf(arvif, he_gi,
he_ltf); if (ret) {
ath11k_warn(ar->ab, "failed to set auto rate gi ltf: %d\n",
ret); return ret;
}
}
} else {
vdev_param = WMI_VDEV_PARAM_SGI;
ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id,
vdev_param, sgi); if (ret) {
ath11k_warn(ar->ab, "failed to set sgi param %d: %d\n",
sgi, ret); return ret;
}
}
ret = ath11k_wmi_set_peer_param(ar, sta->addr,
arvif->vdev_id,
WMI_PEER_PARAM_FIXED_RATE,
WMI_FIXED_RATE_NONE); if (ret)
ath11k_warn(ar->ab, "failed to disable peer fixed rate for STA %pM ret %d\n",
sta->addr, ret);
}
/* mac80211 doesn't support sending a fixed HT/VHT MCS alone, rather it * requires passing at least one of used basic rates along with them. * Fixed rate setting across different preambles(legacy, HT, VHT) is * not supported by the FW. Hence use of FIXED_RATE vdev param is not * suitable for setting single HT/VHT rates. * But, there could be a single basic rate passed from userspace which * can be done through the FIXED_RATE param.
*/ if (ath11k_mac_has_single_legacy_rate(ar, band, mask)) {
ret = ath11k_mac_get_single_legacy_rate(ar, band, mask, &rate,
&nss); if (ret) {
ath11k_warn(ar->ab, "failed to get single legacy rate for vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
ieee80211_iterate_stations_mtx(ar->hw,
ath11k_mac_disable_peer_fixed_rate,
arvif);
} elseif (ath11k_mac_bitrate_mask_get_single_nss(ar, arvif, band, mask,
&single_nss)) {
rate = WMI_FIXED_RATE_NONE;
nss = single_nss;
mutex_lock(&ar->conf_mutex);
arvif->bitrate_mask = *mask;
ieee80211_iterate_stations_atomic(ar->hw,
ath11k_mac_set_bitrate_mask_iter,
arvif);
mutex_unlock(&ar->conf_mutex);
} else {
rate = WMI_FIXED_RATE_NONE;
if (!ath11k_mac_validate_vht_he_fixed_rate_settings(ar, band, mask))
ath11k_warn(ar->ab, "could not update fixed rate settings to all peers due to mcs/nss incompatibility\n");
nss = min_t(u32, ar->num_tx_chains,
ath11k_mac_max_nss(ht_mcs_mask, vht_mcs_mask, he_mcs_mask));
/* If multiple rates across different preambles are given * we can reconfigure this info with all peers using PEER_ASSOC * command with the below exception cases. * - Single VHT Rate : peer_assoc command accommodates only MCS * range values i.e 0-7, 0-8, 0-9 for VHT. Though mac80211 * mandates passing basic rates along with HT/VHT rates, FW * doesn't allow switching from VHT to Legacy. Hence instead of * setting legacy and VHT rates using RATEMASK_CMD vdev cmd, * we could set this VHT rate as peer fixed rate param, which * will override FIXED rate and FW rate control algorithm. * If single VHT rate is passed along with HT rates, we select * the VHT rate as fixed rate for vht peers. * - Multiple VHT Rates : When Multiple VHT rates are given,this * can be set using RATEMASK CMD which uses FW rate-ctl alg. * TODO: Setting multiple VHT MCS and replacing peer_assoc with * RATEMASK_CMDID can cover all use cases of setting rates * across multiple preambles and rates within same type. * But requires more validation of the command at this point.
*/
if (!ath11k_mac_he_mcs_range_present(ar, band, mask) &&
num_rates > 1) {
ath11k_warn(ar->ab, "Setting more than one HE MCS Value in bitrate mask not supported\n"); return -EINVAL;
}
if (ab->is_reset) {
recovery_count = atomic_inc_return(&ab->recovery_count);
ath11k_dbg(ab, ATH11K_DBG_BOOT, "recovery count %d\n", recovery_count); /* When there are multiple radios in an SOC, * the recovery has to be done for each radio
*/ if (recovery_count == ab->num_radios) {
atomic_dec(&ab->reset_count);
complete(&ab->reset_complete);
ab->is_reset = false;
atomic_set(&ab->fail_cont_count, 0);
ath11k_dbg(ab, ATH11K_DBG_BOOT, "reset success\n");
}
} if (ar->ab->hw_params.support_fw_mac_sequence) {
list_for_each_entry(arvif, &ar->arvifs, list) { if (arvif->is_up && arvif->vdev_type == WMI_VDEV_TYPE_STA)
ieee80211_hw_restart_disconnect(arvif->vif);
}
}
}
mutex_unlock(&ar->conf_mutex);
}
staticvoid
ath11k_mac_update_bss_chan_survey(struct ath11k *ar, struct ieee80211_channel *channel)
{ int ret; enum wmi_bss_chan_info_req_type type = WMI_BSS_SURVEY_REQ_TYPE_READ;
lockdep_assert_held(&ar->conf_mutex);
if (!test_bit(WMI_TLV_SERVICE_BSS_CHANNEL_INFO_64, ar->ab->wmi_ab.svc_map) ||
ar->rx_channel != channel) return;
if (ar->scan.state != ATH11K_SCAN_IDLE) {
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "ignoring bss chan info req while scanning..\n"); return;
}
reinit_completion(&ar->bss_survey_done);
ret = ath11k_wmi_pdev_bss_chan_info_request(ar, type); if (ret) {
ath11k_warn(ar->ab, "failed to send pdev bss chan info request\n"); return;
}
ret = wait_for_completion_timeout(&ar->bss_survey_done, 3 * HZ); if (ret == 0)
ath11k_warn(ar->ab, "bss channel survey timed out\n");
}
staticint ath11k_mac_op_get_survey(struct ieee80211_hw *hw, int idx, struct survey_info *survey)
{ struct ath11k *ar = hw->priv; struct ieee80211_supported_band *sband; struct survey_info *ar_survey; int ret = 0;
for (i = 0; i < ARRAY_SIZE(sinfo->chain_signal); i++) {
sinfo->chains &= ~BIT(i);
rssi = arsta->chain_signal[i]; if (clear)
arsta->chain_signal[i] = ATH11K_INVALID_RSSI_FULL;
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "sta statistics %s rssi[%d] %d\n", pre, i, rssi);
ret = ath11k_wmi_send_stats_request_cmd(ar, req_param);
if (ret) {
ath11k_warn(ab, "could not request fw stats (%d)\n",
ret); return ret;
}
time_left = wait_for_completion_timeout(&ar->fw_stats_complete, 1 * HZ); if (!time_left) return -ETIMEDOUT;
/* FW stats can get split when exceeding the stats data buffer limit. * In that case, since there is no end marking for the back-to-back * received 'update stats' event, we keep a 3 seconds timeout in case, * fw_stats_done is not marked yet
*/
time_left = wait_for_completion_timeout(&ar->fw_stats_done, 3 * HZ); if (!time_left) return -ETIMEDOUT;
/* The _ipv6_changed() is called with RCU lock already held in * atomic_notifier_call_chain(), so we don't need to call * rcu_read_lock() again here. But note that with CONFIG_PREEMPT_RT * enabled, read_lock_bh() also calls rcu_read_lock(). This is OK * because RCU read critical section is allowed to get nested.
*/
read_lock_bh(&idev->lock);
if (!test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) ||
!ar->ab->hw_params.bios_sar_capa) {
ret = -EOPNOTSUPP; gotoexit;
}
ret = ath11k_wmi_pdev_set_bios_geo_table_param(ar); if (ret) {
ath11k_warn(ar->ab, "failed to set geo table: %d\n", ret); gotoexit;
}
sar_tbl = kzalloc(BIOS_SAR_TABLE_LEN, GFP_KERNEL); if (!sar_tbl) {
ret = -ENOMEM; gotoexit;
}
sspec = sar->sub_specs; for (i = 0; i < sar->num_sub_specs; i++) { if (sspec->freq_range_index >= (BIOS_SAR_TABLE_LEN >> 1)) {
ath11k_warn(ar->ab, "Ignore bad frequency index %u, max allowed %u\n",
sspec->freq_range_index, BIOS_SAR_TABLE_LEN >> 1); continue;
}
/* chain0 and chain1 share same power setting */
sar_tbl[sspec->freq_range_index] = sspec->power;
index = sspec->freq_range_index + (BIOS_SAR_TABLE_LEN >> 1);
sar_tbl[index] = sspec->power;
ath11k_dbg(ar->ab, ATH11K_DBG_MAC, "sar tbl[%d] = %d\n",
sspec->freq_range_index, sar_tbl[sspec->freq_range_index]);
sspec++;
}
ret = ath11k_wmi_pdev_set_bios_sar_table_param(ar, sar_tbl); if (ret)
ath11k_warn(ar->ab, "failed to set sar power: %d", ret);
ret = wait_for_completion_timeout(&ar->scan.on_channel, 3 * HZ); if (ret == 0) {
ath11k_warn(ar->ab, "failed to switch to channel for roc scan\n");
ret = ath11k_scan_stop(ar); if (ret)
ath11k_warn(ar->ab, "failed to stop scan: %d\n", ret);
ret = -ETIMEDOUT; goto free_chan_list;
}
/* Final Tx power is minimum of Target Power, CTL power, Regulatory * Power, PSD EIRP Power. We just know the Regulatory power from the * regulatory rules obtained. FW knows all these power and sets the min * of these. Hence, we request the FW pdev stats in which FW reports * the minimum of all vdev's channel Tx power.
*/
mutex_lock(&ar->conf_mutex);
/* Firmware doesn't provide Tx power during CAC hence no need to fetch * the stats.
*/ if (test_bit(ATH11K_CAC_RUNNING, &ar->dev_flags)) {
mutex_unlock(&ar->conf_mutex); return -EAGAIN;
}
ret = ath11k_mac_get_fw_stats(ar, ar->pdev->pdev_id, 0,
WMI_REQUEST_PDEV_STAT); if (ret) {
ath11k_warn(ab, "failed to request fw pdev stats: %d\n", ret); goto err_fallback;
}
ret = ath11k_mac_inc_num_stations(arvif, sta); if (ret) {
ath11k_warn(ab, "refusing to associate station: too many connected already (%d)\n",
ar->max_num_stations); gotoexit;
}
/* Driver allows the DEL KEY followed by SET KEY sequence for * group keys for only when there is no clients associated, if at * all firmware has entered the race during that window, * reinstalling the same key when the first sta connects will allow * firmware to recover from the race.
*/ if (arvif->num_stations == 1 && arvif->reinstall_group_keys) {
ath11k_dbg(ab, ATH11K_DBG_MAC, "set group keys on 1st station add for vdev %d\n",
arvif->vdev_id);
ret = ath11k_set_group_keys(arvif); if (ret) goto dec_num_station;
arvif->reinstall_group_keys = false;
}
arsta->rx_stats = kzalloc(sizeof(*arsta->rx_stats), GFP_KERNEL); if (!arsta->rx_stats) {
ret = -ENOMEM; goto dec_num_station;
}
ret = ath11k_peer_create(ar, arvif, sta, &peer_param); if (ret) {
ath11k_warn(ab, "Failed to add peer: %pM for VDEV: %d\n",
sta->addr, arvif->vdev_id); goto free_rx_stats;
}
ath11k_dbg(ab, ATH11K_DBG_MAC, "Added peer: %pM for VDEV: %d\n",
sta->addr, arvif->vdev_id);
if (ath11k_debugfs_is_extd_tx_stats_enabled(ar)) {
arsta->tx_stats = kzalloc(sizeof(*arsta->tx_stats), GFP_KERNEL); if (!arsta->tx_stats) {
ret = -ENOMEM; goto free_peer;
}
}
if (ieee80211_vif_is_mesh(vif)) {
ath11k_dbg(ab, ATH11K_DBG_MAC, "setting USE_4ADDR for mesh STA %pM\n", sta->addr);
ret = ath11k_wmi_set_peer_param(ar, sta->addr,
arvif->vdev_id,
WMI_PEER_USE_4ADDR, 1); if (ret) {
ath11k_warn(ab, "failed to set mesh STA %pM 4addr capability: %d\n",
sta->addr, ret); goto free_tx_stats;
}
}
ret = ath11k_dp_peer_setup(ar, arvif->vdev_id, sta->addr); if (ret) {
ath11k_warn(ab, "failed to setup dp for peer %pM on vdev %i (%d)\n",
sta->addr, arvif->vdev_id, ret); goto free_tx_stats;
}
if (ab->hw_params.vdev_start_delay &&
!arvif->is_started &&
arvif->vdev_type != WMI_VDEV_TYPE_AP) {
ret = ath11k_mac_start_vdev_delay(ar->hw, vif); if (ret) {
ath11k_warn(ab, "failed to delay vdev start: %d\n", ret); goto free_tx_stats;
}
}
if (ab->hw_params.vdev_start_delay &&
arvif->is_started &&
arvif->vdev_type != WMI_VDEV_TYPE_AP) {
ret = ath11k_mac_stop_vdev_early(ar->hw, vif); if (ret) {
ath11k_warn(ab, "failed to do early vdev stop: %d\n", ret); return ret;
}
}
/* cancel must be done outside the mutex to avoid deadlock */ if ((old_state == IEEE80211_STA_NONE &&
new_state == IEEE80211_STA_NOTEXIST)) {
cancel_work_sync(&arsta->update_wk);
cancel_work_sync(&arsta->set_4addr_wk);
}
if (power_type == IEEE80211_REG_UNSET_AP) {
ath11k_warn(ar->ab, "invalid power type %d\n",
power_type);
ret = -EINVAL;
} else {
ret = ath11k_reg_handle_chan_list(ar->ab,
reg_info,
power_type); if (ret)
ath11k_warn(ar->ab, "failed to handle chan list with power type %d\n",
power_type);
}
}
} elseif (old_state == IEEE80211_STA_AUTHORIZED &&
new_state == IEEE80211_STA_ASSOC) {
spin_lock_bh(&ar->ab->base_lock);
peer = ath11k_peer_find(ar->ab, arvif->vdev_id, sta->addr); if (peer)
peer->is_authorized = false;
memcpy(addresses[0].addr, ar->mac_addr, ETH_ALEN); for (i = 1; i < n_addresses; i++) {
memcpy(addresses[i].addr, ar->mac_addr, ETH_ALEN); /* set Local Administered Address bit */
addresses[i].addr[0] |= 0x2;
/* TODO: Check if HT capability advertised from firmware is different * for each band for a dual band capable radio. It will be tricky to * handle it when the ht capability different for each band.
*/ if (ht_cap & WMI_HT_CAP_DYNAMIC_SMPS ||
(ar->supports_6ghz && ab->hw_params.supports_dynamic_smps_6ghz))
ar->hw->wiphy->features |= NL80211_FEATURE_DYNAMIC_SMPS;
ret = ath11k_wow_init(ar); if (ret) {
ath11k_warn(ar->ab, "failed to init wow: %d\n", ret); goto err_free_if_combs;
}
if (test_bit(WMI_TLV_SERVICE_TX_DATA_MGMT_ACK_RSSI,
ar->ab->wmi_ab.svc_map))
wiphy_ext_feature_set(ar->hw->wiphy,
NL80211_EXT_FEATURE_ACK_SIGNAL_SUPPORT);
if (test_bit(WMI_TLV_SERVICE_BIOS_SAR_SUPPORT, ar->ab->wmi_ab.svc_map) &&
ab->hw_params.bios_sar_capa)
ar->hw->wiphy->sar_capa = ab->hw_params.bios_sar_capa;
ret = ieee80211_register_hw(ar->hw); if (ret) {
ath11k_err(ar->ab, "ieee80211 registration failed: %d\n", ret); goto err_free_if_combs;
}
if (!ab->hw_params.supports_monitor) /* There's a race between calling ieee80211_register_hw() * and here where the monitor mode is enabled for a little * while. But that time is so short and in practise it make * a difference in real life.
*/
ar->hw->wiphy->interface_modes &= ~BIT(NL80211_IFTYPE_MONITOR);
/* Apply the regd received during initialization */
ret = ath11k_regd_update(ar); if (ret) {
ath11k_err(ar->ab, "ath11k regd update failed: %d\n", ret); goto err_unregister_hw;
}
if (ab->hw_params.current_cc_support && ab->new_alpha2[0]) {
memcpy(&ar->alpha2, ab->new_alpha2, 2);
ret = ath11k_reg_set_cc(ar); if (ret)
ath11k_warn(ar->ab, "failed set cc code for mac register: %d\n", ret);
}
ret = ath11k_debugfs_register(ar); if (ret) {
ath11k_err(ar->ab, "debugfs registration failed: %d\n", ret); goto err_unregister_hw;
}
ret = ath11k_wmi_sta_keepalive(ar, &arg); if (ret) {
ath11k_warn(ar->ab, "failed to set keepalive on vdev %i: %d\n",
arvif->vdev_id, ret); return ret;
}
return 0;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.260 Sekunden
(vorverarbeitet am 2026-04-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.