blob: a7bd45318a7fdb19e18fe2f27c45dedb9f7c5396 [file] [log] [blame]
From 15d44f1c050949ec23da85167bef1163b4a8ddf2 Mon Sep 17 00:00:00 2001
From: Benjamin Lin <benjamin-jw.lin@mediatek.com>
Date: Fri, 2 Aug 2024 14:22:45 +0800
Subject: [PATCH] wifi: mt76: mt7915: add PID to only report data-frame TX rate
According to definition of NL80211_STA_INFO_RX_BITRATE, mac80211 implicitly only expects data-frame rates to be reported.
In MT76, TX rate is updated using TXS, and PID in TXS is possibly useful for distinguishing between data and management frames.
Originally, MT_PACKET_ID_NO_SKB was used for data frames (when WED is disabled) and some management frames.
In order to differentiate between them, MT_PACKET_ID_SW_DATA is added.
And TX rate is updated only when TXS is associated with either SW-path or HW-path data frame.
Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
---
mt76.h | 3 ++-
mt76_connac.h | 2 +-
mt76_connac_mac.c | 7 +++++--
mt7915/mac.c | 2 +-
tx.c | 9 ++++-----
5 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/mt76.h b/mt76.h
index 05ee568..bdc9a9b 100644
--- a/mt76.h
+++ b/mt76.h
@@ -443,7 +443,8 @@ struct mt76_rx_tid {
#define MT_PACKET_ID_NO_ACK 0
#define MT_PACKET_ID_NO_SKB 1
#define MT_PACKET_ID_WED 2
-#define MT_PACKET_ID_FIRST 3
+#define MT_PACKET_ID_SW_DATA 3
+#define MT_PACKET_ID_FIRST 4
#define MT_PACKET_ID_HAS_RATE BIT(7)
/* This is timer for when to give up when waiting for TXS callback,
* with starting time being the time at which the DMA_DONE callback
diff --git a/mt76_connac.h b/mt76_connac.h
index 5028e49..355b506 100644
--- a/mt76_connac.h
+++ b/mt76_connac.h
@@ -436,7 +436,7 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
struct ieee80211_vif *vif,
bool beacon, bool mcast);
bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
- __le32 *txs_data);
+ int pid, __le32 *txs_data);
bool mt76_connac2_mac_add_txs_skb(struct mt76_dev *dev, struct mt76_wcid *wcid,
int pid, __le32 *txs_data);
void mt76_connac2_mac_decode_he_radiotap(struct mt76_dev *dev,
diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c
index 170ef36..4d24cc6 100644
--- a/mt76_connac_mac.c
+++ b/mt76_connac_mac.c
@@ -594,7 +594,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi);
bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
- __le32 *txs_data)
+ int pid, __le32 *txs_data)
{
struct mt76_sta_stats *stats = &wcid->stats;
struct ieee80211_supported_band *sband;
@@ -628,6 +628,9 @@ bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
}
}
+ if (pid != MT_PACKET_ID_WED && pid != MT_PACKET_ID_SW_DATA)
+ return true;
+
txrate = FIELD_GET(MT_TXS0_TX_RATE, txs);
rate.mcs = FIELD_GET(MT_TX_RATE_IDX, txrate);
@@ -737,7 +740,7 @@ bool mt76_connac2_mac_add_txs_skb(struct mt76_dev *dev, struct mt76_wcid *wcid,
!!(info->flags & IEEE80211_TX_STAT_ACK);
info->status.rates[0].idx = -1;
- mt76_connac2_mac_fill_txs(dev, wcid, txs_data);
+ mt76_connac2_mac_fill_txs(dev, wcid, pid, txs_data);
mt76_tx_status_skb_done(dev, skb, &list);
}
mt76_tx_status_unlock(dev, &list);
diff --git a/mt7915/mac.c b/mt7915/mac.c
index 1c5ab41..9c56f10 100644
--- a/mt7915/mac.c
+++ b/mt7915/mac.c
@@ -1023,7 +1023,7 @@ static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data)
msta = container_of(wcid, struct mt7915_sta, wcid);
if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) == MT_TXS_PPDU_FMT)
- mt76_connac2_mac_fill_txs(&dev->mt76, wcid, txs_data);
+ mt76_connac2_mac_fill_txs(&dev->mt76, wcid, pid, txs_data);
else
mt76_connac2_mac_add_txs_skb(&dev->mt76, wcid, pid, txs_data);
diff --git a/tx.c b/tx.c
index 0fdf7d8..d6054ab 100644
--- a/tx.c
+++ b/tx.c
@@ -136,11 +136,10 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
IEEE80211_TX_CTL_RATE_CTRL_PROBE))) {
- if (mtk_wed_device_active(&dev->mmio.wed) &&
- ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) ||
- ieee80211_is_data(hdr->frame_control)))
- return MT_PACKET_ID_WED;
-
+ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP ||
+ ieee80211_is_data(hdr->frame_control))
+ return mtk_wed_device_active(&dev->mmio.wed) ? MT_PACKET_ID_WED
+ : MT_PACKET_ID_SW_DATA;
return MT_PACKET_ID_NO_SKB;
}
--
2.45.2