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