developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 1 | From d3a40cf6ad567d4fb50d65cb6960d0672a38abe7 Mon Sep 17 00:00:00 2001 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Tue, 17 Jan 2023 21:15:00 +0800 |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 3010/3013] wifi: mt76: mt7915: get tx retries from tx free |
developer | f8871e8 | 2023-03-08 17:22:32 +0800 | [diff] [blame] | 5 | done event for sw path |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
| 8 | mt7915/mac.c | 14 +++++++++++--- |
| 9 | mt7915/mac.h | 5 ++++- |
| 10 | mt7915/main.c | 6 +++--- |
| 11 | 3 files changed, 18 insertions(+), 7 deletions(-) |
| 12 | |
| 13 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 14 | index d7b0e63..7690cc3 100644 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 15 | --- a/mt7915/mac.c |
| 16 | +++ b/mt7915/mac.c |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 17 | @@ -985,6 +985,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 18 | struct mt76_dev *mdev = &dev->mt76; |
| 19 | struct mt76_txwi_cache *txwi; |
| 20 | struct ieee80211_sta *sta = NULL; |
| 21 | + struct mt76_wcid *wcid = NULL; |
| 22 | LIST_HEAD(free_list); |
| 23 | void *end = data + len; |
| 24 | bool v3, wake = false; |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 25 | @@ -999,7 +1000,7 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 26 | v3 = (FIELD_GET(MT_TX_FREE_VER, txd) == 0x4); |
| 27 | |
| 28 | for (cur_info = tx_info; count < total; cur_info++) { |
| 29 | - u32 msdu, info; |
| 30 | + u32 msdu, info, retries = 0; |
| 31 | u8 i; |
| 32 | |
| 33 | if (WARN_ON_ONCE((void *)cur_info >= end)) |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 34 | @@ -1012,7 +1013,6 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 35 | info = le32_to_cpu(*cur_info); |
| 36 | if (info & MT_TX_FREE_PAIR) { |
| 37 | struct mt7915_sta *msta; |
| 38 | - struct mt76_wcid *wcid = NULL; |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 39 | struct mt7915_phy *phy; |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 40 | u16 idx; |
| 41 | |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 42 | @@ -1037,7 +1037,15 @@ mt7915_mac_tx_free(struct mt7915_dev *dev, void *data, int len) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 43 | continue; |
| 44 | } |
| 45 | |
| 46 | - if (v3 && (info & MT_TX_FREE_MPDU_HEADER)) |
| 47 | + if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3)) |
| 48 | + retries = u32_get_bits(info, MT_TX_FREE_TX_COUNT_V3) - 1; |
| 49 | + else if (!v3 && (info & MT_TX_FREE_MPDU_HEADER)) |
| 50 | + retries = u32_get_bits(info, MT_TX_FREE_TX_COUNT) - 1; |
| 51 | + |
developer | e0a1e0e | 2023-02-24 11:26:12 +0800 | [diff] [blame] | 52 | + if (!mtk_wed_device_active(&mdev->mmio.wed) && wcid) |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 53 | + wcid->stats.tx_retries += retries; |
| 54 | + |
| 55 | + if (v3 && (info & MT_TX_FREE_MPDU_HEADER_V3)) |
| 56 | continue; |
| 57 | |
| 58 | for (i = 0; i < 1 + v3; i++) { |
| 59 | diff --git a/mt7915/mac.h b/mt7915/mac.h |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 60 | index 6fa9c79..afadc51 100644 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 61 | --- a/mt7915/mac.h |
| 62 | +++ b/mt7915/mac.h |
| 63 | @@ -36,8 +36,11 @@ enum rx_pkt_type { |
| 64 | #define MT_TX_FREE_LATENCY GENMASK(12, 0) |
| 65 | /* 0: success, others: dropped */ |
| 66 | #define MT_TX_FREE_MSDU_ID GENMASK(30, 16) |
| 67 | +#define MT_TX_FREE_TX_COUNT GENMASK(12, 0) |
| 68 | +#define MT_TX_FREE_TX_COUNT_V3 GENMASK(27, 24) |
| 69 | #define MT_TX_FREE_PAIR BIT(31) |
| 70 | -#define MT_TX_FREE_MPDU_HEADER BIT(30) |
| 71 | +#define MT_TX_FREE_MPDU_HEADER BIT(15) |
| 72 | +#define MT_TX_FREE_MPDU_HEADER_V3 BIT(30) |
| 73 | #define MT_TX_FREE_MSDU_ID_V3 GENMASK(14, 0) |
| 74 | |
| 75 | /* will support this field in further revision */ |
| 76 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 77 | index 3074091..7cc3a99 100644 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 78 | --- a/mt7915/main.c |
| 79 | +++ b/mt7915/main.c |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 80 | @@ -1118,9 +1118,6 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 81 | sinfo->tx_bytes = msta->wcid.stats.tx_bytes; |
| 82 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_BYTES64); |
| 83 | |
| 84 | - sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 85 | - sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 86 | - |
| 87 | if (mtk_wed_get_rx_capa(&phy->dev->mt76.mmio.wed)) { |
| 88 | sinfo->rx_bytes = msta->wcid.stats.rx_bytes; |
| 89 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_RX_BYTES64); |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 90 | @@ -1130,6 +1127,9 @@ static void mt7915_sta_statistics(struct ieee80211_hw *hw, |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
| 94 | + sinfo->tx_retries = msta->wcid.stats.tx_retries; |
| 95 | + sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_RETRIES); |
| 96 | + |
| 97 | if (!mt7915_mcu_get_tx_stat_wa(phy->dev, msta->wcid.idx)) { |
| 98 | sinfo->tx_packets = msta->wcid.stats.tx_packets; |
| 99 | sinfo->filled |= BIT_ULL(NL80211_STA_INFO_TX_PACKETS); |
| 100 | -- |
developer | a43cc48 | 2023-04-17 15:57:28 +0800 | [diff] [blame^] | 101 | 2.18.0 |
developer | 5eddc51 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 102 | |