mt76: add mt76_default_basic_rate more devices can rely on
Subsystems (2)
Felix Fietkau
maintainerPATCH v4 1/3 mt76: add mt76_default_basic_rate more devices can rely on
From: Sean Wang <[email protected]>
add mt76_default_basic_rate to mt76 core more devices can rely on to send frames which require the rate in the basic rates.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 14 ++++++++++++++ drivers/net/wireless/mediatek/mt76/mt76.h | 1 + 2 files changed, 15 insertions(+)
drivers/net/wireless/mediatek/mt76/mac80211.c +14 -0
@@ -1351,3 +1351,17 @@ mt76_init_queue(struct mt76_dev *dev, int qid, int idx, int n_desc,return hwq; }EXPORT_SYMBOL_GPL (mt76_init_queue); + +u16 mt76_default_basic_rate (struct mt76_phy *phy,struct ieee80211_vif *vif) +{ +int i =ffs (vif->bss_conf.basic_rates) -1 , offset =0 ; +struct ieee80211_rate *rate; + +if (phy->chandef.chan->band ==NL80211_BAND_5GHZ ) + offset =4 ; + + rate = &mt76_rates[offset + i]; + +return rate->hw_value; +} +EXPORT_SYMBOL_GPL (mt76_default_basic_rate);
drivers/net/wireless/mediatek/mt76/mt76.h +1 -0
@@ -891,6 +891,7 @@ int mt76_get_of_eeprom(struct mt76_dev *dev, void *data, int offset, int len);struct mt76_queue *mt76_init_queue (struct mt76_dev *dev,int qid,int idx,int n_desc,int ring_base); +u16 mt76_default_basic_rate (struct mt76_phy *phy,struct ieee80211_vif *vif);static inline int mt76_init_tx_queue (struct mt76_phy *phy,int qid,int idx,int n_desc,int ring_base) {
Signature · 1 line
2.30.1
Felix Fietkau
maintainerPATCH v4 2/3 mt76: mt7921: fix mgmt frame using unexpected bitrate
From: Sean Wang <[email protected]>
Fix the current driver mgmt frame is not respecting the basic rates field provided by the AP and then unconditionally is using the lowest (1 or 6 Mbps) rate.
For example, if the AP only supported basic rate {24, 36, 48, 54} Mbps, mt7921 cannot send mgmt frame with the rate not in the group. So, instead, we pick up the lowest basic rate the AP can support to send.
---
v4: do not rely on rate->hw_value having the proper shift for phy mode
drivers/net/wireless/mediatek/mt76/mt7921/mac.c | 10 +++++----- drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7921/mac.c +5 -5
@@ -811,15 +811,15 @@ void mt7921_mac_write_txwi(struct mt7921_dev *dev, __le32 *txwi,mt7921_mac_write_txwi_80211 (dev, txwi, skb, key);if (txwi[2 ] &cpu_to_le32 (MT_TXD2_FIX_RATE )) { -u16 rate; +u16 rate, mode;/* hardware won't add HTC for mgmt/ctrl frame */ txwi[2 ] |=cpu_to_le32 (MT_TXD2_HTC_VLD ); -if (mphy->chandef.chan->band ==NL80211_BAND_5GHZ ) - rate =MT7921_5G_RATE_DEFAULT ; -else - rate =MT7921_2G_RATE_DEFAULT ; + rate =mt76_default_basic_rate (mphy, vif); + mode = rate >>8 ; + rate &=GENMASK (7 ,0 ); + rate |=FIELD_PREP (MT_TX_RATE_MODE , mode); val =MT_TXD6_FIXED_BW |FIELD_PREP (MT_TXD6_TX_RATE , rate);
drivers/net/wireless/mediatek/mt76/mt7921/mt7921.h +0 -2
@@ -38,8 +38,6 @@#define MT7921_CFEND_RATE_DEFAULT 0x49/* OFDM 24M */ #define MT7921_CFEND_RATE_11B 0x03/* 11B LP, 11M */ -#define MT7921_5G_RATE_DEFAULT 0x4b/* OFDM 6M */ -#define MT7921_2G_RATE_DEFAULT 0x0/* CCK 1M */ #define MT7921_SKU_RATE_NUM 161#define MT7921_SKU_MAX_DELTA_IDX MT7921_SKU_RATE_NUM
Signature · 1 line
2.30.1
Felix Fietkau
maintainerPATCH v4 3/3 mt76: mt7915: fix mgmt frame using unexpected bitrate
In reply to Felix FietkauFrom: Sean Wang <[email protected]>
Fix the current driver mgmt frame is not respecting the basic rates field provided by the AP and then unconditionally is using the lowest (1 or 6 Mbps) rate.
For example, if the AP only supported basic rate {24, 36, 48, 54} Mbps, mt7921 cannot send mgmt frame with the rate not in the group. So, instead, we pick up the lowest basic rate the AP can support to send.
---
v4: do not rely on rate->hw_value having the proper shift for phy mode
drivers/net/wireless/mediatek/mt76/mt7915/mac.c | 10 +++++----- drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h | 2 -- 2 files changed, 5 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7915/mac.c +5 -5
@@ -1055,15 +1055,15 @@ void mt7915_mac_write_txwi(struct mt7915_dev *dev, __le32 *txwi,mt7915_mac_write_txwi_80211 (dev, txwi, skb, key);if (txwi[2 ] &cpu_to_le32 (MT_TXD2_FIX_RATE )) { -u16 rate; +u16 rate, mode;/* hardware won't add HTC for mgmt/ctrl frame */ txwi[2 ] |=cpu_to_le32 (MT_TXD2_HTC_VLD ); -if (mphy->chandef.chan->band ==NL80211_BAND_5GHZ ) - rate =MT7915_5G_RATE_DEFAULT ; -else - rate =MT7915_2G_RATE_DEFAULT ; + rate =mt76_default_basic_rate (mphy, vif); + mode = rate >>8 ; + rate &=GENMASK (7 ,0 ); + rate |=FIELD_PREP (MT_TX_RATE_MODE , mode); val =MT_TXD6_FIXED_BW |FIELD_PREP (MT_TXD6_TX_RATE , rate);
drivers/net/wireless/mediatek/mt76/mt7915/mt7915.h +0 -2
@@ -36,8 +36,6 @@#define MT7915_CFEND_RATE_DEFAULT 0x49/* OFDM 24M */ #define MT7915_CFEND_RATE_11B 0x03/* 11B LP, 11M */ -#define MT7915_5G_RATE_DEFAULT 0x4b/* OFDM 6M */ -#define MT7915_2G_RATE_DEFAULT 0x0/* CCK 1M */ #define MT7915_THERMAL_THROTTLE_MAX 100
Signature · 1 line
2.30.1