developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 1 | From b230d11d8c61d395043c5463a780f7bcabfc7196 Mon Sep 17 00:00:00 2001 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 2 | From: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 3 | Date: Thu, 23 May 2024 02:33:47 +0800 |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 153/223] mtk: mt76: add debugfs for rx drop counters |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 5 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 6 | Change-Id: I23c494a80095c680cfe7765b5898fb044a4b73da |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 7 | Signed-off-by: Peter Chiu <chui-hao.chiu@mediatek.com> |
| 8 | --- |
| 9 | agg-rx.c | 9 +++++ |
| 10 | dma.c | 40 +++++++++++++++++----- |
| 11 | dma.h | 14 ++++---- |
| 12 | mac80211.c | 15 ++++++++- |
| 13 | mt76.h | 39 ++++++++++++++++++++++ |
| 14 | mt7996/mac.c | 13 ++++++++ |
| 15 | mt7996/mtk_debugfs.c | 79 ++++++++++++++++++++++++++++++++++++++++++++ |
| 16 | 7 files changed, 193 insertions(+), 16 deletions(-) |
| 17 | |
| 18 | diff --git a/agg-rx.c b/agg-rx.c |
| 19 | index b48943c4..9875baa8 100644 |
| 20 | --- a/agg-rx.c |
| 21 | +++ b/agg-rx.c |
| 22 | @@ -152,6 +152,7 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames) |
| 23 | struct mt76_wcid *wcid = status->wcid; |
| 24 | struct ieee80211_sta *sta; |
| 25 | struct mt76_rx_tid *tid; |
| 26 | + struct mt76_phy *phy; |
| 27 | bool sn_less; |
| 28 | u16 seqno, head, size, idx; |
| 29 | u8 tidno = status->qos_ctl & IEEE80211_QOS_CTL_TID_MASK; |
| 30 | @@ -178,6 +179,8 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames) |
| 31 | if (!tid) |
| 32 | return; |
| 33 | |
| 34 | + phy = mt76_dev_phy(tid->dev, wcid->phy_idx); |
| 35 | + |
| 36 | status->flag |= RX_FLAG_DUP_VALIDATED; |
| 37 | spin_lock_bh(&tid->lock); |
| 38 | |
| 39 | @@ -200,6 +203,9 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames) |
| 40 | if (sn_less) { |
| 41 | __skb_unlink(skb, frames); |
| 42 | dev_kfree_skb(skb); |
| 43 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 44 | + phy->rx_dbg_stats.rx_drop[MT_RX_DROP_AGG_SN_LESS]++; |
| 45 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 46 | goto out; |
| 47 | } |
| 48 | |
| 49 | @@ -226,6 +232,9 @@ void mt76_rx_aggr_reorder(struct sk_buff *skb, struct sk_buff_head *frames) |
| 50 | /* Discard if the current slot is already in use */ |
| 51 | if (tid->reorder_buf[idx]) { |
| 52 | dev_kfree_skb(skb); |
| 53 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 54 | + phy->rx_dbg_stats.rx_drop[MT_RX_DROP_AGG_DUP]++; |
| 55 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 56 | goto out; |
| 57 | } |
| 58 | |
| 59 | diff --git a/dma.c b/dma.c |
| 60 | index 0dae40e2..81e76191 100644 |
| 61 | --- a/dma.c |
| 62 | +++ b/dma.c |
| 63 | @@ -251,13 +251,16 @@ mt76_dma_add_rx_buf(struct mt76_dev *dev, struct mt76_queue *q, |
| 64 | if (mt76_queue_is_wed_rx(q)) { |
| 65 | if (!rxwi) { |
| 66 | rxwi = mt76_get_rxwi(dev); |
| 67 | - if (!rxwi) |
| 68 | + if (!rxwi) { |
| 69 | + q->rx_drop[MT_RX_DROP_DMAD_GET_RXWI_FAIL]++; |
| 70 | return -ENOMEM; |
| 71 | + } |
| 72 | } |
| 73 | |
| 74 | rx_token = mt76_rx_token_consume(dev, data, rxwi, buf->addr); |
| 75 | if (rx_token < 0) { |
| 76 | mt76_put_rxwi(dev, rxwi); |
| 77 | + q->rx_drop[MT_RX_DROP_DMAD_GET_TOKEN_FAIL]++; |
| 78 | return -ENOMEM; |
| 79 | } |
| 80 | |
| 81 | @@ -428,6 +431,7 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 82 | struct mt76_desc *desc = &q->desc[idx]; |
| 83 | u32 ctrl, desc_info, buf1; |
| 84 | void *buf = e->buf; |
| 85 | + int reason; |
| 86 | |
| 87 | if (mt76_queue_is_wed_rro_ind(q)) |
| 88 | goto done; |
| 89 | @@ -443,7 +447,9 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 90 | *info = desc_info; |
| 91 | |
| 92 | buf1 = le32_to_cpu(desc->buf1); |
| 93 | - mt76_dma_should_drop_buf(drop, ctrl, buf1, desc_info); |
| 94 | + reason = mt76_dma_should_drop_buf(drop, ctrl, buf1, desc_info); |
| 95 | + if (drop && *drop && reason >= 0) |
| 96 | + q->rx_drop[reason]++; |
| 97 | |
| 98 | if (mt76_queue_is_wed_rx(q)) { |
| 99 | u32 id, find = 0; |
| 100 | @@ -467,13 +473,17 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 101 | } |
| 102 | |
| 103 | spin_unlock_bh(&dev->rx_token_lock); |
| 104 | - if (!find) |
| 105 | + if (!find) { |
| 106 | + q->rx_drop[MT_RX_DROP_DMAD_ADDR_NOT_FOUND]++; |
| 107 | return NULL; |
| 108 | + } |
| 109 | } |
| 110 | |
| 111 | r = mt76_rx_token_release(dev, token); |
| 112 | - if (!r) |
| 113 | + if (!r) { |
| 114 | + q->rx_drop[MT_RX_DROP_DMAD_TOKEN_NOT_FOUND]++; |
| 115 | return NULL; |
| 116 | + } |
| 117 | |
| 118 | dma_unmap_single(dev->dma_dev, r->dma_addr, |
| 119 | SKB_WITH_OVERHEAD(q->buf_size), |
| 120 | @@ -489,8 +499,10 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 121 | struct mt76_queue_buf qbuf; |
| 122 | |
| 123 | buf = page_frag_alloc(&q->rx_page, q->buf_size, GFP_ATOMIC | GFP_DMA32); |
| 124 | - if (!buf) |
| 125 | + if (!buf) { |
| 126 | + q->rx_drop[MT_RX_DROP_DMAD_NOMEM]++; |
| 127 | return NULL; |
| 128 | + } |
| 129 | |
| 130 | memcpy(buf, r->ptr, SKB_WITH_OVERHEAD(q->buf_size)); |
| 131 | |
| 132 | @@ -500,6 +512,7 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 133 | if (unlikely(dma_mapping_error(dev->dma_dev, r->dma_addr))) { |
| 134 | skb_free_frag(r->ptr); |
| 135 | mt76_put_rxwi(dev, r); |
| 136 | + q->rx_drop[MT_RX_DROP_DMAD_DMA_MAPPING_FAIL]++; |
| 137 | return NULL; |
| 138 | } |
| 139 | |
| 140 | @@ -517,8 +530,11 @@ mt76_dma_get_buf(struct mt76_dev *dev, struct mt76_queue *q, int idx, |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | - if (drop) |
| 145 | + if (drop) { |
| 146 | *drop |= !!(buf1 & MT_DMA_CTL_WO_DROP); |
| 147 | + if (buf1 & MT_DMA_CTL_WO_DROP) |
| 148 | + q->rx_drop[MT_RX_DROP_DMAD_WO_FRAG]++; |
| 149 | + } |
| 150 | } else { |
| 151 | dma_unmap_single(dev->dma_dev, e->dma_addr[0], |
| 152 | SKB_WITH_OVERHEAD(q->buf_size), |
| 153 | @@ -892,6 +908,7 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, |
| 154 | |
| 155 | skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size); |
| 156 | } else { |
| 157 | + q->rx_drop[MT_RX_DROP_FRAG]++; |
| 158 | skb_free_frag(data); |
| 159 | } |
| 160 | |
| 161 | @@ -899,10 +916,12 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, |
| 162 | return; |
| 163 | |
| 164 | q->rx_head = NULL; |
| 165 | - if (nr_frags < ARRAY_SIZE(shinfo->frags)) |
| 166 | + if (nr_frags < ARRAY_SIZE(shinfo->frags)) { |
| 167 | dev->drv->rx_skb(dev, q - dev->q_rx, skb, &info); |
| 168 | - else |
| 169 | + } else { |
| 170 | + q->rx_drop[MT_RX_DROP_FRAG]++; |
| 171 | dev_kfree_skb(skb); |
| 172 | + } |
| 173 | } |
| 174 | |
| 175 | static int |
| 176 | @@ -947,6 +966,7 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
| 177 | data_len = SKB_WITH_OVERHEAD(q->buf_size); |
| 178 | |
| 179 | if (data_len < len + q->buf_offset) { |
| 180 | + q->rx_drop[MT_RX_DROP_FRAG]++; |
| 181 | dev_kfree_skb(q->rx_head); |
| 182 | q->rx_head = NULL; |
| 183 | goto free_frag; |
| 184 | @@ -963,8 +983,10 @@ mt76_dma_rx_process(struct mt76_dev *dev, struct mt76_queue *q, int budget) |
| 185 | goto free_frag; |
| 186 | |
| 187 | skb = build_skb(data, q->buf_size); |
| 188 | - if (!skb) |
| 189 | + if (!skb) { |
| 190 | + q->rx_drop[MT_RX_DROP_BUILD_SKB_FAIL]++; |
| 191 | goto free_frag; |
| 192 | + } |
| 193 | |
| 194 | skb_reserve(skb, q->buf_offset); |
| 195 | |
| 196 | diff --git a/dma.h b/dma.h |
| 197 | index 3a8c2e55..718122d5 100644 |
| 198 | --- a/dma.h |
| 199 | +++ b/dma.h |
| 200 | @@ -93,27 +93,29 @@ mt76_dma_reset_tx_queue(struct mt76_dev *dev, struct mt76_queue *q) |
| 201 | mt76_wed_dma_setup(dev, q, true); |
| 202 | } |
| 203 | |
| 204 | -static inline void |
| 205 | +static inline int |
| 206 | mt76_dma_should_drop_buf(bool *drop, u32 ctrl, u32 buf1, u32 info) |
| 207 | { |
| 208 | if (!drop) |
| 209 | - return; |
| 210 | + return -1; |
| 211 | |
| 212 | *drop = !!(ctrl & (MT_DMA_CTL_TO_HOST_A | MT_DMA_CTL_DROP)); |
| 213 | if (!(ctrl & MT_DMA_CTL_VER_MASK)) |
| 214 | - return; |
| 215 | + return MT_RX_DROP_DMAD_WO_DROP; |
| 216 | |
| 217 | switch (FIELD_GET(MT_DMA_WED_IND_REASON, buf1)) { |
| 218 | case MT_DMA_WED_IND_REASON_REPEAT: |
| 219 | *drop = true; |
| 220 | - break; |
| 221 | + return MT_RX_DROP_DMAD_RRO_REPEAT; |
| 222 | case MT_DMA_WED_IND_REASON_OLDPKT: |
| 223 | *drop = !(info & MT_DMA_INFO_DMA_FRAG); |
| 224 | - break; |
| 225 | + return MT_RX_DROP_DMAD_RRO_OLDPKT; |
| 226 | default: |
| 227 | *drop = !!(ctrl & MT_DMA_CTL_PN_CHK_FAIL); |
| 228 | - break; |
| 229 | + return MT_RX_DROP_DMAD_RRO_PN_CHK_FAIL; |
| 230 | } |
| 231 | + |
| 232 | + return -1; |
| 233 | } |
| 234 | |
| 235 | #endif |
| 236 | diff --git a/mac80211.c b/mac80211.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 237 | index 93ff77be..6190822c 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 238 | --- a/mac80211.c |
| 239 | +++ b/mac80211.c |
| 240 | @@ -418,6 +418,7 @@ mt76_phy_init(struct mt76_phy *phy, struct ieee80211_hw *hw) |
| 241 | INIT_LIST_HEAD(&phy->tx_list); |
| 242 | spin_lock_init(&phy->tx_lock); |
| 243 | spin_lock_init(&phy->tx_dbg_stats.lock); |
| 244 | + spin_lock_init(&phy->rx_dbg_stats.lock); |
| 245 | |
| 246 | SET_IEEE80211_DEV(hw, dev->dev); |
| 247 | SET_IEEE80211_PERM_ADDR(hw, phy->macaddr); |
| 248 | @@ -755,6 +756,9 @@ static void mt76_rx_release_amsdu(struct mt76_phy *phy, enum mt76_rxq_id q) |
| 249 | } |
| 250 | |
| 251 | if (ether_addr_equal(skb->data + offset, rfc1042_header)) { |
| 252 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 253 | + phy->rx_dbg_stats.rx_drop[MT_RX_DROP_RFC_PKT]++; |
| 254 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 255 | dev_kfree_skb(skb); |
| 256 | return; |
| 257 | } |
| 258 | @@ -792,6 +796,9 @@ void mt76_rx(struct mt76_dev *dev, enum mt76_rxq_id q, struct sk_buff *skb) |
| 259 | |
| 260 | if (!test_bit(MT76_STATE_RUNNING, &phy->state)) { |
| 261 | dev_kfree_skb(skb); |
| 262 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 263 | + phy->rx_dbg_stats.rx_drop[MT_RX_DROP_STATE_ERR]++; |
| 264 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 265 | return; |
| 266 | } |
| 267 | |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 268 | @@ -1080,6 +1087,7 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 269 | { |
| 270 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
| 271 | struct ieee80211_hdr *hdr = mt76_skb_get_hdr(skb); |
| 272 | + struct mt76_phy *phy; |
| 273 | struct mt76_rx_status mstat; |
| 274 | |
| 275 | mstat = *((struct mt76_rx_status *)skb->cb); |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 276 | @@ -1126,7 +1134,12 @@ mt76_rx_convert(struct mt76_dev *dev, struct sk_buff *skb, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 277 | } |
| 278 | |
| 279 | *sta = wcid_to_sta(mstat.wcid); |
| 280 | - *hw = mt76_main_hw(dev->phys[mstat.phy_idx]); |
| 281 | + *hw = mt76_phy_hw(dev, mstat.phy_idx); |
| 282 | + |
| 283 | + phy = mt76_dev_phy(dev, mstat.phy_idx); |
| 284 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 285 | + phy->rx_dbg_stats.rx_to_mac80211++; |
| 286 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 287 | } |
| 288 | |
| 289 | static void |
| 290 | diff --git a/mt76.h b/mt76.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 291 | index 8e78ba86..62ae2662 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 292 | --- a/mt76.h |
| 293 | +++ b/mt76.h |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 294 | @@ -188,6 +188,34 @@ enum mt76_dfs_state { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 295 | MT_DFS_STATE_ACTIVE, |
| 296 | }; |
| 297 | |
| 298 | +enum { |
| 299 | + /* Per dev counters*/ |
| 300 | + MT_RX_DROP_DMAD_RRO_REPEAT, |
| 301 | + MT_RX_DROP_DMAD_RRO_OLDPKT, |
| 302 | + MT_RX_DROP_DMAD_RRO_PN_CHK_FAIL, |
| 303 | + MT_RX_DROP_DMAD_WO_FRAG, |
| 304 | + MT_RX_DROP_DMAD_WO_DROP, |
| 305 | + MT_RX_DROP_DMAD_ADDR_NOT_FOUND, |
| 306 | + MT_RX_DROP_DMAD_TOKEN_NOT_FOUND, |
| 307 | + MT_RX_DROP_DMAD_GET_TOKEN_FAIL, |
| 308 | + MT_RX_DROP_DMAD_GET_RXWI_FAIL, |
| 309 | + MT_RX_DROP_DMAD_NOMEM, |
| 310 | + MT_RX_DROP_DMAD_DMA_MAPPING_FAIL, |
| 311 | + MT_RX_DROP_FRAG, |
| 312 | + MT_RX_DROP_BUILD_SKB_FAIL, |
| 313 | + |
| 314 | + MT_RX_DROP_PER_Q_MAX, |
| 315 | + |
| 316 | + /* Per phy counters */ |
| 317 | + MT_RX_DROP_RXD_ERR = 0, |
| 318 | + MT_RX_DROP_STATE_ERR, |
| 319 | + MT_RX_DROP_RFC_PKT, |
| 320 | + MT_RX_DROP_AGG_SN_LESS, |
| 321 | + MT_RX_DROP_AGG_DUP, |
| 322 | + |
| 323 | + MT_RX_DROP_PER_PHY_MAX, |
| 324 | +}; |
| 325 | + |
| 326 | struct mt76_queue_buf { |
| 327 | dma_addr_t addr; |
| 328 | u16 len:15, |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 329 | @@ -256,6 +284,8 @@ struct mt76_queue { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 330 | dma_addr_t desc_dma; |
| 331 | struct sk_buff *rx_head; |
| 332 | struct page_frag_cache rx_page; |
| 333 | + |
| 334 | + u32 rx_drop[MT_RX_DROP_PER_Q_MAX]; |
| 335 | }; |
| 336 | |
| 337 | struct mt76_mcu_ops { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 338 | @@ -874,6 +904,14 @@ struct mt76_tx_debug { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 339 | spinlock_t lock; |
| 340 | }; |
| 341 | |
| 342 | +struct mt76_rx_debug { |
| 343 | + u32 rx_from_hw; |
| 344 | + u32 rx_to_mac80211; |
| 345 | + |
| 346 | + u32 rx_drop[MT_RX_DROP_PER_PHY_MAX]; |
| 347 | + spinlock_t lock; |
| 348 | +}; |
| 349 | + |
| 350 | struct mt76_phy { |
| 351 | struct ieee80211_hw *hw; |
| 352 | struct ieee80211_hw *ori_hw; |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 353 | @@ -932,6 +970,7 @@ struct mt76_phy { |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 354 | u8 pin; |
| 355 | } leds; |
| 356 | struct mt76_tx_debug tx_dbg_stats; |
| 357 | + struct mt76_rx_debug rx_dbg_stats; |
| 358 | }; |
| 359 | |
| 360 | struct mt76_dev { |
| 361 | diff --git a/mt7996/mac.c b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 362 | index a78ebefc..ee505a55 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 363 | --- a/mt7996/mac.c |
| 364 | +++ b/mt7996/mac.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 365 | @@ -1422,9 +1422,11 @@ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 366 | struct sk_buff *skb, u32 *info) |
| 367 | { |
| 368 | struct mt7996_dev *dev = container_of(mdev, struct mt7996_dev, mt76); |
| 369 | + struct mt76_phy *phy; |
| 370 | __le32 *rxd = (__le32 *)skb->data; |
| 371 | __le32 *end = (__le32 *)&skb->data[skb->len]; |
| 372 | enum rx_pkt_type type; |
| 373 | + u8 band_idx; |
| 374 | |
| 375 | type = le32_get_bits(rxd[0], MT_RXD0_PKT_TYPE); |
| 376 | if (type != PKT_TYPE_NORMAL) { |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 377 | @@ -1459,12 +1461,23 @@ void mt7996_queue_rx_skb(struct mt76_dev *mdev, enum mt76_rxq_id q, |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 378 | dev_kfree_skb(skb); |
| 379 | break; |
| 380 | case PKT_TYPE_NORMAL: |
| 381 | + band_idx = le32_get_bits(rxd[1], MT_RXD1_NORMAL_BAND_IDX); |
| 382 | + phy = mt76_dev_phy(mdev, band_idx); |
| 383 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 384 | + phy->rx_dbg_stats.rx_from_hw++; |
| 385 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 386 | + |
| 387 | if (!mt7996_mac_fill_rx(dev, q, skb, info)) { |
| 388 | mt76_rx(&dev->mt76, q, skb); |
| 389 | return; |
| 390 | } |
| 391 | fallthrough; |
| 392 | default: |
| 393 | + band_idx = le32_get_bits(rxd[1], MT_RXD1_NORMAL_BAND_IDX); |
| 394 | + phy = mt76_dev_phy(mdev, band_idx); |
| 395 | + spin_lock_bh(&phy->rx_dbg_stats.lock); |
| 396 | + phy->rx_dbg_stats.rx_drop[MT_RX_DROP_RXD_ERR]++; |
| 397 | + spin_unlock_bh(&phy->rx_dbg_stats.lock); |
| 398 | dev_kfree_skb(skb); |
| 399 | break; |
| 400 | } |
| 401 | diff --git a/mt7996/mtk_debugfs.c b/mt7996/mtk_debugfs.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 402 | index d15d403b..422518f5 100644 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 403 | --- a/mt7996/mtk_debugfs.c |
| 404 | +++ b/mt7996/mtk_debugfs.c |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 405 | @@ -4239,6 +4239,84 @@ out: |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 406 | } |
| 407 | DEFINE_SHOW_ATTRIBUTE(mt7996_tx_drop); |
| 408 | |
| 409 | +static int |
| 410 | +mt7996_rx_drop_show(struct seq_file *s, void *data) |
| 411 | +{ |
| 412 | + struct mt7996_dev *dev = s->private; |
| 413 | + struct mt76_dev *mdev = &dev->mt76; |
| 414 | + struct mt76_rx_debug *stats[__MT_MAX_BAND]; |
| 415 | + struct mt76_queue *q[2]; |
| 416 | + int i = 0; |
| 417 | + |
| 418 | + q[0] = &mdev->q_rx[MT_RXQ_MAIN]; |
| 419 | + q[1] = is_mt7996(mdev) ? &mdev->q_rx[MT_RXQ_BAND2] : |
| 420 | + &mdev->q_rx[MT_RXQ_BAND1]; |
| 421 | + |
| 422 | + seq_printf(s, "\t\t\t\t "); |
| 423 | + for (i = 0; i < 2; i++) { |
| 424 | + seq_printf(s, " RXQ%d", q[i]->hw_idx); |
| 425 | + } |
| 426 | + seq_printf(s, "\n"); |
| 427 | + |
| 428 | +#define __pr(t) seq_printf(s, "Drop due to %-22s%12d%12d\n", #t, \ |
| 429 | + q[0]->rx_drop[MT_RX_DROP_##t], \ |
| 430 | + q[1]->rx_drop[MT_RX_DROP_##t]); |
| 431 | + __pr(DMAD_RRO_REPEAT); |
| 432 | + __pr(DMAD_RRO_OLDPKT); |
| 433 | + __pr(DMAD_RRO_PN_CHK_FAIL); |
| 434 | + __pr(DMAD_WO_FRAG); |
| 435 | + __pr(DMAD_WO_DROP); |
| 436 | + __pr(DMAD_ADDR_NOT_FOUND); |
| 437 | + __pr(DMAD_TOKEN_NOT_FOUND); |
| 438 | + __pr(DMAD_GET_TOKEN_FAIL); |
| 439 | + __pr(DMAD_GET_RXWI_FAIL); |
| 440 | + __pr(DMAD_NOMEM); |
| 441 | + __pr(DMAD_DMA_MAPPING_FAIL); |
| 442 | + __pr(FRAG); |
| 443 | + __pr(BUILD_SKB_FAIL); |
| 444 | +#undef __pr |
| 445 | + |
| 446 | + seq_printf(s, "\n\t\t\t\t "); |
| 447 | + for (i = 0; i < __MT_MAX_BAND; i++) { |
| 448 | + seq_printf(s, " Band%d", i); |
| 449 | + if (mdev->phys[i]) { |
| 450 | + stats[i] = &mdev->phys[i]->rx_dbg_stats; |
| 451 | + } else { |
| 452 | + stats[i] = kzalloc(sizeof(struct mt76_rx_debug), |
| 453 | + GFP_KERNEL); |
| 454 | + if (!stats[i]) |
| 455 | + goto out; |
| 456 | + } |
| 457 | + } |
| 458 | + seq_printf(s, "\n"); |
| 459 | + seq_printf(s, "%-35s%12d%12d%12d\n", "Receive from hw", |
| 460 | + stats[MT_BAND0]->rx_from_hw, |
| 461 | + stats[MT_BAND1]->rx_from_hw, |
| 462 | + stats[MT_BAND2]->rx_from_hw); |
| 463 | + seq_printf(s, "%-35s%12d%12d%12d\n\n", "Send to mac80211", |
| 464 | + stats[MT_BAND0]->rx_to_mac80211, |
| 465 | + stats[MT_BAND1]->rx_to_mac80211, |
| 466 | + stats[MT_BAND2]->rx_to_mac80211); |
| 467 | +#define __pr(t) seq_printf(s, "Drop due to %-22s%12d%12d%12d\n", #t, \ |
| 468 | + stats[MT_BAND0]->rx_drop[MT_RX_DROP_##t], \ |
| 469 | + stats[MT_BAND1]->rx_drop[MT_RX_DROP_##t], \ |
| 470 | + stats[MT_BAND2]->rx_drop[MT_RX_DROP_##t]) |
| 471 | + __pr(RXD_ERR); |
| 472 | + __pr(STATE_ERR); |
| 473 | + __pr(RFC_PKT); |
| 474 | + __pr(AGG_SN_LESS); |
| 475 | + __pr(AGG_DUP); |
| 476 | +#undef __pr |
| 477 | + |
| 478 | +out: |
| 479 | + for (i = 0; i < __MT_MAX_BAND; i++) { |
| 480 | + if (!mdev->phys[i] && stats[i]) |
| 481 | + kfree(stats[i]); |
| 482 | + } |
| 483 | + |
| 484 | + return 0; |
| 485 | +} |
| 486 | +DEFINE_SHOW_ATTRIBUTE(mt7996_rx_drop); |
| 487 | /* DRR */ |
| 488 | static int |
| 489 | mt7996_drr_info(struct seq_file *s, void *data) |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 490 | @@ -4367,6 +4445,7 @@ void mt7996_mtk_init_dev_debugfs(struct mt7996_dev *dev, struct dentry *dir) |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 491 | |
| 492 | /* Drop counters */ |
| 493 | debugfs_create_file("tx_drop_stats", 0400, dir, dev, &mt7996_tx_drop_fops); |
| 494 | + debugfs_create_file("rx_drop_stats", 0400, dir, dev, &mt7996_rx_drop_fops); |
| 495 | } |
| 496 | |
| 497 | #endif |
| 498 | -- |
developer | d0c8945 | 2024-10-11 16:53:27 +0800 | [diff] [blame^] | 499 | 2.45.2 |
developer | 05f3b2b | 2024-08-19 19:17:34 +0800 | [diff] [blame] | 500 | |