developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 1 | From 31d291dbd8415f4e31b083493f78bdbf6f1230e7 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 3 | Date: Mon, 17 Jun 2024 17:16:19 +0800 |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 162/193] mtk: mt76: mt7996: change source of per-WCID TX MPDU |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | statistics |
| 6 | |
| 7 | Change source of per-WCID TX MPDU statistics from TX-free-done event to PPDU TXS, because WCID from TX-free-done event may not represent the actually used link. |
| 8 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 9 | Change-Id: If4276b3cc779f79f29c7354c9ac2140a2fd8d852 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 10 | Signed-off-by: Benjamin Lin <benjamin-jw.lin@mediatek.com> |
| 11 | --- |
| 12 | mt76.h | 1 + |
| 13 | mt76_connac3_mac.h | 5 +++++ |
| 14 | mt7996/mac.c | 50 +++++++++++++++++++++++++--------------------- |
| 15 | 3 files changed, 33 insertions(+), 23 deletions(-) |
| 16 | |
| 17 | diff --git a/mt76.h b/mt76.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 18 | index 62ae266..c3b71cc 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 19 | --- a/mt76.h |
| 20 | +++ b/mt76.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 21 | @@ -364,6 +364,7 @@ struct mt76_sta_stats { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 22 | u64 tx_bytes; |
| 23 | /* WED TX */ |
| 24 | u32 tx_packets; /* unit: MSDU */ |
| 25 | + u32 tx_mpdus; |
| 26 | u32 tx_retries; |
| 27 | u32 tx_failed; |
| 28 | u64 tx_airtime; |
| 29 | diff --git a/mt76_connac3_mac.h b/mt76_connac3_mac.h |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 30 | index db0c29e..ad8392c 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 31 | --- a/mt76_connac3_mac.h |
| 32 | +++ b/mt76_connac3_mac.h |
| 33 | @@ -204,6 +204,11 @@ enum tx_frag_idx { |
| 34 | MT_TX_FRAG_LAST |
| 35 | }; |
| 36 | |
| 37 | +enum { |
| 38 | + MT_TXS_MPDU_FMT = 0, |
| 39 | + MT_TXS_PPDU_FMT = 2, |
| 40 | +}; |
| 41 | + |
| 42 | #define MT_CT_INFO_APPLY_TXD BIT(0) |
| 43 | #define MT_CT_INFO_COPY_HOST_TXD_ALL BIT(1) |
| 44 | #define MT_CT_INFO_MGMT_FRAME BIT(2) |
| 45 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
developer | 1f55fcf | 2024-10-17 14:52:33 +0800 | [diff] [blame^] | 46 | index 3cd034c..87e671a 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 47 | --- a/mt7996/mac.c |
| 48 | +++ b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 49 | @@ -1218,19 +1218,9 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 50 | spin_unlock_bh(&mdev->sta_poll_lock); |
| 51 | continue; |
| 52 | } else if (info & MT_TXFREE_INFO_HEADER) { |
| 53 | - u32 tx_retries = 0, tx_failed = 0; |
| 54 | - |
| 55 | if (!wcid) |
| 56 | continue; |
| 57 | |
| 58 | - tx_retries = |
| 59 | - FIELD_GET(MT_TXFREE_INFO_COUNT, info) - 1; |
| 60 | - tx_failed = tx_retries + |
| 61 | - !!FIELD_GET(MT_TXFREE_INFO_STAT, info); |
| 62 | - |
| 63 | - wcid->stats.tx_retries += tx_retries; |
| 64 | - wcid->stats.tx_failed += tx_failed; |
| 65 | - |
| 66 | if (FIELD_GET(MT_TXFREE_INFO_STAT, info) == 2) { |
| 67 | struct mt7996_phy *mphy = |
| 68 | __mt7996_phy(dev, wcid->phy_idx); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 69 | @@ -1268,9 +1258,10 @@ mt7996_mac_tx_free(struct mt7996_dev *dev, void *data, int len) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 70 | |
| 71 | static bool |
| 72 | mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, |
| 73 | - int pid, __le32 *txs_data) |
| 74 | + struct mt76_wcid *link_wcid, int pid, __le32 *txs_data) |
| 75 | { |
| 76 | - struct mt76_sta_stats *stats = &wcid->stats; |
| 77 | + u8 fmt = le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT); |
| 78 | + struct mt76_sta_stats *stats = &link_wcid->stats; |
| 79 | struct mt76_dev *mdev = &dev->mt76; |
| 80 | struct ieee80211_tx_info *info; |
| 81 | struct sk_buff_head list; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 82 | @@ -1282,8 +1273,9 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 83 | |
| 84 | mt76_tx_status_lock(mdev, &list); |
| 85 | |
| 86 | - /* only report MPDU TXS */ |
| 87 | - if (le32_get_bits(txs_data[0], MT_TXS0_TXS_FORMAT) == 0) { |
| 88 | + switch (fmt) { |
| 89 | + case MT_TXS_MPDU_FMT: |
| 90 | + /* Only report MPDU TXS to mac80211. */ |
| 91 | skb = mt76_tx_status_skb_get(mdev, wcid, pid, &list); |
| 92 | if (skb) { |
| 93 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 94 | @@ -1312,6 +1304,15 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 95 | mvif->probe_send_count[wcid->phy_idx] = 0; |
| 96 | } |
| 97 | } |
| 98 | + break; |
| 99 | + case MT_TXS_PPDU_FMT: |
| 100 | + stats->tx_mpdus += le32_get_bits(txs_data[5], MT_TXS5_MPDU_TX_CNT); |
| 101 | + stats->tx_failed += le32_get_bits(txs_data[6], MT_TXS6_MPDU_FAIL_CNT); |
| 102 | + stats->tx_retries += le32_get_bits(txs_data[7], MT_TXS7_MPDU_RETRY_CNT); |
| 103 | + break; |
| 104 | + default: |
| 105 | + dev_err(mdev->dev, "Unknown TXS format: %hhu\n", fmt); |
| 106 | + goto unlock; |
| 107 | } |
| 108 | |
| 109 | if (mtk_wed_device_active(&dev->mt76.mmio.wed) && wcid->sta) { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 110 | @@ -1343,6 +1344,7 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 111 | |
| 112 | if (skb) |
| 113 | mt76_tx_status_skb_done(mdev, skb, &list); |
| 114 | +unlock: |
| 115 | mt76_tx_status_unlock(mdev, &list); |
| 116 | |
| 117 | return !!skb; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 118 | @@ -1350,13 +1352,13 @@ mt7996_mac_add_txs_skb(struct mt7996_dev *dev, struct mt76_wcid *wcid, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 119 | |
| 120 | static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data) |
| 121 | { |
| 122 | - struct mt7996_link_sta *mlink; |
| 123 | - struct mt76_wcid *wcid; |
| 124 | + struct mt76_wcid *wcid, *link_wcid; |
| 125 | __le32 *txs_data = data; |
| 126 | u16 wcidx; |
| 127 | - u8 pid; |
| 128 | + u8 band, pid; |
| 129 | |
| 130 | wcidx = le32_get_bits(txs_data[2], MT_TXS2_WCID); |
| 131 | + band = le32_get_bits(txs_data[2], MT_TXS2_BAND); |
| 132 | pid = le32_get_bits(txs_data[3], MT_TXS3_PID); |
| 133 | |
| 134 | if (pid < MT_PACKET_ID_NO_SKB) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 135 | @@ -1371,17 +1373,19 @@ static void mt7996_mac_add_txs(struct mt7996_dev *dev, void *data) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 136 | if (!wcid) |
| 137 | goto out; |
| 138 | |
| 139 | - mt7996_mac_add_txs_skb(dev, wcid, pid, txs_data); |
| 140 | + link_wcid = mt7996_get_link_wcid(dev, wcidx, band); |
| 141 | + if (!link_wcid) |
| 142 | + goto out; |
| 143 | + |
| 144 | + mt7996_mac_add_txs_skb(dev, wcid, link_wcid, pid, txs_data); |
| 145 | |
| 146 | - if (!wcid->sta) |
| 147 | + if (!link_wcid->sta) |
| 148 | goto out; |
| 149 | |
| 150 | - mlink = wcid_to_mlink(wcid); |
| 151 | spin_lock_bh(&dev->mt76.sta_poll_lock); |
| 152 | - if (list_empty(&mlink->wcid.poll_list)) |
| 153 | - list_add_tail(&mlink->wcid.poll_list, &dev->mt76.sta_poll_list); |
| 154 | + if (list_empty(&link_wcid->poll_list)) |
| 155 | + list_add_tail(&link_wcid->poll_list, &dev->mt76.sta_poll_list); |
| 156 | spin_unlock_bh(&dev->mt76.sta_poll_lock); |
| 157 | - |
| 158 | out: |
| 159 | rcu_read_unlock(); |
| 160 | } |
| 161 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame] | 162 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 163 | |