Add a key iterator that (re)installs the existing keys on a given set of MLO links, used when later links are brought up after the first key was already programmed on the primary link. This is a preparation patch before the MT7925 MLO hybrid/EMLSR work. Signed-off-by: Emery Hsin --- .../net/wireless/mediatek/mt76/mt7925/main.c | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/net/wireless/mediatek/mt76/mt7925/main.c b/drivers/net/wireless/mediatek/mt76/mt7925/main.c index 0bff5863e01e..45d656cfee21 100644 --- a/drivers/net/wireless/mediatek/mt76/mt7925/main.c +++ b/drivers/net/wireless/mediatek/mt76/mt7925/main.c @@ -1377,6 +1377,35 @@ mt7925_mac_set_links(struct mt76_dev *mdev, struct ieee80211_vif *vif) ieee80211_set_active_links_async(vif, sel_links); } +struct mt7925_set_links_key_iter { + unsigned long links; +}; + +/* Install the existing keys on the given links. */ +static void +mt7925_set_links_key_iter(struct ieee80211_hw *hw, struct ieee80211_vif *vif, + struct ieee80211_sta *sta, + struct ieee80211_key_conf *key, void *data) +{ + struct mt792x_vif *mvif = (struct mt792x_vif *)vif->drv_priv; + struct mt792x_sta *msta = sta ? (struct mt792x_sta *)sta->drv_priv : + &mvif->sta; + struct mt7925_set_links_key_iter *it = data; + unsigned long links = key->link_id != -1 ? BIT(key->link_id) : it->links; + unsigned int link_id; + + links &= it->links; + + for_each_set_bit(link_id, &links, IEEE80211_MLD_MAX_NUM_LINKS) { + struct mt792x_link_sta *mlink = mt792x_sta_to_link(msta, link_id); + + if (!mlink) + continue; + + mt7925_set_link_key(hw, SET_KEY, vif, sta, key, link_id, mlink); + } +} + static void mt7925_mac_link_sta_assoc(struct mt76_dev *mdev, struct ieee80211_vif *vif, struct ieee80211_link_sta *link_sta) -- 2.45.2