[PATCH v2] wifi: mt76: connac: honour injected HT/VHT rate and bandwidth
Aaron Beckendorf
albecken at mtu.edu
Wed Nov 4 06:26:22 PST 2026
On connac2 parts the fixed-rate TXD path uses the basic rate from
mt76_connac2_mac_tx_rate_val() and ignores the rate carried in an
injected frame's radiotap header, so monitor-mode injection always goes
out at a legacy 20 MHz rate and cannot choose the modulation or channel
width.
When info->control.rates[0] contains an HT or VHT MCS, set the TXD6 rate
from it instead: mode (HT/VHT), MCS, NSS, and the channel width from the
rate flags; for HT the whole MCS index is used, as mt7615 does. Legacy
injection and the normal (non-fixed-rate) data path are unchanged.
This makes 20/40/80 MHz HT/VHT injection work on mt7921u. mt7925 and
mt7996 build their own TX descriptor and are not affected.
Signed-off-by: Aaron Beckendorf <albecken at mtu.edu>
---
v2:
- HT: use the whole MCS index in the rate index field; the v1 mask
(tr->idx & 0x7) dropped the second spatial stream, so HT MCS 8-15
went out as 0-7. Caught in review by Devin <lucid_duck at justthetip.ca>.
- Also set the 160 MHz width; the shared mt76_connac2_mac_write_txwi()
is used by the 160-capable mt7915 family and mt7922, matching mt7615.
- Drop the mt7925u claim; mt7925 has its own mt7925_mac_write_txwi()
and never reaches this path.
.../wireless/mediatek/mt76/mt76_connac_mac.c | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
index 8481eac8d783..e62d39cb1ba5 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
+++ b/drivers/net/wireless/mediatek/mt76/mt76_connac_mac.c
@@ -602,6 +602,43 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
u32 val = MT_TXD6_FIXED_BW;
u8 spe_idx = mt76_connac_spe_idx(mphy->antenna_mask);
+ /* Honour an injected HT/VHT rate and bandwidth from radiotap:
+ * connac otherwise transmits at the basic rate picked by
+ * mt76_connac2_mac_tx_rate_val(), so monitor injection cannot
+ * select the modulation or channel width.
+ */
+ if (info->control.rates[0].idx >= 0 &&
+ (info->control.rates[0].flags &
+ (IEEE80211_TX_RC_MCS | IEEE80211_TX_RC_VHT_MCS))) {
+ struct ieee80211_tx_rate *tr = &info->control.rates[0];
+ u8 mode, mcs, nss = 0, bw = 0;
+
+ if (tr->flags & IEEE80211_TX_RC_VHT_MCS) {
+ mode = MT_PHY_TYPE_VHT;
+ mcs = ieee80211_rate_get_vht_mcs(tr);
+ nss = ieee80211_rate_get_vht_nss(tr) - 1;
+ } else {
+ mode = MT_PHY_TYPE_HT;
+ /* the HT rate index encodes NSS in its upper
+ * bits, so pass it whole, as mt7615 does
+ */
+ mcs = tr->idx;
+ nss = tr->idx >> 3;
+ }
+
+ if (tr->flags & IEEE80211_TX_RC_80_MHZ_WIDTH)
+ bw = 2;
+ else if (tr->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
+ bw = 1;
+ else if (tr->flags & IEEE80211_TX_RC_160_MHZ_WIDTH)
+ bw = 3;
+
+ rate = FIELD_PREP(MT_TX_RATE_MODE, mode) |
+ FIELD_PREP(MT_TX_RATE_IDX, mcs) |
+ FIELD_PREP(MT_TX_RATE_NSS, nss);
+ val = MT_TXD6_FIXED_BW | FIELD_PREP(MT_TXD6_BW, bw);
+ }
+
/* hardware won't add HTC for mgmt/ctrl frame */
txwi[2] |= cpu_to_le32(MT_TXD2_HTC_VLD);
base-commit: 991a73f4909f1348ffb4b38765cdb522a775e4c2
--
2.53.0
More information about the Linux-mediatek
mailing list