Skip to contentSkip to conversation

mt7603: fix reading target tx power from eeprom

PATCH Superseded Felix Fietkau 2 participants 9 messages Jun 7, 2019 – Jun 27, 2019

Subsystems (2)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH 1/4 mt7603: fix reading target tx power from eeprom

For the external PA (TSSI OFF) case, the target power needs to be read from a different location in EEPROM

---
 drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h | 2 ++
 drivers/net/wireless/mediatek/mt76/mt7603/init.c   | 4 ++++
 2 files changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h +2 -0
index f27b99b7e359..b893facfba48 100644
@@ -69,6 +69,8 @@ enum mt7603_eeprom_field {
 
 	MT_EE_CP_FT_VERSION =			0x0f0,
 
+	MT_EE_TX_POWER_TSSI_OFF =		0x0f2,
+
 	MT_EE_XTAL_FREQ_OFFSET =		0x0f4,
 	MT_EE_XTAL_TRIM_2_COMP =		0x0f5,
 	MT_EE_XTAL_TRIM_3_COMP =		0x0f6,
drivers/net/wireless/mediatek/mt76/mt7603/init.c +4 -0
index 4e269044f8a4..2238e3daedc6 100644
@@ -465,9 +465,13 @@ mt7603_init_txpower(struct mt7603_dev *dev,
 	u8 *eeprom = (u8 *)dev->mt76.eeprom.data;
 	int target_power = eeprom[MT_EE_TX_POWER_0_START_2G + 2] & ~BIT(7);
 	u8 *rate_power = &eeprom[MT_EE_TX_POWER_CCK];
+	bool ext_pa = eeprom[MT_EE_NIC_CONF_0 + 1] & BIT(1);
 	int max_offset, cur_offset;
 	int i;
 
+	if (ext_pa)
+		target_power = eeprom[MT_EE_TX_POWER_TSSI_OFF] & ~BIT(7);
+
 	if (target_power & BIT(6))
 		target_power = -(target_power & GENMASK(5, 0));
 
Signature · 1 line
2.17.0
author maintainer
#1 lore raw

PATCH 2/4 mt76: fix setting chan->max_power

When setting chan->max_power after registering the wiphy, chan->max_reg_power needs to be used as a limit

---
 drivers/net/wireless/mediatek/mt76/mt7603/init.c | 2 +-
 drivers/net/wireless/mediatek/mt76/mt76x0/init.c | 5 +++--
 drivers/net/wireless/mediatek/mt76/mt76x2/init.c | 9 +++++----
 3 files changed, 9 insertions(+), 7 deletions(-)
drivers/net/wireless/mediatek/mt76/mt7603/init.c +1 -1
index 2238e3daedc6..bce51997ff3b 100644
@@ -494,7 +494,7 @@ mt7603_init_txpower(struct mt7603_dev *dev,
 
 	for (i = 0; i < sband->n_channels; i++) {
 		chan = &sband->channels[i];
-		chan->max_power = target_power;
+		chan->max_power = min_t(int, chan->max_reg_power, target_power);
 		chan->orig_mpwr = target_power;
 	}
 }
drivers/net/wireless/mediatek/mt76/mt76x0/init.c +3 -2
index 57e46d57b449..d67401f895ca 100644
@@ -279,8 +279,9 @@ mt76x0_init_txpower(struct mt76x02_dev *dev,
 		mt76x0_get_tx_power_per_rate(dev, chan, &t);
 		mt76x0_get_power_info(dev, chan, &tp);
 
-		chan->max_power = (mt76x02_get_max_rate_power(&t) + tp) / 2;
-		chan->orig_mpwr = chan->max_power;
+		chan->orig_mpwr = (mt76x02_get_max_rate_power(&t) + tp) / 2;
+		chan->max_power = min_t(int, chan->max_reg_power,
+					chan->orig_mpwr);
 	}
 }
 
drivers/net/wireless/mediatek/mt76/mt76x2/init.c +5 -4
index c6078e90ca43..97c3543eed8a 100644
@@ -173,13 +173,14 @@ void mt76x2_init_txpower(struct mt76x02_dev *dev,
 		mt76x2_get_power_info(dev, &txp, chan);
 		mt76x2_get_rate_power(dev, &t, chan);
 
-		chan->max_power = mt76x02_get_max_rate_power(&t) +
+		chan->orig_mpwr = mt76x02_get_max_rate_power(&t) +
 				  txp.target_power;
-		chan->max_power = DIV_ROUND_UP(chan->max_power, 2);
+		chan->orig_mpwr = DIV_ROUND_UP(chan->orig_mpwr, 2);
 
 		/* convert to combined output power on 2x2 devices */
-		chan->max_power += 3;
-		chan->orig_mpwr = chan->max_power;
+		chan->orig_mpwr += 3;
+		chan->max_power = min_t(int, chan->max_reg_power,
+					chan->orig_mpwr);
 	}
 }
 EXPORT_SYMBOL_GPL(mt76x2_init_txpower);
