developer | c2cfe0f | 2023-09-22 04:11:09 +0800 | [diff] [blame] | 1 | From fd9cc614274b3bfbc1604c2a93cac2a1169e3518 Mon Sep 17 00:00:00 2001 |
| 2 | From: Yi-Chia Hsieh <yi-chia.hsieh@mediatek.com> |
| 3 | Date: Wed, 28 Jun 2023 07:51:38 +0800 |
| 4 | Subject: [PATCH 16/22] wifi: mt76: mt7996: get tx_retries and tx_failed from |
| 5 | txfree for both wed on and wed off |
| 6 | |
| 7 | --- |
| 8 | mt76_connac3_mac.h | 4 ++-- |
| 9 | mt7996/mac.c | 21 ++++++++++++++++----- |
| 10 | mt7996/main.c | 6 ++++++ |
| 11 | 3 files changed, 24 insertions(+), 7 deletions(-) |
| 12 | |
| 13 | diff --git a/mt76_connac3_mac.h b/mt76_connac3_mac.h |
| 14 | index df6b02af9..20a2fe931 100644 |
| 15 | --- a/mt76_connac3_mac.h |
| 16 | +++ b/mt76_connac3_mac.h |
| 17 | @@ -272,11 +272,11 @@ enum tx_mgnt_type { |
| 18 | #define MT_TXFREE0_MSDU_CNT GENMASK(25, 16) |
| 19 | #define MT_TXFREE0_RX_BYTE GENMASK(15, 0) |
| 20 | |
| 21 | -#define MT_TXFREE1_VER GENMASK(18, 16) |
| 22 | +#define MT_TXFREE1_VER GENMASK(19, 16) |
| 23 | |
| 24 | #define MT_TXFREE_INFO_PAIR BIT(31) |
| 25 | #define MT_TXFREE_INFO_HEADER BIT(30) |
| 26 | -#define MT_TXFREE_INFO_WLAN_ID GENMASK(23, 12) |
| 27 | +#define MT_TXFREE_INFO_MLD_ID GENMASK(23, 12) |
| 28 | #define MT_TXFREE_INFO_MSDU_ID GENMASK(14, 0) |
| 29 | #define MT_TXFREE_INFO_COUNT GENMASK(27, 24) |
| 30 | #define MT_TXFREE_INFO_STAT GENMASK(29, 28) |
| 31 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
| 32 | index 0aabded63..8f3742c4e 100644 |
| 33 | --- a/mt7996/mac.c |
| 34 | +++ b/mt7996/mac.c |
| 35 | @@ -1065,6 +1065,7 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
| 36 | struct mt76_phy *phy3 = mdev->phys[MT_BAND2]; |
| 37 | struct mt76_txwi_cache *txwi; |
| 38 | struct ieee80211_sta *sta = NULL; |
| 39 | + struct mt76_wcid *wcid; |
| 40 | LIST_HEAD(free_list); |
| 41 | struct sk_buff *skb, *tmp; |
| 42 | void *end = data + len; |
| 43 | @@ -1083,7 +1084,7 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
| 44 | mt76_queue_tx_cleanup(dev, phy3->q_tx[MT_TXQ_BE], false); |
| 45 | } |
| 46 | |
| 47 | - if (WARN_ON_ONCE(le32_get_bits(tx_free[1], MT_TXFREE1_VER) < 4)) |
| 48 | + if (WARN_ON_ONCE(le32_get_bits(tx_free[1], MT_TXFREE1_VER) < 5)) |
| 49 | return; |
| 50 | |
| 51 | total = le32_get_bits(tx_free[0], MT_TXFREE0_MSDU_CNT); |
| 52 | @@ -1099,10 +1100,9 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
| 53 | info = le32_to_cpu(*cur_info); |
| 54 | if (info & MT_TXFREE_INFO_PAIR) { |
| 55 | struct mt7996_sta *msta; |
| 56 | - struct mt76_wcid *wcid; |
| 57 | u16 idx; |
| 58 | |
| 59 | - idx = FIELD_GET(MT_TXFREE_INFO_WLAN_ID, info); |
| 60 | + idx = FIELD_GET(MT_TXFREE_INFO_MLD_ID, info); |
| 61 | wcid = rcu_dereference(dev->mt76.wcid[idx]); |
| 62 | sta = wcid_to_sta(wcid); |
| 63 | if (!sta) |
| 64 | @@ -1115,10 +1115,21 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
| 65 | &mdev->sta_poll_list); |
| 66 | spin_unlock_bh(&mdev->sta_poll_lock); |
| 67 | continue; |
| 68 | - } |
| 69 | + } else if (info & MT_TXFREE_INFO_HEADER) { |
| 70 | + u32 tx_retries = 0, tx_failed = 0; |
| 71 | + |
| 72 | + if (!wcid) |
| 73 | + continue; |
| 74 | + |
| 75 | + tx_retries = |
| 76 | + FIELD_GET(MT_TXFREE_INFO_COUNT, info) - 1; |
| 77 | + tx_failed = tx_retries + |
| 78 | + !!FIELD_GET(MT_TXFREE_INFO_STAT, info); |
| 79 | |
| 80 | - if (info & MT_TXFREE_INFO_HEADER) |
| 81 | + wcid->stats.tx_retries += tx_retries; |
| 82 | + wcid->stats.tx_failed += tx_failed; |
| 83 | continue; |
| 84 | + } |
| 85 | |
| 86 | for (i = 0; i < 2; i++) { |
| 87 | msdu = (info >> (15 * i)) & MT_TXFREE_INFO_MSDU_ID; |
| 88 | diff --git a/mt7996/main.c b/mt7996/main.c |
| 89 | index d8fd8191c..32d975c63 100644 |
| 90 | --- a/mt7996/main.c |
| 91 | +++ b/mt7996/main.c |
| 92 | @@ -997,6 +997,12 @@ static void mt7996_sta_statistics(struct ieee80211_hw *hw, |
| 93 | sinfo->txrate.flags = txrate->flags; |
| 94 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BITRATE); |
| 95 | |
| 96 | + sinfo->tx_failed = msta->wcid.stats.tx_failed; |
| 97 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_FAILED); |
| 98 | + |
| 99 | + sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 100 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 101 | + |
| 102 | sinfo->ack_signal = (s8)msta->ack_signal; |
| 103 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_ACK_SIGNAL); |
| 104 | |
| 105 | -- |
| 106 | 2.39.2 |
| 107 | |