wifi: mt76: mt7925: update mt7925_mcu_sta_update for MLO
authorSean Wang <sean.wang@mediatek.com>
Sat, 6 Jul 2024 08:28:09 +0000 (01:28 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:02:08 +0000 (23:02 +0200)
update mt7925_mcu_sta_update for the MLO-enabled firmware.

Co-developed-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Signed-off-by: Ming Yen Hsieh <mingyen.hsieh@mediatek.com>
Co-developed-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Deren Wu <deren.wu@mediatek.com>
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
Link: https://patch.msgid.link/2e25bfc2d8aa503ecd1ba8099c6e54dce0c27b99.1720248331.git.sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76_connac_mcu.h
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.h

index e636b033b87eb8e413dd7a6cb53010a352a0673d..9329c959674f60433731d59d52b0fcdd47fac284 100644 (file)
@@ -545,6 +545,13 @@ struct sta_rec_muru {
        } mimo_ul;
 } __packed;
 
+struct sta_rec_remove {
+       __le16 tag;
+       __le16 len;
+       u8 action;
+       u8 pad[3];
+} __packed;
+
 struct sta_phy {
        u8 type;
        u8 flag;
@@ -814,6 +821,8 @@ enum {
        STA_REC_HE_V2 = 0x19,
        STA_REC_MLD = 0x20,
        STA_REC_EHT = 0x22,
+       STA_REC_MLD_OFF = 0x23,
+       STA_REC_REMOVE = 0x25,
        STA_REC_PN_INFO = 0x26,
        STA_REC_KEY_V3 = 0x27,
        STA_REC_HDRT = 0x28,
index 094fa4dde5fe1b0fdb9a5cfe134ed156dbc5931d..159d253ba5b866e3a842581a024e5bc48784c579 100644 (file)
@@ -1812,6 +1812,66 @@ mt7925_mcu_sta_cmd(struct mt76_phy *phy,
        return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
 }
 
+static void
+mt7925_mcu_sta_remove_tlv(struct sk_buff *skb)
+{
+       struct sta_rec_remove *rem;
+       struct tlv *tlv;
+
+       tlv = mt76_connac_mcu_add_tlv(skb, 0x25, sizeof(*rem));
+       rem = (struct sta_rec_remove *)tlv;
+       rem->action = 0;
+}
+
+static int
+mt7925_mcu_mlo_sta_cmd(struct mt76_phy *phy,
+                      struct mt76_sta_cmd_info *info)
+{
+       struct mt792x_vif *mvif = (struct mt792x_vif *)info->vif->drv_priv;
+       struct mt76_dev *dev = phy->dev;
+       struct mt792x_bss_conf *mconf;
+       struct sk_buff *skb;
+
+       mconf = mt792x_vif_to_link(mvif, info->wcid->link_id);
+
+       skb = __mt76_connac_mcu_alloc_sta_req(dev, &mconf->mt76, info->wcid,
+                                             MT7925_STA_UPDATE_MAX_SIZE);
+       if (IS_ERR(skb))
+               return PTR_ERR(skb);
+
+       if (info->enable)
+               mt76_connac_mcu_sta_basic_tlv(dev, skb, info->vif,
+                                             info->link_sta,
+                                             info->enable, info->newly);
+
+       if (info->enable && info->link_sta) {
+               mt7925_mcu_sta_phy_tlv(skb, info->vif, info->link_sta);
+               mt7925_mcu_sta_ht_tlv(skb, info->link_sta);
+               mt7925_mcu_sta_vht_tlv(skb, info->link_sta);
+               mt76_connac_mcu_sta_uapsd(skb, info->vif, info->link_sta->sta);
+               mt7925_mcu_sta_amsdu_tlv(skb, info->vif, info->link_sta);
+               mt7925_mcu_sta_he_tlv(skb, info->link_sta);
+               mt7925_mcu_sta_he_6g_tlv(skb, info->link_sta);
+               mt7925_mcu_sta_eht_tlv(skb, info->link_sta);
+               mt7925_mcu_sta_rate_ctrl_tlv(skb, info->vif,
+                                            info->link_sta);
+               mt7925_mcu_sta_state_v2_tlv(phy, skb, info->link_sta,
+                                           info->vif, info->rcpi,
+                                           info->state);
+               if (info->state != MT76_STA_INFO_STATE_NONE)
+                       mt7925_mcu_sta_mld_tlv(skb, info->vif, info->link_sta->sta);
+               mt7925_mcu_sta_hdr_trans_tlv(skb, info->vif, info->link_sta);
+       }
+
+       if (!info->enable) {
+               mt7925_mcu_sta_remove_tlv(skb);
+               mt76_connac_mcu_add_tlv(skb, STA_REC_MLD_OFF,
+                                       sizeof(struct tlv));
+       }
+
+       return mt76_mcu_skb_send_msg(dev, skb, info->cmd, true);
+}
+
 int mt7925_mcu_sta_update(struct mt792x_dev *dev,
                          struct ieee80211_link_sta *link_sta,
                          struct ieee80211_vif *vif, bool enable,
@@ -1830,6 +1890,7 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev,
        };
        struct mt792x_sta *msta;
        struct mt792x_link_sta *mlink;
+       int err;
 
        if (link_sta) {
                msta = (struct mt792x_sta *)link_sta->sta->drv_priv;
@@ -1838,7 +1899,12 @@ int mt7925_mcu_sta_update(struct mt792x_dev *dev,
        info.wcid = link_sta ? &mlink->wcid : &mvif->sta.deflink.wcid;
        info.newly = link_sta ? state != MT76_STA_INFO_STATE_ASSOC : true;
 
-       return mt7925_mcu_sta_cmd(&dev->mphy, &info);
+       if (ieee80211_vif_is_mld(vif))
+               err = mt7925_mcu_mlo_sta_cmd(&dev->mphy, &info);
+       else
+               err = mt7925_mcu_sta_cmd(&dev->mphy, &info);
+
+       return err;
 }
 
 int mt7925_mcu_set_beacon_filter(struct mt792x_dev *dev,
index 7b0c6937f91820773e92b3b96b29370f7d23f4aa..a97e5b539ab91215d449d6360b099ff0abb397c3 100644 (file)
@@ -492,7 +492,8 @@ struct bss_rlm_tlv {
                                         sizeof(struct sta_rec_eht) +           \
                                         sizeof(struct sta_rec_hdr_trans) +     \
                                         sizeof(struct sta_rec_mld) +           \
-                                        sizeof(struct tlv))
+                                        sizeof(struct tlv) * 2 +               \
+                                        sizeof(struct sta_rec_remove))
 
 #define MT7925_BSS_UPDATE_MAX_SIZE     (sizeof(struct bss_req_hdr) +           \
                                         sizeof(struct mt76_connac_bss_basic_tlv) +     \