blob: 6505422103ff55a4528b71b5c01a02f9f2abbfbc [file] [log] [blame]
From 85c7ec658b8ea1ee4ca7525f21c28d2f456e0b95 Mon Sep 17 00:00:00 2001
From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com>
Date: Wed, 28 Jun 2023 08:34:21 +0800
Subject: [PATCH 19/98] wifi: mt76: mt7996: enable PPDU-TxS to host
Enable PPDU-TxS by default no matter WED on or WED off
PPDU-TxS is also capable of getting tx_bytes and tx_retries,
but we'll get that from mcu command and TxFree instead.
---
mt76_connac3_mac.h | 22 +++++++++++++++++++++-
mt7996/init.c | 5 +++++
mt7996/mac.c | 45 +++++++++++++++++++++++++++------------------
mt7996/regs.h | 7 +++++++
4 files changed, 60 insertions(+), 19 deletions(-)
diff --git a/mt76_connac3_mac.h b/mt76_connac3_mac.h
index 20a2fe9..7402de2 100644
--- a/mt76_connac3_mac.h
+++ b/mt76_connac3_mac.h
@@ -281,6 +281,12 @@ enum tx_mgnt_type {
#define MT_TXFREE_INFO_COUNT GENMASK(27, 24)
#define MT_TXFREE_INFO_STAT GENMASK(29, 28)
+enum {
+ MT_TXS_MPDU_FM0,
+ MT_TXS_MPDU_FM1,
+ MT_TXS_PPDU_FM
+};
+
#define MT_TXS0_BW GENMASK(31, 29)
#define MT_TXS0_TID GENMASK(28, 26)
#define MT_TXS0_AMPDU BIT(25)
@@ -306,7 +312,7 @@ enum tx_mgnt_type {
#define MT_TXS2_BF_STATUS GENMASK(31, 30)
#define MT_TXS2_BAND GENMASK(29, 28)
-#define MT_TXS2_WCID GENMASK(27, 16)
+#define MT_TXS2_MLD_ID GENMASK(27, 16)
#define MT_TXS2_TX_DELAY GENMASK(15, 0)
#define MT_TXS3_PID GENMASK(31, 24)
@@ -318,6 +324,7 @@ enum tx_mgnt_type {
#define MT_TXS4_TIMESTAMP GENMASK(31, 0)
+/* MPDU based TXS */
#define MT_TXS5_F0_FINAL_MPDU BIT(31)
#define MT_TXS5_F0_QOS BIT(30)
#define MT_TXS5_F0_TX_COUNT GENMASK(29, 25)
@@ -339,4 +346,17 @@ enum tx_mgnt_type {
#define MT_TXS7_F1_MPDU_RETRY_COUNT GENMASK(31, 24)
#define MT_TXS7_F1_MPDU_RETRY_BYTES GENMASK(23, 0)
+/* PPDU based TXS */
+#define MT_TXS5_MPDU_TX_CNT GENMASK(30, 20)
+#define MT_TXS5_MPDU_TX_BYTE_SCALE BIT(15)
+#define MT_TXS5_MPDU_TX_BYTE GENMASK(14, 0)
+
+#define MT_TXS6_MPDU_FAIL_CNT GENMASK(30, 20)
+#define MT_TXS6_MPDU_FAIL_BYTE_SCALE BIT(15)
+#define MT_TXS6_MPDU_FAIL_BYTE GENMASK(14, 0)
+
+#define MT_TXS7_MPDU_RETRY_CNT GENMASK(30, 20)
+#define MT_TXS7_MPDU_RETRY_BYTE_SCALE BIT(15)
+#define MT_TXS7_MPDU_RETRY_BYTE GENMASK(14, 0)
+
#endif /* __MT76_CONNAC3_MAC_H */
diff --git a/mt7996/init.c b/mt7996/init.c
index 17a4abd..3656b89 100644
--- a/mt7996/init.c
+++ b/mt7996/init.c
@@ -456,6 +456,11 @@ mt7996_mac_init_band(struct mt7996_dev *dev, u8 band)
set = FIELD_PREP(MT_WTBLOFF_RSCR_RCPI_MODE, 0) |
FIELD_PREP(MT_WTBLOFF_RSCR_RCPI_PARAM, 0x3);
mt76_rmw(dev, MT_WTBLOFF_RSCR(band), mask, set);
+
+ /* MT_TXD5_TX_STATUS_HOST (MPDU format) has higher priority than
+ * MT_AGG_ACR_PPDU_TXS2H (PPDU format) even though ACR bit is set.
+ */
+ mt76_set(dev, MT_AGG_ACR4(band), MT_AGG_ACR_PPDU_TXS2H);
}
static void mt7996_mac_init_basic_rates(struct mt7996_dev *dev)
diff --git a/mt7996/mac.c b/mt7996/mac.c
index 4828f10..7512147 100644
--- a/mt7996/mac.c
+++ b/mt7996/mac.c
@@ -1227,22 +1227,35 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
bool cck = false;
u32 txrate, txs, mode, stbc;
+ txs = le32_to_cpu(txs_data[0]);
+
mt76_tx_status_lock(mdev, &list);
skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list);
- if (!skb)
- goto out_no_skb;
- txs = le32_to_cpu(txs_data[0]);
+ if (skb) {
+ info = IEEE80211_SKB_CB(skb);
+ if (!(txs & MT_TXS0_ACK_ERROR_MASK))
+ info->flags |= IEEE80211_TX_STAT_ACK;
- info = IEEE80211_SKB_CB(skb);
- if (!(txs & MT_TXS0_ACK_ERROR_MASK))
- info->flags |= IEEE80211_TX_STAT_ACK;
+ info->status.ampdu_len = 1;
+ info->status.ampdu_ack_len = !!(info->flags &
+ IEEE80211_TX_STAT_ACK);
+
+ info->status.rates[0].idx = -1;
+ }
- info->status.ampdu_len = 1;
- info->status.ampdu_ack_len = !!(info->flags &
- IEEE80211_TX_STAT_ACK);
+ /* PPDU based reporting */
+ if (FIELD_GET(MT_TXS0_TXS_FORMAT,txs) == MT_TXS_PPDU_FM) {
+ if (wcid->sta) {
+ struct ieee80211_sta *sta;
+ u8 tid;
- info->status.rates[0].idx = -1;
+ sta = container_of((void *)wcid, struct ieee80211_sta,
+ drv_priv);
+ tid = FIELD_GET(MT_TXS0_TID, txs);
+ ieee80211_refresh_tx_agg_session_timer(sta, tid);
+ }
+ }
txrate = FIELD_GET(MT_TXS0_TX_RATE, txs);
@@ -1342,9 +1355,8 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid,
wcid->rate = rate;
out:
- mt76_tx_status_skb_done(mdev, skb, &list);
-
-out_no_skb:
+ if (skb)
+ mt76_tx_status_skb_done(mdev, skb, &list);
mt76_tx_status_unlock(mdev, &list);
return !!skb;
@@ -1358,13 +1370,10 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data)
u16 wcidx;
u8 pid;
- if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) > 1)
- return;
-
- wcidx = le32_get_bits(txs_data[2], MT_TXS2_WCID);
+ wcidx = le32_get_bits(txs_data[2], MT_TXS2_MLD_ID);
pid = le32_get_bits(txs_data[3], MT_TXS3_PID);
- if (pid < MT_PACKET_ID_FIRST)
+ if (pid < MT_PACKET_ID_WED)
return;
if (wcidx >= mt7996_wtbl_size(dev))
diff --git a/mt7996/regs.h b/mt7996/regs.h
index bd0eb51..865e005 100644
--- a/mt7996/regs.h
+++ b/mt7996/regs.h
@@ -275,6 +275,13 @@ enum base_rev {
FIELD_PREP(MT_WTBL_LMAC_ID, _id) | \
FIELD_PREP(MT_WTBL_LMAC_DW, _dw))
+/* AGG: band 0(0x820e2000), band 1(0x820f2000), band 2(0x830e2000) */
+#define MT_WF_AGG_BASE(_band) __BASE(WF_AGG_BASE, (_band))
+#define MT_WF_AGG(_band, ofs) (MT_WF_AGG_BASE(_band) + (ofs))
+
+#define MT_AGG_ACR4(_band) MT_WF_AGG(_band, 0x3c)
+#define MT_AGG_ACR_PPDU_TXS2H BIT(1)
+
/* ARB: band 0(0x820e3000), band 1(0x820f3000), band 2(0x830e3000) */
#define MT_WF_ARB_BASE(_band) __BASE(WF_ARB_BASE, (_band))
#define MT_WF_ARB(_band, ofs) (MT_WF_ARB_BASE(_band) + (ofs))
--
2.18.0