Signature · 1 line
2.17.0
author maintainer
#2 lore raw

PATCH 3/4 mt76: mt76x02: fix tx status reporting issues

In reply to Felix Fietkau

When the hardware falls back to lower rates for a transmit attempt, only the first status report will show the number of retries correctly. The frames that follow will report the correct final rate, but number of retries set to 0. This can cause the rate control module to vastly underestimate the number of retransmissions per rate.

To fix this, we need to keep track of the initial requested tx rate per packet and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in the packet id (and make it possible to distinguish it from real packet ids).

To do that, reduce the packet id field size by one bit, and use that bit to indicate packet id vs rate.

This change also improves reporting by filling the status rate array with rates from first rate to final rate, taking the same steps as the hardware fallback table. This matters in corner cases like MCS8 on HT, where the fallback target is MCS0, not MCS7.

---
 drivers/net/wireless/mediatek/mt76/mt76.h     | 11 ++-
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 88 ++++++++++++++++---
 .../net/wireless/mediatek/mt76/mt76x02_txrx.c |  7 +-
 .../wireless/mediatek/mt76/mt76x02_usb_core.c |  7 +-
 4 files changed, 97 insertions(+), 16 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +10 -1
index fc4169c83e76..907bec9d5e4c 100644
@@ -258,10 +258,11 @@ struct mt76_rx_tid {
 #define MT_TX_CB_TXS_DONE		BIT(1)
 #define MT_TX_CB_TXS_FAILED		BIT(2)
 
-#define MT_PACKET_ID_MASK		GENMASK(7, 0)
+#define MT_PACKET_ID_MASK		GENMASK(6, 0)
 #define MT_PACKET_ID_NO_ACK		0
 #define MT_PACKET_ID_NO_SKB		1
 #define MT_PACKET_ID_FIRST		2
+#define MT_PACKET_ID_HAS_RATE		BIT(7)
 
 #define MT_TX_STATUS_SKB_TIMEOUT	HZ
 
@@ -689,6 +690,14 @@ static inline void mt76_insert_hdr_pad(struct sk_buff *skb)
 	skb->data[len + 1] = 0;
 }
 
+static inline bool mt76_is_skb_pktid(u8 pktid)
+{
+	if (pktid & MT_PACKET_ID_HAS_RATE)
+		return false;
+
+	return pktid >= MT_PACKET_ID_FIRST;
+}
+
 void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
 void mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta,
 	     struct mt76_wcid *wcid, struct sk_buff *skb);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +75 -13

119 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +6 -1
index cf7abd9b7d2e..95c73049a68b 100644
@@ -164,9 +164,14 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	mt76x02_mac_write_txwi(dev, txwi, tx_info->skb, wcid, sta, len);
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE | (txwi->rate & MT_RXWI_RATE_INDEX);
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST)
+	if (mt76_is_skb_pktid(pid))
 		qsel = MT_QSEL_MGMT;
 
 	tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +6 -1
index 6b89f7eab26c..2436f14ca24a 100644
@@ -89,9 +89,14 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 	skb_push(tx_info->skb, sizeof(*txwi));
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE | (txwi->rate & MT_RXWI_RATE_INDEX);
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST || ep == MT_EP_OUT_HCCA)
+	if (mt76_is_skb_pktid(pid) || ep == MT_EP_OUT_HCCA)
 		qsel = MT_QSEL_MGMT;
 	else
 		qsel = MT_QSEL_EDCA;
Signature · 1 line
2.17.0
author maintainer
#3 lore raw

