]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: mt76: mt7925: set mt7925_mcu_sta_key_tlv according to link id
authorSean Wang <sean.wang@mediatek.com>
Sat, 6 Jul 2024 08:27:44 +0000 (01:27 -0700)
committerFelix Fietkau <nbd@nbd.name>
Tue, 9 Jul 2024 21:02:01 +0000 (23:02 +0200)
configure mt7925_mcu_sta_key_tlv according to link id

We created a link id field in the common structure mt76_wcid so that
mt7925_mcu_sta_key_tlv can access per-link STA/BSS. Additionally,
.link_id will be required when reporting the link information of Rx status
to mac80211. We will submit the changes for reporting the Rx status in
a separate patch.

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/16d65aae010113f9be3c4e6e759b4226d396a1be.1720248331.git.sean.wang@kernel.org
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt76.h
drivers/net/wireless/mediatek/mt76/mt7925/main.c
drivers/net/wireless/mediatek/mt76/mt7925/mcu.c
drivers/net/wireless/mediatek/mt76/mt792x.h

index 15f83b5adac7007ec8a3b3d65ddf0cbf0a1ba368..daf1e43e304eeebc78c89ba9c4f76a4b28708929 100644 (file)
@@ -349,6 +349,7 @@ struct mt76_wcid {
        u8 sta:1;
        u8 amsdu:1;
        u8 phy_idx:2;
+       u8 link_id:4;
 
        u8 rx_check_pn;
        u8 rx_key_pn[IEEE80211_NUM_TIDS + 1][6];
index da70c203d618e765858684c5eefaa14738d6c1a1..59b1e920bb4a770784cf129dab881952027245fc 100644 (file)
@@ -748,6 +748,7 @@ static int mt7925_mac_link_sta_add(struct mt76_dev *mdev,
        mlink->wcid.phy_idx = mconf->mt76.band_idx;
        mlink->wcid.tx_info |= MT_WCID_TX_INFO_SET;
        mlink->last_txs = jiffies;
+       mlink->wcid.link_id = link_sta->link_id;
 
        ret = mt76_connac_pm_wake(&dev->mphy, &dev->pm);
        if (ret)
index a67d8dd6075f41287d7d8ab567d39bd097e2253c..ba91c8e37dff6ae5bb1ea3f139d64d8ff5516cef 100644 (file)
@@ -967,6 +967,7 @@ mt7925_mcu_sta_key_tlv(struct mt76_wcid *wcid,
        struct mt792x_sta *msta = container_of(mlink, struct mt792x_sta, deflink);
        struct sta_rec_sec_uni *sec;
        struct mt792x_vif *mvif = msta->vif;
+       struct mt792x_bss_conf *mconf = mt792x_vif_to_link(mvif, wcid->link_id);
        struct ieee80211_sta *sta;
        struct ieee80211_vif *vif;
        struct tlv *tlv;
@@ -978,17 +979,23 @@ mt7925_mcu_sta_key_tlv(struct mt76_wcid *wcid,
 
        tlv = mt76_connac_mcu_add_tlv(skb, STA_REC_KEY_V3, sizeof(*sec));
        sec = (struct sta_rec_sec_uni *)tlv;
-       sec->bss_idx = mvif->bss_conf.mt76.idx;
+       sec->bss_idx = mconf->mt76.idx;
        sec->is_authenticator = 0;
-       sec->mgmt_prot = 0;
+       sec->mgmt_prot = 1; /* only used in MLO mode */
        sec->wlan_idx = (u8)wcid->idx;
 
        if (sta) {
+               struct ieee80211_link_sta *link_sta;
+
                sec->tx_key = 1;
                sec->key_type = 1;
-               memcpy(sec->peer_addr, sta->addr, ETH_ALEN);
+               link_sta = mt792x_sta_to_link_sta(vif, sta, wcid->link_id);
+               memcpy(sec->peer_addr, link_sta->addr, ETH_ALEN);
        } else {
-               memcpy(sec->peer_addr, vif->bss_conf.bssid, ETH_ALEN);
+               struct ieee80211_bss_conf *link_conf;
+
+               link_conf = mt792x_vif_to_bss_conf(vif, wcid->link_id);
+               memcpy(sec->peer_addr, link_conf->bssid, ETH_ALEN);
        }
 
        if (cmd == SET_KEY) {
index 69eb8dac0b70655cf3a5be391ca8c31ec54904e1..fe5a6c93270591c3d563c41409a44b0c0e0ff923 100644 (file)
@@ -273,6 +273,17 @@ mt792x_vif_to_bss_conf(struct ieee80211_vif *vif, unsigned int link_id)
        return link_conf_dereference_protected(vif, link_id);
 }
 
+static inline struct ieee80211_link_sta *
+mt792x_sta_to_link_sta(struct ieee80211_vif *vif, struct ieee80211_sta *sta,
+                      unsigned int link_id)
+{
+       if (!ieee80211_vif_is_mld(vif) ||
+           link_id >= IEEE80211_LINK_UNSPECIFIED)
+               return &sta->deflink;
+
+       return link_sta_dereference_protected(sta, link_id);
+}
+
 static inline struct mt792x_dev *
 mt792x_hw_dev(struct ieee80211_hw *hw)
 {