developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 1 | From 7fad725b238b5b94403b9c4457aa0c3c0acdd576 Mon Sep 17 00:00:00 2001 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Tue, 17 Jan 2023 21:15:00 +0800 |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 4 | Subject: [PATCH 3009/3012] wifi: mt76: mt7915: get tx retries from tx free |
developer | 4f0d84b | 2023-03-03 14:21:44 +0800 | [diff] [blame] | 5 | done event for sw path |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 8 | mt76_connac2_mac.h | 2 ++ |
| 9 | mt7915/mac.c | 14 +++++++++++--- |
| 10 | mt7915/mac.h | 3 ++- |
| 11 | mt7915/main.c | 6 +++--- |
| 12 | 4 files changed, 18 insertions(+), 7 deletions(-) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 13 | |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 14 | diff --git a/mt76_connac2_mac.h b/mt76_connac2_mac.h |
| 15 | index e7a4019..e6170ea 100644 |
| 16 | --- a/mt76_connac2_mac.h |
| 17 | +++ b/mt76_connac2_mac.h |
| 18 | @@ -38,6 +38,8 @@ enum { |
| 19 | /* 0: success, others: dropped */ |
| 20 | #define MT_TX_FREE_STATUS GENMASK(14, 13) |
| 21 | #define MT_TX_FREE_MSDU_ID GENMASK(30, 16) |
| 22 | +#define MT_TX_FREE_TX_COUNT GENMASK(12, 0) |
| 23 | +#define MT_TX_FREE_TX_COUNT_V3 GENMASK(27, 24) |
| 24 | #define MT_TX_FREE_PAIR BIT(31) |
| 25 | /* will support this field in further revision */ |
| 26 | #define MT_TX_FREE_RATE GENMASK(13, 0) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 27 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 28 | index 26b5e15..0994ce1 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 29 | --- a/mt7915/mac.c |
| 30 | +++ b/mt7915/mac.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 31 | @@ -981,6 +981,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 32 | struct mt76_dev *mdev = &dev->mt76; |
| 33 | struct mt76_txwi_cache *txwi; |
| 34 | struct ieee80211_sta *sta = NULL; |
| 35 | + struct mt76_wcid *wcid = NULL; |
| 36 | LIST_HEAD(free_list); |
| 37 | void *end = data + len; |
| 38 | bool v3, wake = false; |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 39 | @@ -995,7 +996,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 40 | v3 = (FIELD_GET(MT_TX_FREE_VER, txd) == 0x4); |
| 41 | |
| 42 | for (cur_info = tx_info; count < total; cur_info++) { |
| 43 | - u32 msdu, info; |
| 44 | + u32 msdu, info, retries = 0; |
| 45 | u8 i; |
| 46 | |
| 47 | if (WARN_ON_ONCE((void *)cur_info >= end)) |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 48 | @@ -1008,7 +1009,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 49 | info = le32_to_cpu(*cur_info); |
| 50 | if (info & MT_TX_FREE_PAIR) { |
| 51 | struct mt7915_sta *msta; |
| 52 | - struct mt76_wcid *wcid = NULL; |
developer | 5bea732 | 2023-04-13 18:50:55 +0800 | [diff] [blame] | 53 | struct mt7915_phy *phy; |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 54 | u16 idx; |
| 55 | |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 56 | @@ -1033,7 +1033,15 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 57 | continue; |
| 58 | } |
| 59 | |
| 60 | - if (v3 && (info & MT_TX_FREE_MPDU_HEADER)) |
| 61 | + if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3)) |
| 62 | + retries = u32_get_bits(info, MT_TX_FREE_TX_COUNT_V3) - 1; |
| 63 | + else if (!v3 && (info & MT_TX_FREE_MPDU_HEADER)) |
| 64 | + retries = u32_get_bits(info, MT_TX_FREE_TX_COUNT) - 1; |
| 65 | + |
developer | d1877ca | 2023-02-23 11:31:03 +0800 | [diff] [blame] | 66 | + if (!mtk_wed_device_active(&mdev->mmio.wed) && wcid) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 67 | + wcid->stats.tx_retries += retries; |
| 68 | + |
| 69 | + if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3)) |
| 70 | continue; |
| 71 | |
| 72 | for (i = 0; i < 1 + v3; i++) { |
| 73 | diff --git a/mt7915/mac.h b/mt7915/mac.h |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 74 | index ce94f87..859298d 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 75 | --- a/mt7915/mac.h |
| 76 | +++ b/mt7915/mac.h |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 77 | @@ -9,7 +9,8 @@ |
| 78 | #define MT_TX_FREE_VER GENMASK(18, 16) |
| 79 | #define MT_TX_FREE_MSDU_CNT_V0 GENMASK(6, 0) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 80 | /* 0: success, others: dropped */ |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 81 | -#define MT_TX_FREE_MPDU_HEADER BIT(30) |
| 82 | +#define MT_TX_FREE_MPDU_HEADER BIT(15) |
| 83 | +#define MT_TX_FREE_MPDU_HEADER_V3 BIT(30) |
| 84 | #define MT_TX_FREE_MSDU_ID_V3 GENMASK(14, 0) |
| 85 | |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 86 | #define MT_TXS5_F0_FINAL_MPDU BIT(31) |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 87 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 88 | index c377ef2..f836aa8 100644 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 89 | --- a/mt7915/main.c |
| 90 | +++ b/mt7915/main.c |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 91 | @@ -1116,9 +1116,6 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 92 | sinfo->tx_bytes = msta->wcid.stats.tx_bytes; |
| 93 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); |
| 94 | |
| 95 | - sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 96 | - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 97 | - |
| 98 | if (mtk_wed_get_rx_capa(&phy->dev->mt76.mmio.wed)) { |
| 99 | sinfo->rx_bytes = msta->wcid.stats.rx_bytes; |
| 100 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); |
developer | bbd45e1 | 2023-05-19 08:22:06 +0800 | [diff] [blame] | 101 | @@ -1128,6 +1125,9 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 102 | } |
| 103 | } |
| 104 | |
| 105 | + sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 106 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 107 | + |
| 108 | if (!mt7915_mcu_get_tx_stat_wa(phy->dev, msta->wcid.idx)) { |
| 109 | sinfo->tx_packets = msta->wcid.stats.tx_packets; |
| 110 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); |
| 111 | -- |
developer | 2324aa2 | 2023-04-12 11:30:15 +0800 | [diff] [blame] | 112 | 2.18.0 |
developer | 33554a2 | 2023-01-30 14:11:29 +0800 | [diff] [blame] | 113 | |