PATCH v2 3/4 mt76: mt76x02: fix tx status reporting issues

When the hardware falls back to lower rates for a transmit attempt, only the first status report will show the number of retries correctly. The frames that follow will report the correct final rate, but number of retries set to 0. This can cause the rate control module to vastly underestimate the number of retransmissions per rate.

To fix this, we need to keep track of the initial requested tx rate per packet and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in the packet id (and make it possible to distinguish it from real packet ids).

To do that, reduce the packet id field size by one bit, and use that bit to indicate packet id vs rate.

This change also improves reporting by filling the status rate array with rates from first rate to final rate, taking the same steps as the hardware fallback table. This matters in corner cases like MCS8 on HT, where the fallback target is MCS0, not MCS7.

---
v2: fix reporting of non-probing frames with tx status requested

 drivers/net/wireless/mediatek/mt76/mt76.h     |  11 +-
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 102 +++++++++++++++---
 .../net/wireless/mediatek/mt76/mt76x02_txrx.c |   7 +-
 .../wireless/mediatek/mt76/mt76x02_usb_core.c |   7 +-
 4 files changed, 107 insertions(+), 20 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +10 -1
index fc4169c83e76..907bec9d5e4c 100644
@@ -258,10 +258,11 @@ struct mt76_rx_tid {
 #define MT_TX_CB_TXS_DONE		BIT(1)
 #define MT_TX_CB_TXS_FAILED		BIT(2)
 
-#define MT_PACKET_ID_MASK		GENMASK(7, 0)
+#define MT_PACKET_ID_MASK		GENMASK(6, 0)
 #define MT_PACKET_ID_NO_ACK		0
 #define MT_PACKET_ID_NO_SKB		1
 #define MT_PACKET_ID_FIRST		2
+#define MT_PACKET_ID_HAS_RATE		BIT(7)
 
 #define MT_TX_STATUS_SKB_TIMEOUT	HZ
 
@@ -689,6 +690,14 @@ static inline void mt76_insert_hdr_pad(struct sk_buff *skb)
 	skb->data[len + 1] = 0;
 }
 
+static inline bool mt76_is_skb_pktid(u8 pktid)
+{
+	if (pktid & MT_PACKET_ID_HAS_RATE)
+		return false;
+
+	return pktid >= MT_PACKET_ID_FIRST;
+}
+
 void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
 void mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta,
 	     struct mt76_wcid *wcid, struct sk_buff *skb);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +85 -17

142 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +6 -1
index cf7abd9b7d2e..95c73049a68b 100644
@@ -164,9 +164,14 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	mt76x02_mac_write_txwi(dev, txwi, tx_info->skb, wcid, sta, len);
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE | (txwi->rate & MT_RXWI_RATE_INDEX);
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST)
+	if (mt76_is_skb_pktid(pid))
 		qsel = MT_QSEL_MGMT;
 
 	tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +6 -1
index 6b89f7eab26c..2436f14ca24a 100644
@@ -89,9 +89,14 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 	skb_push(tx_info->skb, sizeof(*txwi));
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE | (txwi->rate & MT_RXWI_RATE_INDEX);
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST || ep == MT_EP_OUT_HCCA)
+	if (mt76_is_skb_pktid(pid) || ep == MT_EP_OUT_HCCA)
 		qsel = MT_QSEL_MGMT;
 	else
 		qsel = MT_QSEL_EDCA;
Signature · 1 line
2.17.0
maintainer
#4 lore raw

Re: [PATCH v2 3/4] mt76: mt76x02: fix tx status reporting issues

Quoted 21 lines

When the hardware falls back to lower rates for a transmit attempt, only the first status report will show the number of retries correctly. The frames that follow will report the correct final rate, but number of retries set to 0. This can cause the rate control module to vastly underestimate the number of retransmissions per rate.

To fix this, we need to keep track of the initial requested tx rate per packet and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in the packet id (and make it possible to distinguish it from real packet ids).

To do that, reduce the packet id field size by one bit, and use that bit to indicate packet id vs rate.

This change also improves reporting by filling the status rate array with rates from first rate to final rate, taking the same steps as the hardware fallback table. This matters in corner cases like MCS8 on HT, where the fallback target is MCS0, not MCS7.

[...]

drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, · line 170

