mt76: stop tx queues from the driver callback instead of common code
Subsystems (2)
Felix Fietkau
maintainerPATCH 1/7 mt76: stop tx queues from the driver callback instead of common code
Allows the driver to control whether to send a BlockAckReq after waking up. MT76x2 needs this set to true, for MT7603 (to be submitted later) it needs to be false.
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 6 ++---- drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 1 + 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -4
@@ -541,12 +541,10 @@ mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb)if (!!test_bit (MT_WCID_FLAG_PS , &wcid->flags) == ps)return ; -if (ps) { +if (ps)set_bit (MT_WCID_FLAG_PS , &wcid->flags); -mt76_stop_tx_queues (dev, sta, true); - }else { +else clear_bit (MT_WCID_FLAG_PS , &wcid->flags); - }ieee80211_sta_ps_transition (sta, ps); dev->drv->sta_ps (dev, sta, ps);
drivers/net/wireless/mediatek/mt76/mt76x2_main.c +1 -0
@@ -321,6 +321,7 @@ mt76x2_sta_ps(struct mt76_dev *mdev, struct ieee80211_sta *sta, bool ps) struct mt76x2_dev *dev = container_of(mdev, struct mt76x2_dev, mt76);int idx = msta->wcid.idx; +mt76_stop_tx_queues (&dev->mt76, sta, true);mt76x2_mac_wcid_set_drop (dev, idx, ps); }
Signature · 1 line
2.14.2
Felix Fietkau
maintainerPATCH 2/7 mt76: add missing VHT maximum A-MPDU length capability
Signficantly improves throughput with some clients
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +2 -1
@@ -213,7 +213,8 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, vht_cap->vht_supported = true; vht_cap->cap |=IEEE80211_VHT_CAP_RXLDPC |IEEE80211_VHT_CAP_RXSTBC_1 | -IEEE80211_VHT_CAP_SHORT_GI_80 ; +IEEE80211_VHT_CAP_SHORT_GI_80 | + (3 <<IEEE80211_VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_SHIFT );return 0 ; }
Signature · 1 line
2.14.2
Felix Fietkau
maintainerPATCH 4/7 mt76: rework tx power handling
In reply to Felix FietkauThere were a number of issues in the existing tx power handling code:
1. The EEPROM target power for chain 0 refers to the actual output power after the channel and bandwidth delta have been added to the initial channel gain. This means the delta values should not be added/subtracted for the rate power calculation
2. When power is reduced significantly, the initial channel gain underflows very quickly, while the per-rate power offsets are high. This miscalculation causes effective tx power to be increased when it should actually be lowered.
Fix this by trying to adjust the channel gain to the lowest power from the rate table. In case of under- or overflow, compensate by adding an appropriate delta to the rate power values.
This makes power configuration more accurate on a wider range of configurable values
--- drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | 67 ++++++++++++++++--------- 1 file changed, 42 insertions(+), 25 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x2_phy.c +42 -25
@@ -73,16 +73,6 @@ int mt76x2_phy_get_rssi(struct mt76x2_dev *dev, s8 rssi, int chain)return rssi; } -static u8 -mt76x2_txpower_check (int value) -{ -if (value <0 ) -return 0 ; -if (value >0x2f ) -return 0x2f ; -return value; -} -static void mt76x2_add_rate_power_offset (struct mt76_rate_power *r,int offset) {
@@ -102,6 +92,26 @@ mt76x2_limit_rate_power(struct mt76_rate_power *r, int limit) r->all[i] = limit; } +static int +mt76x2_get_min_rate_power (struct mt76_rate_power *r) +{ +int i; +s8 ret =0 ; + +for (i =0 ; i <sizeof (r->all); i++) { +if (!r->all[i]) +continue ; + +if (ret) + ret =min (ret, r->all[i]); +else + ret = r->all[i]; + } + +return ret; +} + +void mt76x2_phy_set_txpower (struct mt76x2_dev *dev) {enum nl80211_chan_width width = dev->mt76.chandef.width;
@@ -109,6 +119,7 @@ void mt76x2_phy_set_txpower(struct mt76x2_dev *dev)struct mt76x2_tx_power_info txp;int txp_0, txp_1, delta =0 ;struct mt76_rate_power t = {}; +int base_power, gain;mt76x2_get_power_info (dev, &txp, chan);
@@ -117,26 +128,32 @@ void mt76x2_phy_set_txpower(struct mt76x2_dev *dev)else if (width ==NL80211_CHAN_WIDTH_80 ) delta = txp.delta_bw80; -if (txp.target_power > dev->txpower_conf) - delta -= txp.target_power - dev->txpower_conf; -mt76x2_get_rate_power (dev, &t, chan); -mt76x2_add_rate_power_offset (&t, txp.chain[0 ].target_power + - txp.chain[0 ].delta); +mt76x2_add_rate_power_offset (&t, txp.chain[0 ].target_power);mt76x2_limit_rate_power (&t, dev->txpower_conf); dev->txpower_cur =mt76x2_get_max_rate_power (&t); -mt76x2_add_rate_power_offset (&t, -(txp.chain[0 ].target_power + - txp.chain[0 ].delta + delta)); - dev->target_power = txp.chain[0 ].target_power; - dev->target_power_delta[0 ] = txp.chain[0 ].delta + delta; - dev->target_power_delta[1 ] = txp.chain[1 ].delta + delta; - dev->rate_power = t; - txp_0 =mt76x2_txpower_check (txp.chain[0 ].target_power + - txp.chain[0 ].delta + delta); + base_power =mt76x2_get_min_rate_power (&t); + delta += base_power - txp.chain[0 ].target_power; + txp_0 = txp.chain[0 ].target_power + txp.chain[0 ].delta + delta; + txp_1 = txp.chain[1 ].target_power + txp.chain[1 ].delta + delta; + + gain =min (txp_0, txp_1); +if (gain <0 ) { + base_power -= gain; + txp_0 -= gain; + txp_1 -= gain; + }else if (gain >0x2f ) { + base_power -= gain -0x2f ; + txp_0 =0x2f ; + txp_1 =0x2f ; + } - txp_1 =mt76x2_txpower_check (txp.chain[1 ].target_power + - txp.chain[1 ].delta + delta); +mt76x2_add_rate_power_offset (&t, -base_power); + dev->target_power = txp.chain[0 ].target_power; + dev->target_power_delta[0 ] = txp_0 - txp.chain[0 ].target_power; + dev->target_power_delta[1 ] = txp_1 - txp.chain[0 ].target_power; + dev->rate_power = t;mt76_rmw_field (dev,MT_TX_ALC_CFG_0 ,MT_TX_ALC_CFG_0_CH_INIT_0 , txp_0);mt76_rmw_field (dev,MT_TX_ALC_CFG_0 ,MT_TX_ALC_CFG_0_CH_INIT_1 , txp_1);
Signature · 1 line
2.14.2
Felix Fietkau
maintainerPATCH 6/7 mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets
In reply to Felix FietkauRequired for fast-rx and allows mac80211 to skip an unnnecessary check.
--- drivers/net/wireless/mediatek/mt76/agg-rx.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/mediatek/mt76/agg-rx.c +1 -0
@@ -169,6 +169,7 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)if (!tid)return ; + status->flag |=RX_FLAG_DUP_VALIDATED ;spin_lock_bh (&tid->lock);if (tid->stopped)
Signature · 1 line
2.14.2
Felix Fietkau
maintainerPATCH 7/7 mt76: check qos ack policy before reordering packets
In reply to Felix FietkauDo not attempt to reorder packets not part of a BA session
--- drivers/net/wireless/mediatek/mt76/agg-rx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/agg-rx.c +8 -1
@@ -147,12 +147,13 @@ mt76_rx_aggr_check_ctl(struct sk_buff *skb, struct sk_buff_head *frames)void mt76_rx_aggr_reorder (struct sk_buff *skb,struct sk_buff_head *frames) {struct mt76_rx_status *status = (struct mt76_rx_status *) skb->cb; +struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;struct mt76_wcid *wcid = status->wcid;struct ieee80211_sta *sta;struct mt76_rx_tid *tid;bool sn_less;u16 seqno, head, size; -u8 idx; +u8 ackp, idx;__skb_queue_tail (frames, skb);
@@ -165,6 +166,12 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames)return ; } +/* not part of a BA session */ + ackp = *ieee80211_get_qos_ctl (hdr) &IEEE80211_QOS_CTL_ACK_POLICY_MASK ; +if (ackp !=IEEE80211_QOS_CTL_ACK_POLICY_BLOCKACK && + ackp !=IEEE80211_QOS_CTL_ACK_POLICY_NORMAL ) +return ; + tid =rcu_dereference (wcid->aggr[status->tid]);if (!tid)return ;
Signature · 1 line
2.14.2
Felix Fietkau
maintainerPATCH 3/7 mt76: toggle driver station powersave bit before notifying mac80211
In reply to Felix FietkauAvoids race conditions from mac80211 enqueueing tx packets before the tx-drop bit is cleared
--- drivers/net/wireless/mediatek/mt76/mac80211.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/mac80211.c +1 -1
@@ -547,8 +547,8 @@ mt76_check_ps(struct mt76_dev *dev, struct sk_buff *skb)else clear_bit (MT_WCID_FLAG_PS , &wcid->flags); -ieee80211_sta_ps_transition (sta, ps); dev->drv->sta_ps (dev, sta, ps); +ieee80211_sta_ps_transition (sta, ps); } void mt76_rx_complete(struct mt76_dev *dev, struct sk_buff_head *frames,
Signature · 1 line
2.14.2
Felix Fietkau
maintainerPATCH 5/7 mt76: fix potential sleep in atomic context
In reply to Felix FietkauUse cancel_delayed_work instead of cancel_delayed_work_sync
--- drivers/net/wireless/mediatek/mt76/agg-rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/mediatek/mt76/agg-rx.c +1 -1
@@ -273,7 +273,7 @@ static void mt76_rx_aggr_shutdown(struct mt76_dev *dev, struct mt76_rx_tid *tid)spin_unlock_bh (&tid->lock); -cancel_delayed_work_sync (&tid->reorder_work); +cancel_delayed_work (&tid->reorder_work); }void mt76_rx_aggr_stop (struct mt76_dev *dev,struct mt76_wcid *wcid,u8 tidno)
Signature · 1 line
2.14.2
Quoted 5 lines · Felix Fietkau
Allows the driver to control whether to send a BlockAckReq after waking up. MT76x2 needs this set to true, for MT7603 (to be submitted later) it needs to be false.
Signed-off-by Felix Fietkau <[email protected]>
7 patches applied to wireless-drivers-next.git, thanks.
11b2a25f02b7 mt76: stop tx queues from the driver callback instead of common code 49149d3f1c6b mt76: add missing VHT maximum A-MPDU length capability 9f67c277a80f mt76: toggle driver station powersave bit before notifying mac80211 80f28994f7d9 mt76: rework tx power handling07073a2768ac mt76: fix potential sleep in atomic context 18efed59fabc mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets 1af83148a4fc mt76: check qos ack policy before reordering packets
Signature · 3 lines
https://patchwork.kernel.org/patch/10321713/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches