The user is allowed to change beacon tx rate (HT/VHT/HE) from hostapd.
Signed-off-by: Ryder Lee <[email protected]>
---
.../net/wireless/mediatek/mt76/mt7996/mac.c | 2 ++
.../net/wireless/mediatek/mt76/mt7996/main.c | 26 ++++++++++++++-----
.../wireless/mediatek/mt76/mt7996/mt7996.h | 2 ++
3 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
index 36e50b12e5eb..dfd4793f5a26 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mac.c
@@ -1082,6 +1082,8 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
if (mcast && mvif->mcast_rates_idx)
idx = mvif->mcast_rates_idx;
+ else if (beacon && mvif->beacon_rates_idx)
+ idx = mvif->beacon_rates_idx;
txwi[6] |= FIELD_PREP(MT_TXD6_TX_RATE, idx);
txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/main.c b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
index 231905fb7ea1..d86e43a84497 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/main.c
@@ -513,14 +513,24 @@ mt7996_update_bss_color(struct ieee80211_hw *hw,
static u8
mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
- bool mcast)
+ bool beacon, bool mcast)
{
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
struct mt76_phy *mphy = hw->priv;
u16 rate;
- u8 i, idx;
+ u8 i, idx, ht;
- rate = mt76_connac2_mac_tx_rate_val(mphy, vif, false, mcast);
+ rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast);
+ ht = FIELD_GET(MT_TX_RATE_MODE, rate) > MT_PHY_TYPE_OFDM;
+
+ if (beacon && ht) {
+ struct mt7996_dev *dev = mt7996_hw_dev(hw);
+
+ /* must odd index */
+ idx = MT7996_BEACON_RATES_TBL + 2 * (mvif->mt76.idx % 20);
+ mt7996_mac_set_fixed_rate_table(dev, idx, rate);
+ return idx;
+ }
idx = FIELD_GET(MT_TX_RATE_IDX, rate);
for (i = 0; i < ARRAY_SIZE(mt76_rates); i++)
@@ -569,11 +579,11 @@ 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);
+ mt7996_get_rates_table(hw, vif, false, true);
if (changed & BSS_CHANGED_BASIC_RATES)
mvif->basic_rates_idx =
- mt7996_get_rates_table(hw, vif, false);
+ mt7996_get_rates_table(hw, vif, false, false);
if (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon) {
mt7996_mcu_add_bss_info(phy, vif, true);
@@ -591,8 +601,12 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
mt7996_update_bss_color(hw, vif, &info->he_bss_color);
if (changed & (BSS_CHANGED_BEACON |
- BSS_CHANGED_BEACON_ENABLED))
+ BSS_CHANGED_BEACON_ENABLED)) {
+ mvif->beacon_rates_idx =
+ mt7996_get_rates_table(hw, vif, true, false);
+
mt7996_mcu_add_beacon(hw, vif, info->enable_beacon);
+ }
if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP ||
changed & BSS_CHANGED_FILS_DISCOVERY)
diff --git a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
index 52138aefc6be..2c226d9c50de 100644
--- a/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
+++ b/drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h
@@ -45,6 +45,7 @@
/* NOTE: used to map mt76_rates. idx may change if firmware expands table */
#define MT7996_BASIC_RATES_TBL 11
+#define MT7996_BEACON_RATES_TBL 25
struct mt7996_vif;
struct mt7996_sta;
@@ -142,6 +143,7 @@ struct mt7996_vif {
u8 basic_rates_idx;
u8 mcast_rates_idx;
+ u8 beacon_rates_idx;
};
/* per-phy stats. */
--
2.18.0