Quoted 12 lines
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +4 -0
index cf7abd9b7d2e..95c73049a68b 100644
@@ -164,9 +164,14 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	mt76x02_mac_write_txwi(dev, txwi, tx_info->skb, wcid, sta, len);
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE | (txwi->rate & MT_RXWI_RATE_INDEX);

I guess here we should do:

		pid = MT_PACKET_ID_HAS_RATE | (le16_to_cpu(txwi->rate) & MT_RXWI_RATE_INDEX);
Quoted 13 lines
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +2 -1
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST)
+	if (mt76_is_skb_pktid(pid))
 		qsel = MT_QSEL_MGMT;
 
 	tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +0 -0
index 6b89f7eab26c..2436f14ca24a 100644

drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data, · line 95

Quoted 7 lines
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +4 -0
@@ -89,9 +89,14 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 	skb_push(tx_info->skb, sizeof(*txwi));
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE | (txwi->rate & MT_RXWI_RATE_INDEX);

same here

Regards,
Lorenzo

Quoted 11 lines
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +2 -1
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST || ep == MT_EP_OUT_HCCA)
+	if (mt76_is_skb_pktid(pid) || ep == MT_EP_OUT_HCCA)
 		qsel = MT_QSEL_MGMT;
 	else
 		qsel = MT_QSEL_EDCA;
Signature · 1 line
2.17.0
author maintainer
#5 lore raw

PATCH v3 3/4 mt76: mt76x02: fix tx status reporting issues

In reply to Felix Fietkau

When the hardware falls back to lower rates for a transmit attempt, only the first status report will show the number of retries correctly. The frames that follow will report the correct final rate, but number of retries set to 0. This can cause the rate control module to vastly underestimate the number of retransmissions per rate.

To fix this, we need to keep track of the initial requested tx rate per packet and pass it to the status information.
For frames with tx status requested, this is simple: use the rate configured in info->control.rates[0] as reference.
For no-skb tx status information, we have to encode the requested tx rate in the packet id (and make it possible to distinguish it from real packet ids).

To do that, reduce the packet id field size by one bit, and use that bit to indicate packet id vs rate.

This change also improves reporting by filling the status rate array with rates from first rate to final rate, taking the same steps as the hardware fallback table. This matters in corner cases like MCS8 on HT, where the fallback target is MCS0, not MCS7.

---
v3: fix endian issue
v2: fix reporting of non-probing frames with tx status requested

 drivers/net/wireless/mediatek/mt76/mt76.h     |  11 +-
 .../net/wireless/mediatek/mt76/mt76x02_mac.c  | 102 +++++++++++++++---
 .../net/wireless/mediatek/mt76/mt76x02_txrx.c |   8 +-
 .../wireless/mediatek/mt76/mt76x02_usb_core.c |   8 +-
 4 files changed, 109 insertions(+), 20 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76.h +10 -1
index fc4169c83e76..907bec9d5e4c 100644
@@ -258,10 +258,11 @@ struct mt76_rx_tid {
 #define MT_TX_CB_TXS_DONE		BIT(1)
 #define MT_TX_CB_TXS_FAILED		BIT(2)
 
-#define MT_PACKET_ID_MASK		GENMASK(7, 0)
+#define MT_PACKET_ID_MASK		GENMASK(6, 0)
 #define MT_PACKET_ID_NO_ACK		0
 #define MT_PACKET_ID_NO_SKB		1
 #define MT_PACKET_ID_FIRST		2
+#define MT_PACKET_ID_HAS_RATE		BIT(7)
 
 #define MT_TX_STATUS_SKB_TIMEOUT	HZ
 
@@ -689,6 +690,14 @@ static inline void mt76_insert_hdr_pad(struct sk_buff *skb)
 	skb->data[len + 1] = 0;
 }
 
+static inline bool mt76_is_skb_pktid(u8 pktid)
+{
+	if (pktid & MT_PACKET_ID_HAS_RATE)
+		return false;
+
+	return pktid >= MT_PACKET_ID_FIRST;
+}
+
 void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb);
 void mt76_tx(struct mt76_dev *dev, struct ieee80211_sta *sta,
 	     struct mt76_wcid *wcid, struct sk_buff *skb);
drivers/net/wireless/mediatek/mt76/mt76x02_mac.c +85 -17

