Skip to content

Commit c2171b0

Browse files
ryderlee1110nbd168
authored andcommitted
wifi: mt76: mt7996: enable configured beacon tx rate
The user is allowed to change beacon tx rate (HT/VHT/HE) from hostapd. Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent ab0eec4 commit c2171b0

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

drivers/net/wireless/mediatek/mt76/mt7996/mac.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,6 +1077,8 @@ void mt7996_mac_write_txwi(struct mt7996_dev *dev, __le32 *txwi,
10771077

10781078
if (mcast && mvif->mcast_rates_idx)
10791079
idx = mvif->mcast_rates_idx;
1080+
else if (beacon && mvif->beacon_rates_idx)
1081+
idx = mvif->beacon_rates_idx;
10801082

10811083
txwi[6] |= FIELD_PREP(MT_TXD6_TX_RATE, idx);
10821084
txwi[3] |= cpu_to_le32(MT_TXD3_BA_DISABLE);

drivers/net/wireless/mediatek/mt76/mt7996/main.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,14 +504,24 @@ mt7996_update_bss_color(struct ieee80211_hw *hw,
504504

505505
static u8
506506
mt7996_get_rates_table(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
507-
bool mcast)
507+
bool beacon, bool mcast)
508508
{
509509
struct mt7996_vif *mvif = (struct mt7996_vif *)vif->drv_priv;
510510
struct mt76_phy *mphy = hw->priv;
511511
u16 rate;
512-
u8 i, idx;
512+
u8 i, idx, ht;
513513

514-
rate = mt76_connac2_mac_tx_rate_val(mphy, vif, false, mcast);
514+
rate = mt76_connac2_mac_tx_rate_val(mphy, vif, beacon, mcast);
515+
ht = FIELD_GET(MT_TX_RATE_MODE, rate) > MT_PHY_TYPE_OFDM;
516+
517+
if (beacon && ht) {
518+
struct mt7996_dev *dev = mt7996_hw_dev(hw);
519+
520+
/* must odd index */
521+
idx = MT7996_BEACON_RATES_TBL + 2 * (mvif->mt76.idx % 20);
522+
mt7996_mac_set_fixed_rate_table(dev, idx, rate);
523+
return idx;
524+
}
515525

516526
idx = FIELD_GET(MT_TX_RATE_IDX, rate);
517527
for (i = 0; i < ARRAY_SIZE(mt76_rates); i++)
@@ -560,11 +570,11 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
560570

561571
if (changed & BSS_CHANGED_MCAST_RATE)
562572
mvif->mcast_rates_idx =
563-
mt7996_get_rates_table(hw, vif, true);
573+
mt7996_get_rates_table(hw, vif, false, true);
564574

565575
if (changed & BSS_CHANGED_BASIC_RATES)
566576
mvif->basic_rates_idx =
567-
mt7996_get_rates_table(hw, vif, false);
577+
mt7996_get_rates_table(hw, vif, false, false);
568578

569579
if (changed & BSS_CHANGED_BEACON_ENABLED && info->enable_beacon) {
570580
mt7996_mcu_add_bss_info(phy, vif, true);
@@ -582,8 +592,12 @@ static void mt7996_bss_info_changed(struct ieee80211_hw *hw,
582592
mt7996_update_bss_color(hw, vif, &info->he_bss_color);
583593

584594
if (changed & (BSS_CHANGED_BEACON |
585-
BSS_CHANGED_BEACON_ENABLED))
595+
BSS_CHANGED_BEACON_ENABLED)) {
596+
mvif->beacon_rates_idx =
597+
mt7996_get_rates_table(hw, vif, true, false);
598+
586599
mt7996_mcu_add_beacon(hw, vif, info->enable_beacon);
600+
}
587601

588602
if (changed & BSS_CHANGED_UNSOL_BCAST_PROBE_RESP ||
589603
changed & BSS_CHANGED_FILS_DISCOVERY)

drivers/net/wireless/mediatek/mt76/mt7996/mt7996.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545

4646
/* NOTE: used to map mt76_rates. idx may change if firmware expands table */
4747
#define MT7996_BASIC_RATES_TBL 11
48+
#define MT7996_BEACON_RATES_TBL 25
4849

4950
struct mt7996_vif;
5051
struct mt7996_sta;
@@ -126,6 +127,7 @@ struct mt7996_vif {
126127

127128
u8 basic_rates_idx;
128129
u8 mcast_rates_idx;
130+
u8 beacon_rates_idx;
129131
};
130132

131133
/* per-phy stats. */

0 commit comments

Comments
 (0)