blob: a7bd45318a7fdb19e18fe2f27c45dedb9f7c5396 [file] [log] [blame]
developer05f3b2b2024-08-19 19:17:34 +08001From 15d44f1c050949ec23da85167bef1163b4a8ddf2 Mon Sep 17 00:00:00 2001
2From: Benjamin Lin <benjamin-jw.lin@mediatek.com>
3Date: Fri, 2 Aug 2024 14:22:45 +0800
4Subject: [PATCH] wifi: mt76: mt7915: add PID to only report data-frame TX rate
5
6According to definition of NL80211_STA_INFO_RX_BITRATE, mac80211 implicitly only expects data-frame rates to be reported.
7In MT76, TX rate is updated using TXS, and PID in TXS is possibly useful for distinguishing between data and management frames.
8Originally, MT_PACKET_ID_NO_SKB was used for data frames (when WED is disabled) and some management frames.
9In order to differentiate between them, MT_PACKET_ID_SW_DATA is added.
10And TX rate is updated only when TXS is associated with either SW-path or HW-path data frame.
11
12Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com>
13---
14 mt76.h | 3 ++-
15 mt76_connac.h | 2 +-
16 mt76_connac_mac.c | 7 +++++--
17 mt7915/mac.c | 2 +-
18 tx.c | 9 ++++-----
19 5 files changed, 13 insertions(+), 10 deletions(-)
20
21diff --git a/mt76.h b/mt76.h
22index 05ee568..bdc9a9b 100644
23--- a/mt76.h
24+++ b/mt76.h
25@@ -443,7 +443,8 @@ struct mt76_rx_tid {
26 #define MT_PACKET_ID_NO_ACK 0
27 #define MT_PACKET_ID_NO_SKB 1
28 #define MT_PACKET_ID_WED 2
29-#define MT_PACKET_ID_FIRST 3
30+#define MT_PACKET_ID_SW_DATA 3
31+#define MT_PACKET_ID_FIRST 4
32 #define MT_PACKET_ID_HAS_RATE BIT(7)
33 /* This is timer for when to give up when waiting for TXS callback,
34 * with starting time being the time at which the DMA_DONE callback
35diff --git a/mt76_connac.h b/mt76_connac.h
36index 5028e49..355b506 100644
37--- a/mt76_connac.h
38+++ b/mt76_connac.h
39@@ -436,7 +436,7 @@ u16 mt76_connac2_mac_tx_rate_val(struct mt76_phy *mphy,
40 struct ieee80211_vif *vif,
41 bool beacon, bool mcast);
42 bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
43- __le32 *txs_data);
44+ int pid, __le32 *txs_data);
45 bool mt76_connac2_mac_add_txs_skb(struct mt76_dev *dev, struct mt76_wcid *wcid,
46 int pid, __le32 *txs_data);
47 void mt76_connac2_mac_decode_he_radiotap(struct mt76_dev *dev,
48diff --git a/mt76_connac_mac.c b/mt76_connac_mac.c
49index 170ef36..4d24cc6 100644
50--- a/mt76_connac_mac.c
51+++ b/mt76_connac_mac.c
52@@ -594,7 +594,7 @@ void mt76_connac2_mac_write_txwi(struct mt76_dev *dev, __le32 *txwi,
53 EXPORT_SYMBOL_GPL(mt76_connac2_mac_write_txwi);
54
55 bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
56- __le32 *txs_data)
57+ int pid, __le32 *txs_data)
58 {
59 struct mt76_sta_stats *stats = &wcid->stats;
60 struct ieee80211_supported_band *sband;
61@@ -628,6 +628,9 @@ bool mt76_connac2_mac_fill_txs(struct mt76_dev *dev, struct mt76_wcid *wcid,
62 }
63 }
64
65+ if (pid != MT_PACKET_ID_WED && pid != MT_PACKET_ID_SW_DATA)
66+ return true;
67+
68 txrate = FIELD_GET(MT_TXS0_TX_RATE, txs);
69
70 rate.mcs = FIELD_GET(MT_TX_RATE_IDX, txrate);
71@@ -737,7 +740,7 @@ bool mt76_connac2_mac_add_txs_skb(struct mt76_dev *dev, struct mt76_wcid *wcid,
72 !!(info->flags & IEEE80211_TX_STAT_ACK);
73 info->status.rates[0].idx = -1;
74
75- mt76_connac2_mac_fill_txs(dev, wcid, txs_data);
76+ mt76_connac2_mac_fill_txs(dev, wcid, pid, txs_data);
77 mt76_tx_status_skb_done(dev, skb, &list);
78 }
79 mt76_tx_status_unlock(dev, &list);
80diff --git a/mt7915/mac.c b/mt7915/mac.c
81index 1c5ab41..9c56f10 100644
82--- a/mt7915/mac.c
83+++ b/mt7915/mac.c
84@@ -1023,7 +1023,7 @@ static void mt7915_mac_add_txs(struct mt7915_dev *dev, void *data)
85 msta = container_of(wcid, struct mt7915_sta, wcid);
86
87 if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) == MT_TXS_PPDU_FMT)
88- mt76_connac2_mac_fill_txs(&dev->mt76, wcid, txs_data);
89+ mt76_connac2_mac_fill_txs(&dev->mt76, wcid, pid, txs_data);
90 else
91 mt76_connac2_mac_add_txs_skb(&dev->mt76, wcid, pid, txs_data);
92
93diff --git a/tx.c b/tx.c
94index 0fdf7d8..d6054ab 100644
95--- a/tx.c
96+++ b/tx.c
97@@ -136,11 +136,10 @@ mt76_tx_status_skb_add(struct mt76_dev *dev, struct mt76_wcid *wcid,
98
99 if (!(info->flags & (IEEE80211_TX_CTL_REQ_TX_STATUS |
100 IEEE80211_TX_CTL_RATE_CTRL_PROBE))) {
101- if (mtk_wed_device_active(&dev->mmio.wed) &&
102- ((info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP) ||
103- ieee80211_is_data(hdr->frame_control)))
104- return MT_PACKET_ID_WED;
105-
106+ if (info->flags & IEEE80211_TX_CTL_HW_80211_ENCAP ||
107+ ieee80211_is_data(hdr->frame_control))
108+ return mtk_wed_device_active(&dev->mmio.wed) ? MT_PACKET_ID_WED
109+ : MT_PACKET_ID_SW_DATA;
110 return MT_PACKET_ID_NO_SKB;
111 }
112
113--
1142.45.2
115