wifi: mt76: mt7615: enable BSS_CHANGED_MU_GROUPS support
authorRyder Lee <ryder.lee@mediatek.com>
Tue, 2 May 2023 03:10:06 +0000 (11:10 +0800)
committerFelix Fietkau <nbd@nbd.name>
Tue, 25 Jul 2023 19:59:40 +0000 (21:59 +0200)
The Group ID Management frame is an Action frame of category VHT.
It is transmitted by the AP to assign or change the user position
of a STA for one or more group IDs.

Also, sniffer can use a given group id to monitor STA that belongs
to that group.

Notify underlying driver of changes via BSS_CHANGED_MU_GROUPS.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7615/init.c
drivers/net/wireless/mediatek/mt76/mt7615/main.c
drivers/net/wireless/mediatek/mt76/mt7615/regs.h

index 621e69f..ab475c8 100644 (file)
@@ -397,6 +397,8 @@ mt7615_init_wiphy(struct ieee80211_hw *hw)
        wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_SET_SCAN_DWELL);
        wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_VHT_IBSS);
        wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_CAN_REPLACE_PTK0);
+       if (!is_mt7622(&phy->dev->mt76))
+               wiphy_ext_feature_set(wiphy, NL80211_EXT_FEATURE_MU_MIMO_AIR_SNIFFER);
 
        ieee80211_hw_set(hw, SINGLE_SCAN_ON_ALL_BANDS);
        ieee80211_hw_set(hw, TX_STATUS_NO_AMPDU_LEN);
index dadb13f..4167aaf 100644 (file)
@@ -552,6 +552,32 @@ static void mt7615_configure_filter(struct ieee80211_hw *hw,
        mt7615_mutex_release(dev);
 }
 
+static void
+mt7615_update_mu_group(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                      struct ieee80211_bss_conf *info)
+{
+       struct mt7615_vif *mvif = (struct mt7615_vif *)vif->drv_priv;
+       struct mt7615_dev *dev = mt7615_hw_dev(hw);
+       u8 i, band = mvif->mt76.band_idx;
+       u32 *mu;
+
+       mu = (u32 *)info->mu_group.membership;
+       for (i = 0; i < WLAN_MEMBERSHIP_LEN / sizeof(*mu); i++) {
+               if (is_mt7663(&dev->mt76))
+                       mt76_wr(dev, MT7663_WF_PHY_GID_TAB_VLD(band, i), mu[i]);
+               else
+                       mt76_wr(dev, MT_WF_PHY_GID_TAB_VLD(band, i), mu[i]);
+       }
+
+       mu = (u32 *)info->mu_group.position;
+       for (i = 0; i < WLAN_USER_POSITION_LEN / sizeof(*mu); i++) {
+               if (is_mt7663(&dev->mt76))
+                       mt76_wr(dev, MT7663_WF_PHY_GID_TAB_POS(band, i), mu[i]);
+               else
+                       mt76_wr(dev, MT_WF_PHY_GID_TAB_POS(band, i), mu[i]);
+       }
+}
+
 static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
                                    struct ieee80211_vif *vif,
                                    struct ieee80211_bss_conf *info,
@@ -600,6 +626,9 @@ static void mt7615_bss_info_changed(struct ieee80211_hw *hw,
        if (changed & BSS_CHANGED_ASSOC)
                mt7615_mac_set_beacon_filter(phy, vif, vif->cfg.assoc);
 
+       if (changed & BSS_CHANGED_MU_GROUPS)
+                mt7615_update_mu_group(hw, vif, info);
+
        mt7615_mutex_release(dev);
 }
 
index 7cecb22..806b388 100644 (file)
@@ -212,6 +212,15 @@ enum mt7615_reg_base {
 
 #define MT7663_WF_PHY_R0_PHYCTRL_STS5(_phy)    MT_WF_PHY(0x0224 + ((_phy) << 12))
 
+#define MT_WF_PHY_GID_TAB_VLD(_phy, i)         MT_WF_PHY(0x0254 + (i) * 4 + \
+                                                         ((_phy) << 9))
+#define MT7663_WF_PHY_GID_TAB_VLD(_phy, i)     MT_WF_PHY(0x0254 + (i) * 4 + \
+                                                         ((_phy) << 12))
+#define MT_WF_PHY_GID_TAB_POS(_phy, i)         MT_WF_PHY(0x025c + (i) * 4 + \
+                                                         ((_phy) << 9))
+#define MT7663_WF_PHY_GID_TAB_POS(_phy, i)     MT_WF_PHY(0x025c + (i) * 4 + \
+                                                         ((_phy) << 12))
+
 #define MT_WF_PHY_MIN_PRI_PWR(_phy)    MT_WF_PHY((_phy) ? 0x084 : 0x229c)
 #define MT_WF_PHY_PD_OFDM_MASK(_phy)   ((_phy) ? GENMASK(24, 16) : \
                                         GENMASK(28, 20))