mt7925_set_key() installs a pairwise key only on the links in msta->valid_links at the time of the call. mac80211 does not install it again when a link is added to the station later, because ieee80211_key_switch_links() only moves keys with a link ID. A link that mt7925_change_sta_links() adds after the key is installed thus has no key in its WTBL entry. Reachable via _ieee80211_set_active_links(), for example when the AP removes all active links of the client with ML reconfiguration and ieee80211_ml_reconf_work() activates another link. Install the pairwise keys of the station on the links that mt7925_change_sta_links() adds, like mt7996_mac_sta_links_set_keys() does. Stop at the first key that fails and log it: a timed out MCU command already schedules a chip reset, and each further command can wait for its own timeout under the wiphy lock. Keep the links and return success, since ieee80211_sta_set_link_valid() drops a link on an error without telling the driver. Fixes: 43aa4033eb18 ("wifi: mt76: mt7925: add mt7925_change_sta_links") Signed-off-by: Felix Fietkau --- .../net/wireless/mediatek/mt76/mt7925/main.c | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 975c564236f9..b88d92f9aaf2 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -2597,6 +2597,51 @@ mt7925_change_vif_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, return err; } +struct mt7925_key_iter_data { + struct ieee80211_sta *sta; + struct mt792x_link_sta *mlink; + unsigned int link_id; + int err; +}; + +static void +mt7925_sta_key_iter(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, struct ieee80211_key_conf *key, + void *data) +{ + struct mt7925_key_iter_data *it = data; + + if (it->err || sta != it->sta || key->link_id >= 0) + return; + + it->err = mt7925_set_link_key(hw, SET_KEY, vif, sta, key, it->link_id, + it->mlink); +} + +static void +mt7925_mac_sta_links_set_keys(struct ieee80211_hw *hw, + struct ieee80211_vif *vif, + struct ieee80211_sta *sta, unsigned long links) +{ + struct mt792x_sta *msta = (struct mt792x_sta *)sta->drv_priv; + struct mt7925_key_iter_data it = { + .sta = sta, + }; + unsigned int link_id; + + for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) { + it.link_id = link_id; + it.mlink = mt792x_sta_to_link(msta, link_id); + ieee80211_iter_keys(hw, vif, mt7925_sta_key_iter, &it); + if (it.err) { + dev_err(mt792x_hw_dev(hw)->mt76.dev, + "failed to set station keys on link %u: %d\n", + link_id, it.err); + return; + } + } +} + static int mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, struct ieee80211_sta *sta, u16 old_links, u16 new_links) @@ -2619,6 +2664,8 @@ mt7925_change_sta_links(struct ieee80211_hw *hw, struct ieee80211_vif *vif, if (err < 0) goto out; + mt7925_mac_sta_links_set_keys(hw, vif, sta, add); + out: mt792x_mutex_release(dev); -- 2.47.3