public inbox for linux-wireless@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code
@ 2018-04-03 19:52 Felix Fietkau
  2018-04-03 19:52 ` [PATCH 2/7] mt76: add missing VHT maximum A-MPDU length capability Felix Fietkau
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

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 <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c    | 6 ++----
 drivers/net/wireless/mediatek/mt76/mt76x2_main.c | 1 +
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 4f30cdcd2b53..962ed8234065 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -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);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_main.c b/drivers/net/wireless/mediatek/mt76/mt76x2_main.c
index 73c127f92613..81c58f865c64 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2_main.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2_main.c
@@ -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);
 }
 
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/7] mt76: add missing VHT maximum A-MPDU length capability
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
@ 2018-04-03 19:52 ` Felix Fietkau
  2018-04-03 19:52 ` [PATCH 3/7] mt76: toggle driver station powersave bit before notifying mac80211 Felix Fietkau
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

Signficantly improves throughput with some clients

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 962ed8234065..ec531ce50d01 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -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;
 }
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/7] mt76: toggle driver station powersave bit before notifying mac80211
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
  2018-04-03 19:52 ` [PATCH 2/7] mt76: add missing VHT maximum A-MPDU length capability Felix Fietkau
@ 2018-04-03 19:52 ` Felix Fietkau
  2018-04-03 19:52 ` [PATCH 4/7] mt76: rework tx power handling Felix Fietkau
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

Avoids race conditions from mac80211 enqueueing tx packets before the
tx-drop bit is cleared

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index ec531ce50d01..eb49e0a6758c 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -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,
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/7] mt76: rework tx power handling
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
  2018-04-03 19:52 ` [PATCH 2/7] mt76: add missing VHT maximum A-MPDU length capability Felix Fietkau
  2018-04-03 19:52 ` [PATCH 3/7] mt76: toggle driver station powersave bit before notifying mac80211 Felix Fietkau
@ 2018-04-03 19:52 ` Felix Fietkau
  2018-04-03 19:52 ` [PATCH 5/7] mt76: fix potential sleep in atomic context Felix Fietkau
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

There 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

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/mt76x2_phy.c | 67 ++++++++++++++++---------
 1 file changed, 42 insertions(+), 25 deletions(-)

diff --git a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c
index fcc37eb7ce0b..2edc6b8b4e29 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76x2_phy.c
@@ -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);
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/7] mt76: fix potential sleep in atomic context
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
                   ` (2 preceding siblings ...)
  2018-04-03 19:52 ` [PATCH 4/7] mt76: rework tx power handling Felix Fietkau
@ 2018-04-03 19:52 ` Felix Fietkau
  2018-04-03 19:52 ` [PATCH 6/7] mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets Felix Fietkau
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

Use cancel_delayed_work instead of cancel_delayed_work_sync

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/agg-rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
index fcb208d1f276..cbac42cb536c 100644
--- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
+++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
@@ -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)
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/7] mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
                   ` (3 preceding siblings ...)
  2018-04-03 19:52 ` [PATCH 5/7] mt76: fix potential sleep in atomic context Felix Fietkau
@ 2018-04-03 19:52 ` Felix Fietkau
  2018-04-03 19:52 ` [PATCH 7/7] mt76: check qos ack policy before reordering packets Felix Fietkau
  2018-04-24 17:30 ` [1/7] mt76: stop tx queues from the driver callback instead of common code Kalle Valo
  6 siblings, 0 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

Required for fast-rx and allows mac80211 to skip an unnnecessary check.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/agg-rx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
index cbac42cb536c..6657ec8928de 100644
--- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
+++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
@@ -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)
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 7/7] mt76: check qos ack policy before reordering packets
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
                   ` (4 preceding siblings ...)
  2018-04-03 19:52 ` [PATCH 6/7] mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets Felix Fietkau
@ 2018-04-03 19:52 ` Felix Fietkau
  2018-04-24 17:30 ` [1/7] mt76: stop tx queues from the driver callback instead of common code Kalle Valo
  6 siblings, 0 replies; 8+ messages in thread
From: Felix Fietkau @ 2018-04-03 19:52 UTC (permalink / raw)
  To: linux-wireless; +Cc: kvalo

Do not attempt to reorder packets not part of a BA session

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 drivers/net/wireless/mediatek/mt76/agg-rx.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mediatek/mt76/agg-rx.c b/drivers/net/wireless/mediatek/mt76/agg-rx.c
index 6657ec8928de..dbf4057d2d3e 100644
--- a/drivers/net/wireless/mediatek/mt76/agg-rx.c
+++ b/drivers/net/wireless/mediatek/mt76/agg-rx.c
@@ -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;
-- 
2.14.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [1/7] mt76: stop tx queues from the driver callback instead of common code
  2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
                   ` (5 preceding siblings ...)
  2018-04-03 19:52 ` [PATCH 7/7] mt76: check qos ack policy before reordering packets Felix Fietkau
@ 2018-04-24 17:30 ` Kalle Valo
  6 siblings, 0 replies; 8+ messages in thread
From: Kalle Valo @ 2018-04-24 17:30 UTC (permalink / raw)
  To: Felix Fietkau; +Cc: linux-wireless

Felix Fietkau <nbd@nbd.name> wrote:

> 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 <nbd@nbd.name>

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 handling
07073a2768ac 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

-- 
https://patchwork.kernel.org/patch/10321713/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-24 17:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-04-03 19:52 [PATCH 1/7] mt76: stop tx queues from the driver callback instead of common code Felix Fietkau
2018-04-03 19:52 ` [PATCH 2/7] mt76: add missing VHT maximum A-MPDU length capability Felix Fietkau
2018-04-03 19:52 ` [PATCH 3/7] mt76: toggle driver station powersave bit before notifying mac80211 Felix Fietkau
2018-04-03 19:52 ` [PATCH 4/7] mt76: rework tx power handling Felix Fietkau
2018-04-03 19:52 ` [PATCH 5/7] mt76: fix potential sleep in atomic context Felix Fietkau
2018-04-03 19:52 ` [PATCH 6/7] mt76: set RX_FLAG_DUP_VALIDATED for A-MPDU reordered packets Felix Fietkau
2018-04-03 19:52 ` [PATCH 7/7] mt76: check qos ack policy before reordering packets Felix Fietkau
2018-04-24 17:30 ` [1/7] mt76: stop tx queues from the driver callback instead of common code Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox