mt76: mt7615: fix sta ampdu factor for VHT
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/9 mt76: mt7615: fix sta ampdu factor for VHT
If VHT has a larger A-MPDU size limit, pass it to the MCU via the wtbl_ht TLV element.
--- drivers/net/wireless/mediatek/mt76/mt7615/mcu.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mcu.c +9 -2
@@ -924,11 +924,10 @@ mt7615_mcu_wtbl_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, void *sta_wtbl, void *wtbl_tlv) { struct tlv *tlv; +struct wtbl_ht *ht =NULL ;u32 flags =0 ;if (sta->ht_cap.ht_supported) { -struct wtbl_ht *ht; - tlv =mt7615_mcu_add_nested_tlv (skb,WTBL_HT ,sizeof (*ht), wtbl_tlv, sta_wtbl); ht = (struct wtbl_ht *)tlv;
@@ -945,6 +944,7 @@ mt7615_mcu_wtbl_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta,if (sta->vht_cap.vht_supported) {struct wtbl_vht *vht; +u8 af; tlv =mt7615_mcu_add_nested_tlv (skb,WTBL_VHT ,sizeof (*vht), wtbl_tlv, sta_wtbl);
@@ -952,6 +952,13 @@ mt7615_mcu_wtbl_ht_tlv(struct sk_buff *skb, struct ieee80211_sta *sta, vht->ldpc = sta->vht_cap.cap &IEEE80211_VHT_CAP_RXLDPC , vht->vht =1 ; + af = (sta->vht_cap.cap & +IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK ) >> +IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT ; + +if (ht) + ht->af =max (ht->af, af); +if (sta->vht_cap.cap &IEEE80211_VHT_CAP_SHORT_GI_80 ) flags |=MT_WTBL_W5_SHORT_GI_80 ;if (sta->vht_cap.cap &IEEE80211_VHT_CAP_SHORT_GI_160 )
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 2/9 mt76: fix A-MPDU density handling
The hardware requirements for A-MPDU density are entirely on the tx side, not the rx side. Because of that, the IE value should stay at 0 and the minimum value should instead be enforced in WTBL/TXWI
MT7615 has no restrictions here
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 1 - drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 5 +++++ drivers/net/wireless/mediatek/mt76/mt76x02_mac.c | 7 +++++-- 3 files changed, 10 insertions(+), 3 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +0 -1
@@ -198,7 +198,6 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, ht_cap->mcs.tx_params =IEEE80211_HT_MCS_TX_DEFINED ; ht_cap->ampdu_factor =IEEE80211_HT_MAX_AMPDU_64K ; - ht_cap->ampdu_density =IEEE80211_HT_MPDU_DENSITY_4 ;mt76_init_stream_cap (dev, sband, vht);
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +5 -0
@@ -318,11 +318,16 @@ void mt7603_wtbl_update_cap(struct mt7603_dev *dev, struct ieee80211_sta *sta) {struct mt7603_sta *msta = (struct mt7603_sta *)sta->drv_priv;int idx = msta->wcid.idx; +u8 ampdu_density;u32 addr;u32 val; addr =mt7603_wtbl1_addr (idx); + ampdu_density = sta->ht_cap.ampdu_density; +if (ampdu_density <IEEE80211_HT_MPDU_DENSITY_4 ) + ampdu_density =IEEE80211_HT_MPDU_DENSITY_4 ; + val =mt76_rr (dev, addr +2 *4 ); val &=MT_WTBL1_W2_KEY_TYPE |MT_WTBL1_W2_ADMISSION_CONTROL ; val |= FIELD_PREP(MT_WTBL1_W2_AMPDU_FACTOR, sta->ht_cap.ampdu_factor) |
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +5 -2
@@ -409,6 +409,7 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi, txwi->ack_ctl |=MT_TXWI_ACK_CTL_NSEQ ;if ((info->flags &IEEE80211_TX_CTL_AMPDU ) && sta) {u8 ba_size =IEEE80211_MIN_AMPDU_BUF ; +u8 ampdu_density = sta->ht_cap.ampdu_density; ba_size <<= sta->ht_cap.ampdu_factor; ba_size =min_t (int,63 , ba_size -1 );
@@ -416,9 +417,11 @@ void mt76x02_mac_write_txwi(struct mt76x02_dev *dev, struct mt76x02_txwi *txwi, ba_size =0 ; txwi->ack_ctl |=FIELD_PREP (MT_TXWI_ACK_CTL_BA_WINDOW , ba_size); +if (ampdu_density <IEEE80211_HT_MPDU_DENSITY_4 ) + ampdu_density =IEEE80211_HT_MPDU_DENSITY_4 ; + txwi_flags |=MT_TXWI_FLAGS_AMPDU | -FIELD_PREP (MT_TXWI_FLAGS_MPDU_DENSITY , - sta->ht_cap.ampdu_density); +FIELD_PREP (MT_TXWI_FLAGS_MPDU_DENSITY , ampdu_density); } if (ieee80211_is_probe_resp(hdr->frame_control) ||
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 3/9 mt76: mt7615: use larger rx buffers if VHT is supported
In reply to Felix FietkauIn VHT mode we can receive larger MPDUs. Increasing the buffer size reduces fragmentation here, which should improve performance.
--- drivers/net/wireless/mediatek/mt76/mt7615/dma.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/dma.c +7 -2
@@ -192,8 +192,13 @@ static void mt7663_dma_sched_init(struct mt7615_dev *dev)int mt7615_dma_init (struct mt7615_dev *dev) {int rx_ring_size =MT7615_RX_RING_SIZE ; +int rx_buf_size =MT_RX_BUF_SIZE ;int ret; +/* Increase buffer size to receive large VHT MPDUs */ +if (dev->mt76.cap.has_5ghz) + rx_buf_size *=2 ; +mt76_dma_attach (&dev->mt76); mt76_wr(dev, MT_WPDMA_GLO_CFG,
@@ -234,7 +239,7 @@ int mt7615_dma_init(struct mt7615_dev *dev)/* init rx queues */ ret =mt76_queue_alloc (dev, &dev->mt76.q_rx[MT_RXQ_MCU ],1 , -MT7615_RX_MCU_RING_SIZE ,MT_RX_BUF_SIZE , +MT7615_RX_MCU_RING_SIZE , rx_buf_size,MT_RX_RING_BASE );if (ret)return ret;
@@ -243,7 +248,7 @@ int mt7615_dma_init(struct mt7615_dev *dev) rx_ring_size /=2 ; ret =mt76_queue_alloc (dev, &dev->mt76.q_rx[MT_RXQ_MAIN ],0 , - rx_ring_size,MT_RX_BUF_SIZE ,MT_RX_RING_BASE ); + rx_ring_size, rx_buf_size,MT_RX_RING_BASE );if (ret)return ret;
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 4/9 mt76: mt7615: never use an 802.11b CF-End rate on 5GHz
In reply to Felix FietkauSometimes mt7615_mac_set_timing gets called while the slot time is still configured to 20. Ensure that in this case it always uses the OFDM CFend rate.
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -2
@@ -117,8 +117,9 @@ void mt7615_mac_set_timing(struct mt7615_phy *phy)u32 ofdm =FIELD_PREP (MT_TIMEOUT_VAL_PLCP ,60 ) |FIELD_PREP (MT_TIMEOUT_VAL_CCA ,24 );int sifs, offset; +bool is_5ghz = phy->mt76->chandef.chan->band ==NL80211_BAND_5GHZ ; -if (phy->mt76->chandef.chan->band ==NL80211_BAND_5GHZ ) +if (is_5ghz) sifs =16 ;else sifs =10 ;
@@ -151,7 +152,7 @@ void mt7615_mac_set_timing(struct mt7615_phy *phy)FIELD_PREP (MT_IFS_SIFS , sifs) | FIELD_PREP(MT_IFS_SLOT, phy->slottime)); -if (phy->slottime <20 ) +if (phy->slottime <20 || is_5ghz) val =MT7615_CFEND_RATE_DEFAULT ;else val =MT7615_CFEND_RATE_11B ;
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 5/9 mt76: mt7603: never use an 802.11b CF-End rate on 5GHz
In reply to Felix FietkauSometimes mt7615_mac_set_timing gets called while the slot time is still configured to 20. Ensure that in this case it always uses the OFDM CFend rate.
--- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +3 -2
@@ -51,10 +51,11 @@ void mt7603_mac_set_timing(struct mt7603_dev *dev)int offset =3 * dev->coverage_class;u32 reg_offset =FIELD_PREP (MT_TIMEOUT_VAL_PLCP , offset) |FIELD_PREP (MT_TIMEOUT_VAL_CCA , offset); +bool is_5ghz = dev->mphy.chandef.chan->band ==NL80211_BAND_5GHZ ;int sifs;u32 val; -if (dev->mphy.chandef.chan->band ==NL80211_BAND_5GHZ ) +if (is_5ghz) sifs =16 ;else sifs =10 ;
@@ -71,7 +72,7 @@ void mt7603_mac_set_timing(struct mt7603_dev *dev)FIELD_PREP (MT_IFS_SIFS , sifs) | FIELD_PREP(MT_IFS_SLOT, dev->slottime)); -if (dev->slottime <20 ) +if (dev->slottime <20 || is_5ghz) val =MT7603_CFEND_RATE_DEFAULT ;else val =MT7603_CFEND_RATE_11B ;
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 6/9 mt76: mt7615: adjust timing in mt7615_mac_set_timing to match fw/hw values
In reply to Felix FietkauSlightly improves performance
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +1 -1
@@ -115,7 +115,7 @@ void mt7615_mac_set_timing(struct mt7615_phy *phy)u32 cck =FIELD_PREP (MT_TIMEOUT_VAL_PLCP ,231 ) |FIELD_PREP (MT_TIMEOUT_VAL_CCA ,48 );u32 ofdm =FIELD_PREP (MT_TIMEOUT_VAL_PLCP ,60 ) | -FIELD_PREP (MT_TIMEOUT_VAL_CCA ,24 ); +FIELD_PREP (MT_TIMEOUT_VAL_CCA ,28 );int sifs, offset;bool is_5ghz = phy->mt76->chandef.chan->band ==NL80211_BAND_5GHZ ;
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 7/9 mt76: mt7615: do not adjust MAC timings if the device is not running
In reply to Felix FietkauAvoids register writes and MAC start/stop when the hardware isn't ready for it
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +3 -0
@@ -119,6 +119,9 @@ void mt7615_mac_set_timing(struct mt7615_phy *phy)int sifs, offset;bool is_5ghz = phy->mt76->chandef.chan->band ==NL80211_BAND_5GHZ ; +if (!test_bit (MT76_STATE_RUNNING , &phy->mt76->state)) +return ; +if (is_5ghz) sifs =16 ;else
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 8/9 mt76: mt7615: fix tx status rate index calculation
In reply to Felix FietkauA switch from one rate index to the next only happens when tx count from the current slot is greater than MT7615_RATE_RETRY, which is 1 has to be subtracted from count, instead of added to it.
--- drivers/net/wireless/mediatek/mt76/mt7615/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7615/mac.c +1 -1
@@ -1148,7 +1148,7 @@ static bool mt7615_fill_txs(struct mt7615_dev *dev, struct mt7615_sta *sta,if (ampdu || (info->flags &IEEE80211_TX_CTL_AMPDU )) info->flags |=IEEE80211_TX_STAT_AMPDU |IEEE80211_TX_CTL_AMPDU ; - first_idx =max_t (int,0 , last_idx - (count +1 ) /MT7615_RATE_RETRY ); + first_idx =max_t (int,0 , last_idx - (count -1 ) /MT7615_RATE_RETRY );if (fixed_rate && !probe) { info->status.rates[0 ].count = count;
Signature · 1 line
2.24.0
Felix Fietkau
maintainerPATCH 9/9 mt76: mt7603: fix tx status rate index calculation
In reply to Felix FietkauA switch from one rate index to the next only happens when tx count from the current slot is greater than MT7615_RATE_RETRY, which is 1 has to be subtracted from count, instead of added to it.
--- drivers/net/wireless/mediatek/mt76/mt7603/mac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mt7603/mac.c +1 -1
@@ -1103,7 +1103,7 @@ mt7603_fill_txs(struct mt7603_dev *dev, struct mt7603_sta *sta,if (ampdu || (info->flags &IEEE80211_TX_CTL_AMPDU )) info->flags |=IEEE80211_TX_STAT_AMPDU |IEEE80211_TX_CTL_AMPDU ; - first_idx =max_t (int,0 , last_idx - (count +1 ) /MT7603_RATE_RETRY ); + first_idx =max_t (int,0 , last_idx - (count -1 ) /MT7603_RATE_RETRY );if (fixed_rate && !probe) { info->status.rates[0 ].count = count;
Signature · 1 line
2.24.0