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