mt76_connac_mcu_sta_tlv() copies the HT, VHT and HE capabilities of the peer into the STA_REC TLVs unchanged. On mt7615, mt7663 and mt7921, both callers of mt76_connac_mcu_wtbl_ht_tlv() enable WTBL LDPC for any LDPC peer. mac80211 keeps the AP's own setting in ht_ldpc, vht_ldpc and he_ldpc of the link conf alone. An AP configured without LDPC can thus send LDPC frames to an LDPC peer. On an AP, clear each LDPC bit of these TLVs where the link conf has no LDPC for that mode. Clear the WTBL LDPC fields under that condition, like mt7915 does for the WTBL and mt7996 for its STA_REC TLVs. Other interface types keep the peer's bits, since mac80211 sets these link conf fields for an AP alone. Fixes: 04b8e65922f6 ("mt76: add mac80211 driver for MT7615 PCIe-based chipsets") Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7615/mcu.c | 4 ++- .../wireless/mediatek/mt76/mt76_connac_mcu.c | 31 ++++++++++++++----- .../wireless/mediatek/mt76/mt76_connac_mcu.h | 21 ++++++++++++- .../net/wireless/mediatek/mt76/mt7925/mcu.c | 2 +- 4 files changed, 47 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c index e31fb63a5562..c5e2eb5231e3 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7615/mcu.c @@ -898,7 +898,9 @@ mt7615_mcu_wtbl_sta_add(struct mt7615_phy *phy, struct ieee80211_vif *vif, NULL, wtbl_hdr); if (sta) mt76_connac_mcu_wtbl_ht_tlv(&dev->mt76, wskb, sta, - NULL, wtbl_hdr, true, true); + NULL, wtbl_hdr, + mt76_connac_mcu_ht_ldpc(&vif->bss_conf), + mt76_connac_mcu_vht_ldpc(&vif->bss_conf)); mt76_connac_mcu_wtbl_hdr_trans_tlv(wskb, vif, &msta->wcid, NULL, wtbl_hdr); } diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c index 3241e1ce2ef7..56b4a0940bb1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.c @@ -689,7 +689,8 @@ mt76_connac_mcu_sta_amsdu_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, #define HE_PHY(p, c) u8_get_bits(c, IEEE80211_HE_PHY_##p) #define HE_MAC(m, c) u8_get_bits(c, IEEE80211_HE_MAC_##m) static void -mt76_connac_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) +mt76_connac_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, + bool ldpc) { struct ieee80211_sta_he_cap *he_cap = &sta->deflink.he_cap; struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem; @@ -721,7 +722,7 @@ mt76_connac_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) IEEE80211_HE_PHY_CAP0_CHANNEL_WIDTH_SET_RU_MAPPING_IN_5G)) cap |= STA_REC_HE_CAP_BW20_RU242_SUPPORT; - if (elem->phy_cap_info[1] & + if (ldpc && elem->phy_cap_info[1] & IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD) cap |= STA_REC_HE_CAP_LDPC; @@ -823,7 +824,7 @@ mt76_connac_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_sta *sta) void mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, - struct ieee80211_link_sta *link_sta) + struct ieee80211_link_sta *link_sta, bool ldpc) { struct ieee80211_sta_he_cap *he_cap = &link_sta->he_cap; struct ieee80211_he_cap_elem *elem = &he_cap->he_cap_elem; @@ -836,6 +837,9 @@ mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, memcpy(he->he_phy_cap, elem->phy_cap_info, sizeof(he->he_phy_cap)); memcpy(he->he_mac_cap, elem->mac_cap_info, sizeof(he->he_mac_cap)); + if (!ldpc) + he->he_phy_cap[1] &= ~IEEE80211_HE_PHY_CAP1_LDPC_CODING_IN_PAYLOAD; + switch (link_sta->bandwidth) { case IEEE80211_STA_RX_BW_160: if (elem->phy_cap_info[0] & @@ -931,22 +935,30 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, /* starec ht */ if (sta->deflink.ht_cap.ht_supported) { + u16 cap = sta->deflink.ht_cap.cap; struct sta_rec_ht *ht; + if (!mt76_connac_mcu_ht_ldpc(&vif->bss_conf)) + cap &= ~IEEE80211_HT_CAP_LDPC_CODING; + tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_HT, sizeof(*ht)); ht = (struct sta_rec_ht *)tlv; - ht->ht_cap = cpu_to_le16(sta->deflink.ht_cap.cap); + ht->ht_cap = cpu_to_le16(cap); } /* starec vht */ if (sta->deflink.vht_cap.vht_supported) { + u32 cap = sta->deflink.vht_cap.cap; struct sta_rec_vht *vht; int len; + if (!mt76_connac_mcu_vht_ldpc(&vif->bss_conf)) + cap &= ~IEEE80211_VHT_CAP_RXLDPC; + len = is_connac2(dev) ? sizeof(*vht) : sizeof(*vht) - 4; tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_VHT, len); vht = (struct sta_rec_vht *)tlv; - vht->vht_cap = cpu_to_le32(sta->deflink.vht_cap.cap); + vht->vht_cap = cpu_to_le32(cap); vht->vht_rx_mcs_map = sta->deflink.vht_cap.vht_mcs.rx_mcs_map; vht->vht_tx_mcs_map = sta->deflink.vht_cap.vht_mcs.tx_mcs_map; } @@ -962,8 +974,10 @@ void mt76_connac_mcu_sta_tlv(struct mt76_phy *mphy, struct sk_buff *skb, /* starec he */ if (sta->deflink.he_cap.has_he) { - mt76_connac_mcu_sta_he_tlv(skb, sta); - mt76_connac_mcu_sta_he_tlv_v2(skb, &sta->deflink); + bool ldpc = mt76_connac_mcu_he_ldpc(&vif->bss_conf); + + mt76_connac_mcu_sta_he_tlv(skb, sta, ldpc); + mt76_connac_mcu_sta_he_tlv_v2(skb, &sta->deflink, ldpc); if (band == NL80211_BAND_6GHZ && sta_state == MT76_STA_INFO_STATE_ASSOC) { struct sta_rec_he_6g_capa *he_6g_capa; @@ -1155,7 +1169,8 @@ int mt76_connac_mcu_sta_cmd(struct mt76_phy *phy, if (info->sta) mt76_connac_mcu_wtbl_ht_tlv(dev, skb, info->sta, sta_wtbl, wtbl_hdr, - true, true); + mt76_connac_mcu_ht_ldpc(info->link_conf), + mt76_connac_mcu_vht_ldpc(info->link_conf)); } return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true); diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h index a4d08b1f4ea3..bd0ae510202f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h +++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h @@ -2075,6 +2075,24 @@ mt76_connac_mcu_add_tlv(struct sk_buff *skb, int tag, int len) return mt76_connac_mcu_add_nested_tlv(skb, tag, len, skb->data, NULL); } +static inline bool +mt76_connac_mcu_ht_ldpc(struct ieee80211_bss_conf *link_conf) +{ + return link_conf->vif->type != NL80211_IFTYPE_AP || link_conf->ht_ldpc; +} + +static inline bool +mt76_connac_mcu_vht_ldpc(struct ieee80211_bss_conf *link_conf) +{ + return link_conf->vif->type != NL80211_IFTYPE_AP || link_conf->vht_ldpc; +} + +static inline bool +mt76_connac_mcu_he_ldpc(struct ieee80211_bss_conf *link_conf) +{ + return link_conf->vif->type != NL80211_IFTYPE_AP || link_conf->he_ldpc; +} + int mt76_connac_mcu_set_channel_domain(struct mt76_phy *phy); int mt76_connac_mcu_set_vif_ps(struct mt76_dev *dev, struct ieee80211_vif *vif); void mt76_connac_mcu_sta_basic_tlv(struct mt76_dev *dev, struct sk_buff *skb, @@ -2093,7 +2111,8 @@ int mt76_connac_mcu_sta_update_hdr_trans(struct mt76_dev *dev, struct ieee80211_vif *vif, struct mt76_wcid *wcid, int cmd); void mt76_connac_mcu_sta_he_tlv_v2(struct sk_buff *skb, - struct ieee80211_link_sta *link_sta); + struct ieee80211_link_sta *link_sta, + bool ldpc); u8 mt76_connac_get_phy_mode_v2(struct mt76_phy *mphy, struct ieee80211_vif *vif, enum nl80211_band band, struct ieee80211_link_sta *link_sta); diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c index 9a2d428a814a..a1c0633b9a4f 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/mcu.c @@ -1926,7 +1926,7 @@ mt7925_mcu_sta_he_tlv(struct sk_buff *skb, struct ieee80211_link_sta *link_sta) if (!link_sta->he_cap.has_he) return; - mt76_connac_mcu_sta_he_tlv_v2(skb, link_sta); + mt76_connac_mcu_sta_he_tlv_v2(skb, link_sta, true); } static void -- 2.47.3