142 lines not on this page · raw message

drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +7 -1
index cf7abd9b7d2e..7a1164a07ee7 100644
@@ -164,9 +164,15 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	mt76x02_mac_write_txwi(dev, txwi, tx_info->skb, wcid, sta, len);
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE |
+		      (le16_to_cpu(txwi->rate) & MT_RXWI_RATE_INDEX);
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST)
+	if (mt76_is_skb_pktid(pid))
 		qsel = MT_QSEL_MGMT;
 
 	tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +7 -1
index 6b89f7eab26c..47386ca713cc 100644
@@ -89,9 +89,15 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 	skb_push(tx_info->skb, sizeof(*txwi));
 
 	pid = mt76_tx_status_skb_add(mdev, wcid, tx_info->skb);
+
+	/* encode packet rate for no-skb packet id to fix up status reporting */
+	if (pid == MT_PACKET_ID_NO_SKB)
+		pid = MT_PACKET_ID_HAS_RATE |
+		      (le16_to_cpu(txwi->rate) & MT_RXWI_RATE_INDEX);
+
 	txwi->pktid = pid;
 
-	if (pid >= MT_PACKET_ID_FIRST || ep == MT_EP_OUT_HCCA)
+	if (mt76_is_skb_pktid(pid) || ep == MT_EP_OUT_HCCA)
 		qsel = MT_QSEL_MGMT;
 	else
 		qsel = MT_QSEL_EDCA;
Signature · 1 line
2.17.0
author maintainer
#6 lore raw

PATCH 4/4 mt76: mt76x02: fix tx reordering on rate control probing without a-mpdu

In reply to Felix Fietkau

To avoid aggregating rate control probing packets with other traffic, and to ensure that the probing rate gets used, probing packets get assigned a different internal queueing priority.
This causes packets to be transmitted in a different order, which is compensated by the receiver side reordering.
However, if A-MPDU is disabled, this reordering can become visible to upper layers on the receiver side. Disable the priority change if A-MPDU is disabled.

---
 drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c     | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +2 -1
index 95c73049a68b..9f1c4e085380 100644
@@ -154,6 +154,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data;
 	struct mt76x02_txwi *txwi = txwi_ptr;
+	bool ampdu = IEEE80211_SKB_CB(skb)->flags & IEEE80211_TX_CTL_AMPDU;
 	int hdrlen, len, pid, qsel = MT_QSEL_EDCA;
 
 	if (qid == MT_TXQ_PSD && wcid && wcid->idx < 128)
@@ -171,7 +172,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 
 	txwi->pktid = pid;
 
-	if (mt76_is_skb_pktid(pid))
+	if (mt76_is_skb_pktid(pid) && ampdu)
 		qsel = MT_QSEL_MGMT;
 
 	tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +2 -1
index 2436f14ca24a..04bfc923ac71 100644
@@ -79,6 +79,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 	struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
 	int pid, len = tx_info->skb->len, ep = q2ep(mdev->q_tx[qid].q->hw_idx);
 	struct mt76x02_txwi *txwi;
+	bool ampdu = IEEE80211_SKB_CB(skb)->flags & IEEE80211_TX_CTL_AMPDU;
 	enum mt76_qsel qsel;
 	u32 flags;
 
@@ -96,7 +97,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 
 	txwi->pktid = pid;
 
-	if (mt76_is_skb_pktid(pid) || ep == MT_EP_OUT_HCCA)
+	if ((mt76_is_skb_pktid(pid) && ampdu) || ep == MT_EP_OUT_HCCA)
 		qsel = MT_QSEL_MGMT;
 	else
 		qsel = MT_QSEL_EDCA;
Signature · 1 line
2.17.0
author maintainer
#7 lore raw

PATCH v2 4/4 mt76: mt76x02: fix tx reordering on rate control probing without a-mpdu

To avoid aggregating rate control probing packets with other traffic, and to ensure that the probing rate gets used, probing packets get assigned a different internal queueing priority.
This causes packets to be transmitted in a different order, which is compensated by the receiver side reordering.
However, if A-MPDU is disabled, this reordering can become visible to upper layers on the receiver side. Disable the priority change if A-MPDU is disabled.

