wifi: mt76: mt7996: enable BSS_CHANGED_MCAST_RATE support
authorRyder Lee <ryder.lee@mediatek.com>
Thu, 13 Apr 2023 20:23:32 +0000 (04:23 +0800)
committerFelix Fietkau <nbd@nbd.name>
Wed, 19 Apr 2023 08:09:43 +0000 (10:09 +0200)
Similar to BSS_CHANGED_BASIC_RATES, this enables mcast rate
configuration through fixed rate tables.

Signed-off-by: Ryder Lee <ryder.lee@mediatek.com>
Change-Id: Ifc305e8c7de9a7df4ad5f856e2097d721a886aaa
Signed-off-by: Felix Fietkau <nbd@nbd.name>
drivers/net/wireless/mediatek/mt76/mt7996/mac.c
drivers/net/wireless/mediatek/mt76/mt7996/main.c
drivers/net/wireless/mediatek/mt76/mt7996/mcu.c
drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h

index c8ada30..fbb92c3 100644 (file)
@@ -1070,8 +1070,14 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
                mt7996_mac_write_txwi_80211(dev, txwi, skb, key);
 
        if (txwi[1] & cpu_to_le32(MT_TXD1_FIXED_RATE)) {
+               struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data;
+               bool mcast = ieee80211_is_data(hdr->frame_control) &&
+                            is_multicast_ether_addr(hdr->addr1);
                u8 idx = mvif->basic_rates_idx;
 
+               if (mcast && mvif->mcast_rates_idx)
+                       idx = mvif->mcast_rates_idx;
+
                txwi[6] |= FIELD_PREP(MT_TXD6_TX_RATE, idx);
                txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
        }
index 1243e5f..f861fbb 100644 (file)
@@ -503,14 +503,15 @@ mt7996_update_bss_color(struct ieee80211_hw *hw,
 }
 
 static u8
-mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
+mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
+                      bool mcast)
 {
        struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
        struct mt76_phy *mphy = hw->priv;
        u16 rate;
        u8 i, idx;
 
-       rate = mt76_connac2_mac_tx_rate_val(mphy, vif, false, false);
+       rate = mt76_connac2_mac_tx_rate_val(mphy, vif, false, mcast);
 
        idx = FIELD_GET(MT_TX_RATE_IDX, rate);
        for (i = 0; i < ARRAY_SIZE(mt76_rates); i++)
@@ -557,8 +558,13 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
                }
        }
 
+       if (changed & BSS_CHANGED_MCAST_RATE)
+               mvif->mcast_rates_idx =
+                       mt7996_get_rates_table(hw, vif, true);
+
        if (changed & BSS_CHANGED_BASIC_RATES)
-               mvif->basic_rates_idx = mt7996_get_rates_table(hw, vif);
+               mvif->basic_rates_idx =
+                       mt7996_get_rates_table(hw, vif, false);
 
        if (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon) {
                mt7996_mcu_add_bss_info(phy, vif, true);
index 3db74ae..f96992b 100644 (file)
@@ -605,7 +605,8 @@ mt7996_mcu_bss_bmc_tlv(struct sk_buff *skb, struct ieee80211_vif *vif,
        struct cfg80211_chan_def *chandef = &phy->mt76->chandef;
        enum nl80211_band band = chandef->chan->band;
        struct tlv *tlv;
-       u8 idx = mvif->basic_rates_idx;
+       u8 idx = mvif->mcast_rates_idx ?
+                mvif->mcast_rates_idx : mvif->basic_rates_idx;
 
        tlv = mt7996_mcu_add_uni_tlv(skb, UNI_BSS_INFO_RATE, sizeof(*bmc));
 
index 5cf5ea8..a1a6ee0 100644 (file)
@@ -125,6 +125,7 @@ struct mt7996_vif {
        struct cfg80211_bitrate_mask bitrate_mask;
 
        u8 basic_rates_idx;
+       u8 mcast_rates_idx;
 };
 
 /* per-phy stats.  */