---
v2: fix compile error

 drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c     | 3 ++-
 drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/net/wireless/mediatek/mt76/mt76x02_txrx.c +2 -1
index 95c73049a68b..82acebb7f1a9 100644
@@ -154,6 +154,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 	struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx_info->skb->data;
 	struct mt76x02_txwi *txwi = txwi_ptr;
+	bool ampdu = IEEE80211_SKB_CB(tx_info->skb)->flags & IEEE80211_TX_CTL_AMPDU;
 	int hdrlen, len, pid, qsel = MT_QSEL_EDCA;
 
 	if (qid == MT_TXQ_PSD && wcid && wcid->idx < 128)
@@ -171,7 +172,7 @@ int mt76x02_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr,
 
 	txwi->pktid = pid;
 
-	if (mt76_is_skb_pktid(pid))
+	if (mt76_is_skb_pktid(pid) && ampdu)
 		qsel = MT_QSEL_MGMT;
 
 	tx_info->info = FIELD_PREP(MT_TXD_INFO_QSEL, qsel) |
drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +2 -1
index 2436f14ca24a..f3696afc1dde 100644
@@ -79,6 +79,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 	struct mt76x02_dev *dev = container_of(mdev, struct mt76x02_dev, mt76);
 	int pid, len = tx_info->skb->len, ep = q2ep(mdev->q_tx[qid].q->hw_idx);
 	struct mt76x02_txwi *txwi;
+	bool ampdu = IEEE80211_SKB_CB(tx_info->skb)->flags & IEEE80211_TX_CTL_AMPDU;
 	enum mt76_qsel qsel;
 	u32 flags;
 
@@ -96,7 +97,7 @@ int mt76x02u_tx_prepare_skb(struct mt76_dev *mdev, void *data,
 
 	txwi->pktid = pid;
 
-	if (mt76_is_skb_pktid(pid) || ep == MT_EP_OUT_HCCA)
+	if ((mt76_is_skb_pktid(pid) && ampdu) || ep == MT_EP_OUT_HCCA)
 		qsel = MT_QSEL_MGMT;
 	else
 		qsel = MT_QSEL_EDCA;
Signature · 1 line
2.17.0
author maintainer
#8 lore raw

PATCH v2 1/4 mt76: mt7603: fix reading target tx power from eeprom

In reply to Felix Fietkau

For the external PA (TSSI OFF) case, the target power needs to be read from a different location in EEPROM

---
v2:
- fix patch prefix
- limit change to mt7603 (mt7628 does not have this eeprom field)

 drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h | 2 ++
 drivers/net/wireless/mediatek/mt76/mt7603/init.c   | 4 ++++
 2 files changed, 6 insertions(+)
drivers/net/wireless/mediatek/mt76/mt7603/eeprom.h +2 -0
index f27b99b7e359..b893facfba48 100644
@@ -69,6 +69,8 @@ enum mt7603_eeprom_field {
 
 	MT_EE_CP_FT_VERSION =			0x0f0,
 
+	MT_EE_TX_POWER_TSSI_OFF =		0x0f2,
+
 	MT_EE_XTAL_FREQ_OFFSET =		0x0f4,
 	MT_EE_XTAL_TRIM_2_COMP =		0x0f5,
 	MT_EE_XTAL_TRIM_3_COMP =		0x0f6,
drivers/net/wireless/mediatek/mt76/mt7603/init.c +4 -0
index 4e269044f8a4..43baad7fd082 100644
@@ -465,9 +465,13 @@ mt7603_init_txpower(struct mt7603_dev *dev,
 	u8 *eeprom = (u8 *)dev->mt76.eeprom.data;
 	int target_power = eeprom[MT_EE_TX_POWER_0_START_2G + 2] & ~BIT(7);
 	u8 *rate_power = &eeprom[MT_EE_TX_POWER_CCK];
+	bool ext_pa = eeprom[MT_EE_NIC_CONF_0 + 1] & BIT(1);
 	int max_offset, cur_offset;
 	int i;
 
+	if (ext_pa && is_mt7603(dev))
+		target_power = eeprom[MT_EE_TX_POWER_TSSI_OFF] & ~BIT(7);
+
 	if (target_power & BIT(6))
 		target_power = -(target_power & GENMASK(5, 0));
 
Signature · 1 line
2.17.0