developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 1 | From 87ad4633e89e1573f4238ecdfd6680dd78481722 Mon Sep 17 00:00:00 2001 |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 2 | From: Shayne Chen <shayne.chen@mediatek.com> |
| 3 | Date: Wed, 22 Jun 2022 10:39:47 +0800 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 4 | Subject: [PATCH 1000/1040] wifi: mt76: mt7915: add mtk internal debug tools |
| 5 | for mt76 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 6 | |
| 7 | --- |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 8 | mt76_connac_mcu.h | 6 + |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 9 | mt7915/Makefile | 2 +- |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 10 | mt7915/debugfs.c | 89 +- |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 11 | mt7915/mac.c | 14 + |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 12 | mt7915/main.c | 4 + |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 13 | mt7915/mcu.c | 48 +- |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 14 | mt7915/mcu.h | 4 + |
developer | 4d58186 | 2023-02-13 16:01:56 +0800 | [diff] [blame] | 15 | mt7915/mt7915.h | 43 + |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 16 | mt7915/mt7915_debug.h | 1418 ++++++++++++++++ |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 17 | mt7915/mtk_debugfs.c | 3622 +++++++++++++++++++++++++++++++++++++++++ |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 18 | mt7915/mtk_mcu.c | 51 + |
| 19 | tools/fwlog.c | 44 +- |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 20 | 12 files changed, 5326 insertions(+), 19 deletions(-) |
developer | 28b11e2 | 2022-09-05 19:09:45 +0800 | [diff] [blame] | 21 | create mode 100644 mt7915/mt7915_debug.h |
| 22 | create mode 100644 mt7915/mtk_debugfs.c |
| 23 | create mode 100644 mt7915/mtk_mcu.c |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 24 | |
| 25 | diff --git a/mt76_connac_mcu.h b/mt76_connac_mcu.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 26 | index ddf901a..8b3b7c0 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 27 | --- a/mt76_connac_mcu.h |
| 28 | +++ b/mt76_connac_mcu.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 29 | @@ -1162,6 +1162,7 @@ enum { |
developer | b1654ad | 2022-09-27 10:30:15 +0800 | [diff] [blame] | 30 | MCU_EXT_CMD_SET_TX_POWER_CTRL = 0x11, |
| 31 | MCU_EXT_CMD_FW_LOG_2_HOST = 0x13, |
| 32 | MCU_EXT_CMD_TXBF_ACTION = 0x1e, |
| 33 | + MCU_EXT_CMD_MEC_CTRL = 0x1f, |
| 34 | MCU_EXT_CMD_EFUSE_BUFFER_MODE = 0x21, |
| 35 | MCU_EXT_CMD_THERMAL_PROT = 0x23, |
| 36 | MCU_EXT_CMD_STA_REC_UPDATE = 0x25, |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 37 | @@ -1185,6 +1186,11 @@ enum { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 38 | MCU_EXT_CMD_TX_POWER_FEATURE_CTRL = 0x58, |
| 39 | MCU_EXT_CMD_RXDCOC_CAL = 0x59, |
| 40 | MCU_EXT_CMD_GET_MIB_INFO = 0x5a, |
| 41 | +#ifdef MTK_DEBUG |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 42 | + MCU_EXT_CMD_RED_SHOW_STA = 0x69, |
| 43 | + MCU_EXT_CMD_RED_TARGET_DELAY = 0x6A, |
| 44 | + MCU_EXT_CMD_RED_TX_RPT = 0x6B, |
| 45 | +#endif |
| 46 | MCU_EXT_CMD_TXDPD_CAL = 0x60, |
| 47 | MCU_EXT_CMD_CAL_CACHE = 0x67, |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 48 | MCU_EXT_CMD_RED_ENABLE = 0x68, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 49 | diff --git a/mt7915/Makefile b/mt7915/Makefile |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 50 | index c4dca9c..fd71141 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 51 | --- a/mt7915/Makefile |
| 52 | +++ b/mt7915/Makefile |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 53 | @@ -4,7 +4,7 @@ EXTRA_CFLAGS += -DCONFIG_MT76_LEDS |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 54 | obj-$(CONFIG_MT7915E) += mt7915e.o |
| 55 | |
| 56 | mt7915e-y := pci.o init.o dma.o eeprom.o main.o mcu.o mac.o \ |
| 57 | - debugfs.o mmio.o |
| 58 | + debugfs.o mmio.o mtk_debugfs.o mtk_mcu.o |
| 59 | |
| 60 | mt7915e-$(CONFIG_NL80211_TESTMODE) += testmode.o |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 61 | mt7915e-$(CONFIG_MT798X_WMAC) += soc.o |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 62 | diff --git a/mt7915/debugfs.c b/mt7915/debugfs.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 63 | index 93e549c..f181377 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 64 | --- a/mt7915/debugfs.c |
| 65 | +++ b/mt7915/debugfs.c |
| 66 | @@ -8,6 +8,9 @@ |
| 67 | #include "mac.h" |
| 68 | |
| 69 | #define FW_BIN_LOG_MAGIC 0x44e98caf |
| 70 | +#ifdef MTK_DEBUG |
| 71 | +#define FW_BIN_LOG_MAGIC_V2 0x44d9c99a |
| 72 | +#endif |
| 73 | |
| 74 | /** global debugfs **/ |
| 75 | |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 76 | @@ -496,6 +499,9 @@ mt7915_fw_debug_wm_set(void *data, u64 val) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 77 | int ret; |
| 78 | |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 79 | dev->fw.debug_wm = val ? MCU_FW_LOG_TO_HOST : 0; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 80 | +#ifdef MTK_DEBUG |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 81 | + dev->fw.debug_wm = val; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 82 | +#endif |
| 83 | |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 84 | if (dev->fw.debug_bin) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 85 | val = 16; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 86 | @@ -520,6 +526,9 @@ mt7915_fw_debug_wm_set(void *data, u64 val) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 87 | if (ret) |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 88 | goto out; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 89 | } |
| 90 | +#ifdef MTK_DEBUG |
| 91 | + mt7915_mcu_fw_dbg_ctrl(dev, 68, !!val); |
| 92 | +#endif |
| 93 | |
| 94 | /* WM CPU info record control */ |
| 95 | mt76_clear(dev, MT_CPU_UTIL_CTRL, BIT(0)); |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 96 | @@ -527,6 +536,12 @@ mt7915_fw_debug_wm_set(void *data, u64 val) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 97 | mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_MASK_CLR_ADDR, BIT(5)); |
| 98 | mt76_wr(dev, MT_MCU_WM_CIRQ_IRQ_SOFT_ADDR, BIT(5)); |
| 99 | |
| 100 | +#ifdef MTK_DEBUG |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 101 | + if (dev->fw.debug_bin & BIT(3)) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 102 | + /* use bit 7 to indicate v2 magic number */ |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 103 | + dev->fw.debug_wm |= BIT(7); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 104 | +#endif |
| 105 | + |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 106 | out: |
| 107 | if (ret) |
| 108 | dev->fw.debug_wm = 0; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 109 | @@ -539,7 +554,11 @@ mt7915_fw_debug_wm_get(void *data, u64 *val) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 110 | { |
| 111 | struct mt7915_dev *dev = data; |
| 112 | |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 113 | - *val = dev->fw.debug_wm; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 114 | +#ifdef MTK_DEBUG |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 115 | + *val = dev->fw.debug_wm & ~BIT(7); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 116 | +#else |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 117 | + val = dev->fw.debug_wm; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 118 | +#endif |
| 119 | |
| 120 | return 0; |
| 121 | } |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 122 | @@ -614,16 +633,30 @@ mt7915_fw_debug_bin_set(void *data, u64 val) |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 123 | }; |
| 124 | struct mt7915_dev *dev = data; |
| 125 | |
| 126 | - if (!dev->relay_fwlog) |
| 127 | + if (!dev->relay_fwlog && val) { |
| 128 | dev->relay_fwlog = relay_open("fwlog_data", dev->debugfs_dir, |
| 129 | 1500, 512, &relay_cb, NULL); |
| 130 | - if (!dev->relay_fwlog) |
| 131 | - return -ENOMEM; |
| 132 | + if (!dev->relay_fwlog) |
| 133 | + return -ENOMEM; |
| 134 | + } |
| 135 | |
| 136 | dev->fw.debug_bin = val; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 137 | |
| 138 | relay_reset(dev->relay_fwlog); |
| 139 | |
| 140 | +#ifdef MTK_DEBUG |
| 141 | + dev->dbg.dump_mcu_pkt = val & BIT(4) ? true : false; |
| 142 | + dev->dbg.dump_txd = val & BIT(5) ? true : false; |
| 143 | + dev->dbg.dump_tx_pkt = val & BIT(6) ? true : false; |
| 144 | + dev->dbg.dump_rx_pkt = val & BIT(7) ? true : false; |
| 145 | + dev->dbg.dump_rx_raw = val & BIT(8) ? true : false; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 146 | +#endif |
| 147 | + |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 148 | + if (dev->relay_fwlog && !val) { |
| 149 | + relay_close(dev->relay_fwlog); |
| 150 | + dev->relay_fwlog = NULL; |
| 151 | + } |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 152 | + |
| 153 | return mt7915_fw_debug_wm_set(dev, dev->fw.debug_wm); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 154 | } |
| 155 | |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 156 | @@ -1253,6 +1286,11 @@ int mt7915_init_debugfs(struct mt7915_phy *phy) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 157 | if (!ext_phy) |
| 158 | dev->debugfs_dir = dir; |
| 159 | |
| 160 | +#ifdef MTK_DEBUG |
| 161 | + debugfs_create_u16("wlan_idx", 0600, dir, &dev->wlan_idx); |
| 162 | + mt7915_mtk_init_debugfs(phy, dir); |
| 163 | +#endif |
| 164 | + |
| 165 | return 0; |
| 166 | } |
| 167 | |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 168 | @@ -1265,6 +1303,12 @@ mt7915_debugfs_write_fwlog(struct mt7915_dev *dev, const void *hdr, int hdrlen, |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 169 | void *dest; |
| 170 | |
| 171 | spin_lock_irqsave(&lock, flags); |
| 172 | + |
| 173 | + if (!dev->relay_fwlog) { |
| 174 | + spin_unlock_irqrestore(&lock, flags); |
| 175 | + return; |
| 176 | + } |
| 177 | + |
| 178 | dest = relay_reserve(dev->relay_fwlog, hdrlen + len + 4); |
| 179 | if (dest) { |
| 180 | *(u32 *)dest = hdrlen + len; |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 181 | @@ -1293,17 +1337,50 @@ void mt7915_debugfs_rx_fw_monitor(struct mt7915_dev *dev, const void *data, int |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 182 | .msg_type = cpu_to_le16(PKT_TYPE_RX_FW_MONITOR), |
| 183 | }; |
| 184 | |
developer | f552fec | 2023-03-27 11:22:06 +0800 | [diff] [blame] | 185 | - if (!dev->relay_fwlog) |
| 186 | - return; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 187 | +#ifdef MTK_DEBUG |
| 188 | + struct { |
| 189 | + __le32 magic; |
| 190 | + u8 version; |
| 191 | + u8 _rsv; |
| 192 | + __le16 serial_id; |
| 193 | + __le32 timestamp; |
| 194 | + __le16 msg_type; |
| 195 | + __le16 len; |
| 196 | + } hdr2 = { |
| 197 | + .version = 0x1, |
| 198 | + .magic = cpu_to_le32(FW_BIN_LOG_MAGIC_V2), |
| 199 | + .msg_type = PKT_TYPE_RX_FW_MONITOR, |
| 200 | + }; |
| 201 | +#endif |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 202 | |
| 203 | +#ifdef MTK_DEBUG |
| 204 | + /* old magic num */ |
developer | 6caa5e2 | 2022-06-16 13:33:13 +0800 | [diff] [blame] | 205 | + if (!(dev->fw.debug_wm & BIT(7))) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 206 | + hdr.timestamp = mt76_rr(dev, MT_LPON_FRCR(0)); |
| 207 | + hdr.len = *(__le16 *)data; |
| 208 | + mt7915_debugfs_write_fwlog(dev, &hdr, sizeof(hdr), data, len); |
| 209 | + } else { |
| 210 | + hdr2.serial_id = dev->dbg.fwlog_seq++; |
| 211 | + hdr2.timestamp = mt76_rr(dev, MT_LPON_FRCR(0)); |
| 212 | + hdr2.len = *(__le16 *)data; |
| 213 | + mt7915_debugfs_write_fwlog(dev, &hdr2, sizeof(hdr2), data, len); |
| 214 | + } |
| 215 | +#else |
| 216 | hdr.timestamp = cpu_to_le32(mt76_rr(dev, MT_LPON_FRCR(0))); |
| 217 | hdr.len = *(__le16 *)data; |
| 218 | mt7915_debugfs_write_fwlog(dev, &hdr, sizeof(hdr), data, len); |
| 219 | +#endif |
| 220 | } |
| 221 | |
| 222 | bool mt7915_debugfs_rx_log(struct mt7915_dev *dev, const void *data, int len) |
| 223 | { |
| 224 | +#ifdef MTK_DEBUG |
| 225 | + if (get_unaligned_le32(data) != FW_BIN_LOG_MAGIC && |
| 226 | + get_unaligned_le32(data) != FW_BIN_LOG_MAGIC_V2 && |
| 227 | + get_unaligned_le32(data) != PKT_BIN_DEBUG_MAGIC) |
| 228 | +#else |
| 229 | if (get_unaligned_le32(data) != FW_BIN_LOG_MAGIC) |
| 230 | +#endif |
| 231 | return false; |
| 232 | |
| 233 | if (dev->relay_fwlog) |
| 234 | diff --git a/mt7915/mac.c b/mt7915/mac.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 235 | index a9bdb65..2650b87 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 236 | --- a/mt7915/mac.c |
| 237 | +++ b/mt7915/mac.c |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 238 | @@ -275,6 +275,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 239 | __le16 fc = 0; |
| 240 | int idx; |
| 241 | |
| 242 | +#ifdef MTK_DEBUG |
| 243 | + if (dev->dbg.dump_rx_raw) |
| 244 | + mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX_RAW, 0); |
| 245 | +#endif |
| 246 | memset(status, 0, sizeof(*status)); |
| 247 | |
developer | 17bb0a8 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 248 | if ((rxd1 & MT_RXD1_NORMAL_BAND_IDX) && !phy->mt76->band_idx) { |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 249 | @@ -459,6 +463,10 @@ mt7915_mac_fill_rx(struct mt7915_dev *dev, struct sk_buff *skb, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 250 | } |
| 251 | |
| 252 | hdr_gap = (u8 *)rxd - skb->data + 2 * remove_pad; |
| 253 | +#ifdef MTK_DEBUG |
| 254 | + if (dev->dbg.dump_rx_pkt) |
| 255 | + mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_RX, hdr_gap); |
| 256 | +#endif |
| 257 | if (hdr_trans && ieee80211_has_morefrags(fc)) { |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 258 | struct ieee80211_vif *vif; |
| 259 | int err; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 260 | @@ -796,6 +804,12 @@ int mt7915_tx_prepare_skb(struct mt76_dev *mdev, void *txwi_ptr, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 261 | tx_info->buf[1].skip_unmap = true; |
| 262 | tx_info->nbuf = MT_CT_DMA_BUF_NUM; |
| 263 | |
| 264 | +#ifdef MTK_DEBUG |
| 265 | + if (dev->dbg.dump_txd) |
| 266 | + mt7915_packet_log_to_host(dev, txwi, MT_TXD_SIZE, PKT_BIN_DEBUG_TXD, 0); |
| 267 | + if (dev->dbg.dump_tx_pkt) |
| 268 | + mt7915_packet_log_to_host(dev, t->skb->data, t->skb->len, PKT_BIN_DEBUG_TX, 0); |
| 269 | +#endif |
| 270 | return 0; |
| 271 | } |
| 272 | |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 273 | diff --git a/mt7915/main.c b/mt7915/main.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 274 | index 95ad05d..b4dfe4b 100644 |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 275 | --- a/mt7915/main.c |
| 276 | +++ b/mt7915/main.c |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 277 | @@ -73,7 +73,11 @@ int mt7915_run(struct ieee80211_hw *hw) |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 278 | if (ret) |
| 279 | goto out; |
| 280 | |
| 281 | +#ifdef MTK_DEBUG |
| 282 | + ret = mt7915_mcu_set_sku_en(phy, !dev->dbg.sku_disable); |
| 283 | +#else |
| 284 | ret = mt7915_mcu_set_sku_en(phy, true); |
| 285 | +#endif |
| 286 | if (ret) |
| 287 | goto out; |
| 288 | |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 289 | diff --git a/mt7915/mcu.c b/mt7915/mcu.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 290 | index e9d7f20..47e178f 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 291 | --- a/mt7915/mcu.c |
| 292 | +++ b/mt7915/mcu.c |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 293 | @@ -205,6 +205,11 @@ mt7915_mcu_send_message(struct mt76_dev *mdev, struct sk_buff *skb, |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 294 | else |
| 295 | qid = MT_MCUQ_WM; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 296 | |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 297 | +#ifdef MTK_DEBUG |
| 298 | + if (dev->dbg.dump_mcu_pkt) |
| 299 | + mt7915_packet_log_to_host(dev, skb->data, skb->len, PKT_BIN_DEBUG_MCU, 0); |
| 300 | +#endif |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 301 | + |
| 302 | return mt76_tx_queue_skb_raw(dev, mdev->q_mcu[qid], skb, 0); |
| 303 | } |
| 304 | |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 305 | @@ -2297,7 +2302,10 @@ static int mt7915_red_set_watermark(struct mt7915_dev *dev) |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 306 | sizeof(req), false); |
| 307 | } |
| 308 | |
| 309 | -static int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled) |
| 310 | +#ifndef MTK_DEBUG |
| 311 | +static |
| 312 | +#endif |
| 313 | +int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled) |
| 314 | { |
| 315 | #define RED_DISABLE 0 |
| 316 | #define RED_BY_WA_ENABLE 2 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 317 | @@ -3360,6 +3368,8 @@ int mt7915_mcu_set_sku_en(struct mt7915_phy *phy, bool enable) |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 318 | .sku_enable = enable, |
| 319 | }; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 320 | |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 321 | + pr_info("%s: enable = %d\n", __func__, enable); |
| 322 | + |
| 323 | return mt76_mcu_send_msg(&dev->mt76, |
| 324 | MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 325 | sizeof(req), true); |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 326 | @@ -4014,6 +4024,23 @@ out: |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 327 | return ret; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 328 | } |
developer | bb8219b | 2022-05-03 14:10:10 +0800 | [diff] [blame] | 329 | |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 330 | +#ifdef MTK_DEBUG |
| 331 | +int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp) |
| 332 | +{ |
| 333 | + struct { |
| 334 | + __le32 args[3]; |
| 335 | + } req = { |
| 336 | + .args = { |
| 337 | + cpu_to_le32(a1), |
| 338 | + cpu_to_le32(a2), |
| 339 | + cpu_to_le32(a3), |
| 340 | + }, |
| 341 | + }; |
| 342 | + |
| 343 | + return mt76_mcu_send_msg(&dev->mt76, cmd, &req, sizeof(req), wait_resp); |
| 344 | +} |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 345 | +#endif |
developer | bb8219b | 2022-05-03 14:10:10 +0800 | [diff] [blame] | 346 | + |
| 347 | int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set) |
| 348 | { |
| 349 | struct { |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 350 | @@ -4042,3 +4069,22 @@ int mt7915_mcu_rf_regval(struct mt7915_dev *dev, u32 regidx, u32 *val, bool set) |
developer | b1654ad | 2022-09-27 10:30:15 +0800 | [diff] [blame] | 351 | |
| 352 | return 0; |
| 353 | } |
| 354 | + |
| 355 | +#ifdef MTK_DEBUG |
| 356 | +int mt7915_mcu_set_amsdu_algo(struct mt7915_dev *dev, u16 wcid, u8 enable) |
| 357 | +{ |
| 358 | + struct { |
| 359 | + u16 action; |
| 360 | + u8 _rsv1[2]; |
| 361 | + u16 wcid; |
| 362 | + u8 enable; |
| 363 | + u8 _rsv2[5]; |
| 364 | + } __packed req = { |
| 365 | + .action = cpu_to_le16(1), |
| 366 | + .wcid = cpu_to_le16(wcid), |
| 367 | + .enable = enable, |
| 368 | + }; |
| 369 | + |
| 370 | + return mt76_mcu_send_msg(&dev->mt76, MCU_EXT_CMD(MEC_CTRL), &req, sizeof(req), true); |
| 371 | +} |
| 372 | +#endif |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 373 | diff --git a/mt7915/mcu.h b/mt7915/mcu.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 374 | index 8f36546..dd3b506 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 375 | --- a/mt7915/mcu.h |
| 376 | +++ b/mt7915/mcu.h |
developer | 7af0f76 | 2023-05-22 15:16:16 +0800 | [diff] [blame] | 377 | @@ -333,6 +333,10 @@ enum { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 378 | MCU_WA_PARAM_PDMA_RX = 0x04, |
| 379 | MCU_WA_PARAM_CPU_UTIL = 0x0b, |
| 380 | MCU_WA_PARAM_RED = 0x0e, |
| 381 | +#ifdef MTK_DEBUG |
| 382 | + MCU_WA_PARAM_RED_SHOW_STA = 0xf, |
| 383 | + MCU_WA_PARAM_RED_TARGET_DELAY = 0x10, |
| 384 | +#endif |
developer | 60a3d66 | 2023-02-07 15:24:34 +0800 | [diff] [blame] | 385 | MCU_WA_PARAM_RED_SETTING = 0x40, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 386 | }; |
| 387 | |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 388 | diff --git a/mt7915/mt7915.h b/mt7915/mt7915.h |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 389 | index 35458ec..887c4a5 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 390 | --- a/mt7915/mt7915.h |
| 391 | +++ b/mt7915/mt7915.h |
| 392 | @@ -9,6 +9,7 @@ |
| 393 | #include "../mt76_connac.h" |
| 394 | #include "regs.h" |
| 395 | |
| 396 | +#define MTK_DEBUG 1 |
| 397 | #define MT7915_MAX_INTERFACES 19 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 398 | #define MT7915_WTBL_SIZE 288 |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 399 | #define MT7916_WTBL_SIZE 544 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 400 | @@ -322,6 +323,28 @@ struct mt7915_dev { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 401 | struct reset_control *rstc; |
| 402 | void __iomem *dcm; |
| 403 | void __iomem *sku; |
| 404 | + |
| 405 | +#ifdef MTK_DEBUG |
| 406 | + u16 wlan_idx; |
| 407 | + struct { |
| 408 | + u32 fixed_rate; |
| 409 | + u32 l1debugfs_reg; |
| 410 | + u32 l2debugfs_reg; |
| 411 | + u32 mac_reg; |
| 412 | + u32 fw_dbg_module; |
| 413 | + u8 fw_dbg_lv; |
| 414 | + u32 bcn_total_cnt[2]; |
| 415 | + u16 fwlog_seq; |
| 416 | + bool dump_mcu_pkt; |
| 417 | + bool dump_txd; |
| 418 | + bool dump_tx_pkt; |
| 419 | + bool dump_rx_pkt; |
| 420 | + bool dump_rx_raw; |
| 421 | + u32 token_idx; |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 422 | + u8 sku_disable; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 423 | + } dbg; |
| 424 | + const struct mt7915_dbg_reg_desc *dbg_reg; |
| 425 | +#endif |
| 426 | }; |
| 427 | |
| 428 | enum { |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 429 | @@ -601,4 +624,24 @@ void mt7915_sta_add_debugfs(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 430 | int mt7915_mmio_wed_init(struct mt7915_dev *dev, void *pdev_ptr, |
| 431 | bool pci, int *irq); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 432 | |
| 433 | +#ifdef MTK_DEBUG |
| 434 | +int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir); |
| 435 | +int mt7915_dbg_mcu_wa_cmd(struct mt7915_dev *dev, int cmd, u32 a1, u32 a2, u32 a3, bool wait_resp); |
| 436 | +int mt7915_mcu_set_red(struct mt7915_dev *dev, bool enabled); |
| 437 | +void mt7915_dump_tmac_info(u8 *tmac_info); |
| 438 | +int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level); |
| 439 | +void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len); |
developer | b1654ad | 2022-09-27 10:30:15 +0800 | [diff] [blame] | 440 | +int mt7915_mcu_set_amsdu_algo(struct mt7915_dev *dev, u16 wcid, u8 enable); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 441 | + |
| 442 | +#define PKT_BIN_DEBUG_MAGIC 0xc8763123 |
| 443 | +enum { |
| 444 | + PKT_BIN_DEBUG_MCU, |
| 445 | + PKT_BIN_DEBUG_TXD, |
| 446 | + PKT_BIN_DEBUG_TX, |
| 447 | + PKT_BIN_DEBUG_RX, |
| 448 | + PKT_BIN_DEBUG_RX_RAW, |
| 449 | +}; |
| 450 | + |
| 451 | +#endif |
| 452 | + |
| 453 | #endif |
| 454 | diff --git a/mt7915/mt7915_debug.h b/mt7915/mt7915_debug.h |
| 455 | new file mode 100644 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 456 | index 0000000..fa8794f |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 457 | --- /dev/null |
| 458 | +++ b/mt7915/mt7915_debug.h |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 459 | @@ -0,0 +1,1418 @@ |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 460 | +#ifndef __MT7915_DEBUG_H |
| 461 | +#define __MT7915_DEBUG_H |
| 462 | + |
| 463 | +#ifdef MTK_DEBUG |
| 464 | + |
| 465 | +#define DBG_INVALID_BASE 0xffffffff |
| 466 | +#define DBG_INVALID_OFFSET 0x0 |
| 467 | + |
| 468 | +struct __dbg_map { |
| 469 | + u32 phys; |
| 470 | + u32 maps; |
| 471 | + u32 size; |
| 472 | +}; |
| 473 | + |
| 474 | +struct __dbg_reg { |
| 475 | + u32 base; |
| 476 | + u32 offs; |
| 477 | +}; |
| 478 | + |
| 479 | +struct __dbg_mask { |
| 480 | + u32 end; |
| 481 | + u32 start; |
| 482 | +}; |
| 483 | + |
| 484 | +enum dbg_base_rev { |
| 485 | + MT_DBG_WFDMA0_BASE, |
| 486 | + MT_DBG_WFDMA1_BASE, |
| 487 | + MT_DBG_WFDMA0_PCIE1_BASE, |
| 488 | + MT_DBG_WFDMA1_PCIE1_BASE, |
| 489 | + MT_DBG_WFDMA_EXT_CSR_BASE, |
| 490 | + MT_DBG_SWDEF_BASE, |
| 491 | + __MT_DBG_BASE_REV_MAX, |
| 492 | +}; |
| 493 | + |
| 494 | +enum dbg_reg_rev { |
| 495 | + DBG_INT_SOURCE_CSR, |
| 496 | + DBG_INT_MASK_CSR, |
| 497 | + DBG_INT1_SOURCE_CSR, |
| 498 | + DBG_INT1_MASK_CSR, |
| 499 | + DBG_TX_RING_BASE, |
| 500 | + DBG_RX_EVENT_RING_BASE, |
| 501 | + DBG_RX_STS_RING_BASE, |
| 502 | + DBG_RX_DATA_RING_BASE, |
| 503 | + DBG_DMA_ICSC_FR0, |
| 504 | + DBG_DMA_ICSC_FR1, |
| 505 | + DBG_TMAC_ICSCR0, |
| 506 | + DBG_RMAC_RXICSRPT, |
| 507 | + DBG_MIB_M0SDR0, |
| 508 | + DBG_MIB_M0SDR3, |
| 509 | + DBG_MIB_M0SDR4, |
| 510 | + DBG_MIB_M0SDR5, |
| 511 | + DBG_MIB_M0SDR7, |
| 512 | + DBG_MIB_M0SDR8, |
| 513 | + DBG_MIB_M0SDR9, |
| 514 | + DBG_MIB_M0SDR10, |
| 515 | + DBG_MIB_M0SDR11, |
| 516 | + DBG_MIB_M0SDR12, |
| 517 | + DBG_MIB_M0SDR14, |
| 518 | + DBG_MIB_M0SDR15, |
| 519 | + DBG_MIB_M0SDR16, |
| 520 | + DBG_MIB_M0SDR17, |
| 521 | + DBG_MIB_M0SDR18, |
| 522 | + DBG_MIB_M0SDR19, |
| 523 | + DBG_MIB_M0SDR20, |
| 524 | + DBG_MIB_M0SDR21, |
| 525 | + DBG_MIB_M0SDR22, |
| 526 | + DBG_MIB_M0SDR23, |
| 527 | + DBG_MIB_M0DR0, |
| 528 | + DBG_MIB_M0DR1, |
| 529 | + DBG_MIB_MUBF, |
| 530 | + DBG_MIB_M0DR6, |
| 531 | + DBG_MIB_M0DR7, |
| 532 | + DBG_MIB_M0DR8, |
| 533 | + DBG_MIB_M0DR9, |
| 534 | + DBG_MIB_M0DR10, |
| 535 | + DBG_MIB_M0DR11, |
| 536 | + DBG_MIB_M0DR12, |
| 537 | + DBG_WTBLON_WDUCR, |
| 538 | + DBG_UWTBL_WDUCR, |
| 539 | + DBG_PLE_DRR_TABLE_CTRL, |
| 540 | + DBG_PLE_DRR_TABLE_RDATA, |
| 541 | + DBG_PLE_PBUF_CTRL, |
| 542 | + DBG_PLE_QUEUE_EMPTY, |
| 543 | + DBG_PLE_FREEPG_CNT, |
| 544 | + DBG_PLE_FREEPG_HEAD_TAIL, |
| 545 | + DBG_PLE_PG_HIF_GROUP, |
| 546 | + DBG_PLE_HIF_PG_INFO, |
| 547 | + DBG_PLE_PG_HIF_TXCMD_GROUP, |
| 548 | + DBG_PLE_HIF_TXCMD_PG_INFO, |
| 549 | + DBG_PLE_PG_CPU_GROUP, |
| 550 | + DBG_PLE_CPU_PG_INFO, |
| 551 | + DBG_PLE_FL_QUE_CTRL, |
| 552 | + DBG_PLE_NATIVE_TXCMD_Q_EMPTY, |
| 553 | + DBG_PLE_TXCMD_Q_EMPTY, |
| 554 | + DBG_PLE_AC_QEMPTY, |
| 555 | + DBG_PLE_AC_OFFSET, |
| 556 | + DBG_PLE_STATION_PAUSE, |
| 557 | + DBG_PLE_DIS_STA_MAP, |
| 558 | + DBG_PSE_PBUF_CTRL, |
| 559 | + DBG_PSE_FREEPG_CNT, |
| 560 | + DBG_PSE_FREEPG_HEAD_TAIL, |
| 561 | + DBG_PSE_HIF0_PG_INFO, |
| 562 | + DBG_PSE_PG_HIF1_GROUP, |
| 563 | + DBG_PSE_HIF1_PG_INFO, |
| 564 | + DBG_PSE_PG_CPU_GROUP, |
| 565 | + DBG_PSE_CPU_PG_INFO, |
| 566 | + DBG_PSE_PG_PLE_GROUP, |
| 567 | + DBG_PSE_PLE_PG_INFO, |
| 568 | + DBG_PSE_PG_LMAC0_GROUP, |
| 569 | + DBG_PSE_LMAC0_PG_INFO, |
| 570 | + DBG_PSE_PG_LMAC1_GROUP, |
| 571 | + DBG_PSE_LMAC1_PG_INFO, |
| 572 | + DBG_PSE_PG_LMAC2_GROUP, |
| 573 | + DBG_PSE_LMAC2_PG_INFO, |
| 574 | + DBG_PSE_PG_LMAC3_GROUP, |
| 575 | + DBG_PSE_LMAC3_PG_INFO, |
| 576 | + DBG_PSE_PG_MDP_GROUP, |
| 577 | + DBG_PSE_MDP_PG_INFO, |
| 578 | + DBG_PSE_PG_PLE1_GROUP, |
| 579 | + DBG_PSE_PLE1_PG_INFO, |
| 580 | + DBG_AGG_AALCR0, |
| 581 | + DBG_AGG_AALCR1, |
| 582 | + DBG_AGG_AALCR2, |
| 583 | + DBG_AGG_AALCR3, |
| 584 | + DBG_AGG_AALCR4, |
| 585 | + DBG_AGG_B0BRR0, |
| 586 | + DBG_AGG_B1BRR0, |
| 587 | + DBG_AGG_B2BRR0, |
| 588 | + DBG_AGG_B3BRR0, |
| 589 | + DBG_AGG_AWSCR0, |
| 590 | + DBG_AGG_PCR0, |
| 591 | + DBG_AGG_TTCR0, |
| 592 | + DBG_MIB_M0ARNG0, |
| 593 | + DBG_MIB_M0DR2, |
| 594 | + DBG_MIB_M0DR13, |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 595 | + DBG_WFDMA_WED_TX_CTRL, |
| 596 | + DBG_WFDMA_WED_RX_CTRL, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 597 | + __MT_DBG_REG_REV_MAX, |
| 598 | +}; |
| 599 | + |
| 600 | +enum dbg_mask_rev { |
| 601 | + DBG_MIB_M0SDR10_RX_MDRDY_COUNT, |
| 602 | + DBG_MIB_M0SDR14_AMPDU, |
| 603 | + DBG_MIB_M0SDR15_AMPDU_ACKED, |
| 604 | + DBG_MIB_RX_FCS_ERROR_COUNT, |
| 605 | + __MT_DBG_MASK_REV_MAX, |
| 606 | +}; |
| 607 | + |
| 608 | +enum dbg_bit_rev { |
| 609 | + __MT_DBG_BIT_REV_MAX, |
| 610 | +}; |
| 611 | + |
| 612 | +static const u32 mt7915_dbg_base[] = { |
| 613 | + [MT_DBG_WFDMA0_BASE] = 0xd4000, |
| 614 | + [MT_DBG_WFDMA1_BASE] = 0xd5000, |
| 615 | + [MT_DBG_WFDMA0_PCIE1_BASE] = 0xd8000, |
| 616 | + [MT_DBG_WFDMA1_PCIE1_BASE] = 0xd9000, |
| 617 | + [MT_DBG_WFDMA_EXT_CSR_BASE] = 0xd7000, |
| 618 | + [MT_DBG_SWDEF_BASE] = 0x41f200, |
| 619 | +}; |
| 620 | + |
| 621 | +static const u32 mt7916_dbg_base[] = { |
| 622 | + [MT_DBG_WFDMA0_BASE] = 0xd4000, |
| 623 | + [MT_DBG_WFDMA1_BASE] = 0xd5000, |
| 624 | + [MT_DBG_WFDMA0_PCIE1_BASE] = 0xd8000, |
| 625 | + [MT_DBG_WFDMA1_PCIE1_BASE] = 0xd9000, |
| 626 | + [MT_DBG_WFDMA_EXT_CSR_BASE] = 0xd7000, |
| 627 | + [MT_DBG_SWDEF_BASE] = 0x411400, |
| 628 | +}; |
| 629 | + |
| 630 | +static const u32 mt7986_dbg_base[] = { |
| 631 | + [MT_DBG_WFDMA0_BASE] = 0x24000, |
| 632 | + [MT_DBG_WFDMA1_BASE] = 0x25000, |
| 633 | + [MT_DBG_WFDMA0_PCIE1_BASE] = 0x28000, |
| 634 | + [MT_DBG_WFDMA1_PCIE1_BASE] = 0x29000, |
| 635 | + [MT_DBG_WFDMA_EXT_CSR_BASE] = 0x27000, |
| 636 | + [MT_DBG_SWDEF_BASE] = 0x411400, |
| 637 | +}; |
| 638 | + |
| 639 | +/* mt7915 regs with different base and offset */ |
| 640 | +static const struct __dbg_reg mt7915_dbg_reg[] = { |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 641 | + [DBG_WFDMA_WED_TX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x300 }, |
| 642 | + [DBG_WFDMA_WED_RX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x400 }, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 643 | + [DBG_INT_SOURCE_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x10 }, |
| 644 | + [DBG_INT_MASK_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x14 }, |
| 645 | + [DBG_INT1_SOURCE_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x88 }, |
| 646 | + [DBG_INT1_MASK_CSR] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x8c }, |
| 647 | + [DBG_TX_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x400 }, |
| 648 | + [DBG_RX_EVENT_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x500 }, |
| 649 | + [DBG_RX_STS_RING_BASE] = { MT_DBG_WFDMA1_BASE, 0x510 }, |
| 650 | + [DBG_RX_DATA_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x500 }, |
| 651 | + [DBG_DMA_ICSC_FR0] = { DBG_INVALID_BASE, 0x0f0 }, |
| 652 | + [DBG_DMA_ICSC_FR1] = { DBG_INVALID_BASE, 0x0f4 }, |
| 653 | + [DBG_TMAC_ICSCR0] = { DBG_INVALID_BASE, 0x200 }, |
| 654 | + [DBG_RMAC_RXICSRPT] = { DBG_INVALID_BASE, 0x618}, |
| 655 | + [DBG_MIB_M0SDR0] = { DBG_INVALID_BASE, 0x010}, |
| 656 | + [DBG_MIB_M0SDR3] = { DBG_INVALID_BASE, 0x014}, |
| 657 | + [DBG_MIB_M0SDR4] = { DBG_INVALID_BASE, 0x018}, |
| 658 | + [DBG_MIB_M0SDR5] = { DBG_INVALID_BASE, 0x01c}, |
| 659 | + [DBG_MIB_M0SDR7] = { DBG_INVALID_BASE, 0x024}, |
| 660 | + [DBG_MIB_M0SDR8] = { DBG_INVALID_BASE, 0x028}, |
| 661 | + [DBG_MIB_M0SDR9] = { DBG_INVALID_BASE, 0x02C}, |
| 662 | + [DBG_MIB_M0SDR10] = { DBG_INVALID_BASE, 0x030}, |
| 663 | + [DBG_MIB_M0SDR11] = { DBG_INVALID_BASE, 0x034}, |
| 664 | + [DBG_MIB_M0SDR12] = { DBG_INVALID_BASE, 0x038}, |
| 665 | + [DBG_MIB_M0SDR14] = { DBG_INVALID_BASE, 0x040}, |
| 666 | + [DBG_MIB_M0SDR15] = { DBG_INVALID_BASE, 0x044}, |
| 667 | + [DBG_MIB_M0SDR16] = { DBG_INVALID_BASE, 0x048}, |
| 668 | + [DBG_MIB_M0SDR17] = { DBG_INVALID_BASE, 0x04c}, |
| 669 | + [DBG_MIB_M0SDR18] = { DBG_INVALID_BASE, 0x050}, |
| 670 | + [DBG_MIB_M0SDR19] = { DBG_INVALID_BASE, 0x054}, |
| 671 | + [DBG_MIB_M0SDR20] = { DBG_INVALID_BASE, 0x058}, |
| 672 | + [DBG_MIB_M0SDR21] = { DBG_INVALID_BASE, 0x05c}, |
| 673 | + [DBG_MIB_M0SDR22] = { DBG_INVALID_BASE, 0x060}, |
| 674 | + [DBG_MIB_M0SDR23] = { DBG_INVALID_BASE, 0x064}, |
| 675 | + [DBG_MIB_M0DR0] = { DBG_INVALID_BASE, 0x0a0}, |
| 676 | + [DBG_MIB_M0DR1] = { DBG_INVALID_BASE, 0x0a4}, |
| 677 | + [DBG_MIB_MUBF] = { DBG_INVALID_BASE, 0x090}, |
| 678 | + [DBG_MIB_M0DR6] = { DBG_INVALID_BASE, 0x0b8}, |
| 679 | + [DBG_MIB_M0DR7] = { DBG_INVALID_BASE, 0x0bc}, |
| 680 | + [DBG_MIB_M0DR8] = { DBG_INVALID_BASE, 0x0c0}, |
| 681 | + [DBG_MIB_M0DR9] = { DBG_INVALID_BASE, 0x0c4}, |
| 682 | + [DBG_MIB_M0DR10] = { DBG_INVALID_BASE, 0x0c8}, |
| 683 | + [DBG_MIB_M0DR11] = { DBG_INVALID_BASE, 0x0cc}, |
| 684 | + [DBG_MIB_M0DR12] = { DBG_INVALID_BASE, 0x160}, |
| 685 | + [DBG_WTBLON_WDUCR] = { DBG_INVALID_BASE, 0x0}, |
| 686 | + [DBG_UWTBL_WDUCR] = { DBG_INVALID_BASE, 0x0}, |
| 687 | + [DBG_PLE_DRR_TABLE_CTRL] = { DBG_INVALID_BASE, 0x388}, |
| 688 | + [DBG_PLE_DRR_TABLE_RDATA] = { DBG_INVALID_BASE, 0x350}, |
| 689 | + [DBG_PLE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x014}, |
| 690 | + [DBG_PLE_QUEUE_EMPTY] = { DBG_INVALID_BASE, 0x0b0}, |
| 691 | + [DBG_PLE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x100}, |
| 692 | + [DBG_PLE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x104}, |
| 693 | + [DBG_PLE_PG_HIF_GROUP] = { DBG_INVALID_BASE, 0x110}, |
| 694 | + [DBG_PLE_HIF_PG_INFO] = { DBG_INVALID_BASE, 0x114}, |
| 695 | + [DBG_PLE_PG_HIF_TXCMD_GROUP] = { DBG_INVALID_BASE, 0x120}, |
| 696 | + [DBG_PLE_HIF_TXCMD_PG_INFO] = { DBG_INVALID_BASE, 0x124}, |
| 697 | + [DBG_PLE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x150}, |
| 698 | + [DBG_PLE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x154}, |
| 699 | + [DBG_PLE_FL_QUE_CTRL] = { DBG_INVALID_BASE, 0x1b0}, |
| 700 | + [DBG_PLE_NATIVE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x22c}, |
| 701 | + [DBG_PLE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x230}, |
| 702 | + [DBG_PLE_AC_QEMPTY] = { DBG_INVALID_BASE, 0x500}, |
| 703 | + [DBG_PLE_AC_OFFSET] = { DBG_INVALID_BASE, 0x040}, |
| 704 | + [DBG_PLE_STATION_PAUSE] = { DBG_INVALID_BASE, 0x400}, |
| 705 | + [DBG_PLE_DIS_STA_MAP] = { DBG_INVALID_BASE, 0x440}, |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 706 | + [DBG_PSE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x014}, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 707 | + [DBG_PSE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x100}, |
| 708 | + [DBG_PSE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x104}, |
| 709 | + [DBG_PSE_HIF0_PG_INFO] = { DBG_INVALID_BASE, 0x114}, |
| 710 | + [DBG_PSE_PG_HIF1_GROUP] = { DBG_INVALID_BASE, 0x118}, |
| 711 | + [DBG_PSE_HIF1_PG_INFO] = { DBG_INVALID_BASE, 0x11c}, |
| 712 | + [DBG_PSE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x150}, |
| 713 | + [DBG_PSE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x154}, |
| 714 | + [DBG_PSE_PG_PLE_GROUP] = { DBG_INVALID_BASE, 0x160}, |
| 715 | + [DBG_PSE_PLE_PG_INFO] = { DBG_INVALID_BASE, 0x164}, |
| 716 | + [DBG_PSE_PG_LMAC0_GROUP] = { DBG_INVALID_BASE, 0x170}, |
| 717 | + [DBG_PSE_LMAC0_PG_INFO] = { DBG_INVALID_BASE, 0x174}, |
| 718 | + [DBG_PSE_PG_LMAC1_GROUP] = { DBG_INVALID_BASE, 0x178}, |
| 719 | + [DBG_PSE_LMAC1_PG_INFO] = { DBG_INVALID_BASE, 0x17c}, |
| 720 | + [DBG_PSE_PG_LMAC2_GROUP] = { DBG_INVALID_BASE, 0x180}, |
| 721 | + [DBG_PSE_LMAC2_PG_INFO] = { DBG_INVALID_BASE, 0x184}, |
| 722 | + [DBG_PSE_PG_LMAC3_GROUP] = { DBG_INVALID_BASE, 0x188}, |
| 723 | + [DBG_PSE_LMAC3_PG_INFO] = { DBG_INVALID_BASE, 0x18c}, |
| 724 | + [DBG_PSE_PG_MDP_GROUP] = { DBG_INVALID_BASE, 0x198}, |
| 725 | + [DBG_PSE_MDP_PG_INFO] = { DBG_INVALID_BASE, 0x19c}, |
| 726 | + [DBG_PSE_PG_PLE1_GROUP] = { DBG_INVALID_BASE, 0x168}, |
| 727 | + [DBG_PSE_PLE1_PG_INFO] = { DBG_INVALID_BASE, 0x16c}, |
| 728 | + [DBG_AGG_AALCR0] = { DBG_INVALID_BASE, 0x048}, |
| 729 | + [DBG_AGG_AALCR1] = { DBG_INVALID_BASE, 0x04c}, |
| 730 | + [DBG_AGG_AALCR2] = { DBG_INVALID_BASE, 0x050}, |
| 731 | + [DBG_AGG_AALCR3] = { DBG_INVALID_BASE, 0x054}, |
| 732 | + [DBG_AGG_AALCR4] = { DBG_INVALID_BASE, 0x058}, |
| 733 | + [DBG_AGG_B0BRR0] = { DBG_INVALID_BASE, 0x100}, |
| 734 | + [DBG_AGG_B1BRR0] = { DBG_INVALID_BASE, 0x104}, |
| 735 | + [DBG_AGG_B2BRR0] = { DBG_INVALID_BASE, 0x108}, |
| 736 | + [DBG_AGG_B3BRR0] = { DBG_INVALID_BASE, 0x10c}, |
| 737 | + [DBG_AGG_AWSCR0] = { DBG_INVALID_BASE, 0x030}, |
| 738 | + [DBG_AGG_PCR0] = { DBG_INVALID_BASE, 0x040}, |
| 739 | + [DBG_AGG_TTCR0] = { DBG_INVALID_BASE, 0x04c}, |
| 740 | + [DBG_MIB_M0ARNG0] = { DBG_INVALID_BASE, 0x4b8}, |
| 741 | + [DBG_MIB_M0DR2] = { DBG_INVALID_BASE, 0x0a8}, |
| 742 | + [DBG_MIB_M0DR13] = { DBG_INVALID_BASE, 0x164}, |
| 743 | +}; |
| 744 | + |
| 745 | +/* mt7986/mt7916 regs with different base and offset */ |
| 746 | +static const struct __dbg_reg mt7916_dbg_reg[] = { |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 747 | + [DBG_WFDMA_WED_TX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x300 }, |
| 748 | + [DBG_WFDMA_WED_RX_CTRL] = { MT_DBG_WFDMA_EXT_CSR_BASE, 0x400 }, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 749 | + [DBG_INT_SOURCE_CSR] = { MT_DBG_WFDMA0_BASE, 0x200 }, |
| 750 | + [DBG_INT_MASK_CSR] = { MT_DBG_WFDMA0_BASE, 0x204 }, |
| 751 | + [DBG_INT1_SOURCE_CSR] = { MT_DBG_WFDMA0_PCIE1_BASE, 0x200 }, |
| 752 | + [DBG_INT1_MASK_CSR] = { MT_DBG_WFDMA0_PCIE1_BASE, 0x204 }, |
| 753 | + [DBG_TX_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x400 }, |
| 754 | + [DBG_RX_EVENT_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x500 }, |
| 755 | + [DBG_RX_STS_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x520 }, |
| 756 | + [DBG_RX_DATA_RING_BASE] = { MT_DBG_WFDMA0_BASE, 0x540 }, |
| 757 | + [DBG_DMA_ICSC_FR0] = { DBG_INVALID_BASE, 0x05c }, |
| 758 | + [DBG_DMA_ICSC_FR1] = { DBG_INVALID_BASE, 0x060 }, |
| 759 | + [DBG_TMAC_ICSCR0] = { DBG_INVALID_BASE, 0x120 }, |
| 760 | + [DBG_RMAC_RXICSRPT] = { DBG_INVALID_BASE, 0xd0 }, |
| 761 | + [DBG_MIB_M0SDR0] = { DBG_INVALID_BASE, 0x7d8}, |
| 762 | + [DBG_MIB_M0SDR3] = { DBG_INVALID_BASE, 0x698}, |
| 763 | + [DBG_MIB_M0SDR4] = { DBG_INVALID_BASE, 0x788}, |
| 764 | + [DBG_MIB_M0SDR5] = { DBG_INVALID_BASE, 0x780}, |
| 765 | + [DBG_MIB_M0SDR7] = { DBG_INVALID_BASE, 0x5a8}, |
| 766 | + [DBG_MIB_M0SDR8] = { DBG_INVALID_BASE, 0x78c}, |
| 767 | + [DBG_MIB_M0SDR9] = { DBG_INVALID_BASE, 0x024}, |
| 768 | + [DBG_MIB_M0SDR10] = { DBG_INVALID_BASE, 0x76c}, |
| 769 | + [DBG_MIB_M0SDR11] = { DBG_INVALID_BASE, 0x790}, |
| 770 | + [DBG_MIB_M0SDR12] = { DBG_INVALID_BASE, 0x558}, |
| 771 | + [DBG_MIB_M0SDR14] = { DBG_INVALID_BASE, 0x564}, |
| 772 | + [DBG_MIB_M0SDR15] = { DBG_INVALID_BASE, 0x564}, |
| 773 | + [DBG_MIB_M0SDR16] = { DBG_INVALID_BASE, 0x7fc}, |
| 774 | + [DBG_MIB_M0SDR17] = { DBG_INVALID_BASE, 0x800}, |
| 775 | + [DBG_MIB_M0SDR18] = { DBG_INVALID_BASE, 0x030}, |
| 776 | + [DBG_MIB_M0SDR19] = { DBG_INVALID_BASE, 0x5ac}, |
| 777 | + [DBG_MIB_M0SDR20] = { DBG_INVALID_BASE, 0x5b0}, |
| 778 | + [DBG_MIB_M0SDR21] = { DBG_INVALID_BASE, 0x5b4}, |
| 779 | + [DBG_MIB_M0SDR22] = { DBG_INVALID_BASE, 0x770}, |
| 780 | + [DBG_MIB_M0SDR23] = { DBG_INVALID_BASE, 0x774}, |
| 781 | + [DBG_MIB_M0DR0] = { DBG_INVALID_BASE, 0x594}, |
| 782 | + [DBG_MIB_M0DR1] = { DBG_INVALID_BASE, 0x598}, |
| 783 | + [DBG_MIB_MUBF] = { DBG_INVALID_BASE, 0x7ac}, |
| 784 | + [DBG_MIB_M0DR6] = { DBG_INVALID_BASE, 0x658}, |
| 785 | + [DBG_MIB_M0DR7] = { DBG_INVALID_BASE, 0x65c}, |
| 786 | + [DBG_MIB_M0DR8] = { DBG_INVALID_BASE, 0x56c}, |
| 787 | + [DBG_MIB_M0DR9] = { DBG_INVALID_BASE, 0x570}, |
| 788 | + [DBG_MIB_M0DR10] = { DBG_INVALID_BASE, 0x578}, |
| 789 | + [DBG_MIB_M0DR11] = { DBG_INVALID_BASE, 0x574}, |
| 790 | + [DBG_MIB_M0DR12] = { DBG_INVALID_BASE, 0x654}, |
| 791 | + [DBG_WTBLON_WDUCR] = { DBG_INVALID_BASE, 0x200}, |
| 792 | + [DBG_UWTBL_WDUCR] = { DBG_INVALID_BASE, 0x094}, |
| 793 | + [DBG_PLE_DRR_TABLE_CTRL] = { DBG_INVALID_BASE, 0x490}, |
| 794 | + [DBG_PLE_DRR_TABLE_RDATA] = { DBG_INVALID_BASE, 0x470}, |
| 795 | + [DBG_PLE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x004}, |
| 796 | + [DBG_PLE_QUEUE_EMPTY] = { DBG_INVALID_BASE, 0x360}, |
| 797 | + [DBG_PLE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x380}, |
| 798 | + [DBG_PLE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x384}, |
| 799 | + [DBG_PLE_PG_HIF_GROUP] = { DBG_INVALID_BASE, 0x00c}, |
| 800 | + [DBG_PLE_HIF_PG_INFO] = { DBG_INVALID_BASE, 0x388}, |
| 801 | + [DBG_PLE_PG_HIF_TXCMD_GROUP] = { DBG_INVALID_BASE, 0x014}, |
| 802 | + [DBG_PLE_HIF_TXCMD_PG_INFO] = { DBG_INVALID_BASE, 0x390}, |
| 803 | + [DBG_PLE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x018}, |
| 804 | + [DBG_PLE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x394}, |
| 805 | + [DBG_PLE_FL_QUE_CTRL] = { DBG_INVALID_BASE, 0x3e0}, |
| 806 | + [DBG_PLE_NATIVE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x370}, |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 807 | + [DBG_PLE_TXCMD_Q_EMPTY] = { DBG_INVALID_BASE, 0x36c}, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 808 | + [DBG_PLE_AC_QEMPTY] = { DBG_INVALID_BASE, 0x600}, |
| 809 | + [DBG_PLE_AC_OFFSET] = { DBG_INVALID_BASE, 0x080}, |
| 810 | + [DBG_PLE_STATION_PAUSE] = { DBG_INVALID_BASE, 0x100}, |
| 811 | + [DBG_PLE_DIS_STA_MAP] = { DBG_INVALID_BASE, 0x180}, |
| 812 | + [DBG_PSE_PBUF_CTRL] = { DBG_INVALID_BASE, 0x004}, |
| 813 | + [DBG_PSE_FREEPG_CNT] = { DBG_INVALID_BASE, 0x380}, |
| 814 | + [DBG_PSE_FREEPG_HEAD_TAIL] = { DBG_INVALID_BASE, 0x384}, |
| 815 | + [DBG_PSE_HIF0_PG_INFO] = { DBG_INVALID_BASE, 0x150}, |
| 816 | + [DBG_PSE_PG_HIF1_GROUP] = { DBG_INVALID_BASE, 0x154}, |
| 817 | + [DBG_PSE_HIF1_PG_INFO] = { DBG_INVALID_BASE, 0x160}, |
| 818 | + [DBG_PSE_PG_CPU_GROUP] = { DBG_INVALID_BASE, 0x118}, |
| 819 | + [DBG_PSE_CPU_PG_INFO] = { DBG_INVALID_BASE, 0x158}, |
| 820 | + [DBG_PSE_PG_PLE_GROUP] = { DBG_INVALID_BASE, 0x11c}, |
| 821 | + [DBG_PSE_PLE_PG_INFO] = { DBG_INVALID_BASE, 0x15c}, |
| 822 | + [DBG_PSE_PG_LMAC0_GROUP] = { DBG_INVALID_BASE, 0x124}, |
| 823 | + [DBG_PSE_LMAC0_PG_INFO] = { DBG_INVALID_BASE, 0x164}, |
| 824 | + [DBG_PSE_PG_LMAC1_GROUP] = { DBG_INVALID_BASE, 0x128}, |
| 825 | + [DBG_PSE_LMAC1_PG_INFO] = { DBG_INVALID_BASE, 0x168}, |
| 826 | + [DBG_PSE_PG_LMAC2_GROUP] = { DBG_INVALID_BASE, 0x12c}, |
| 827 | + [DBG_PSE_LMAC2_PG_INFO] = { DBG_INVALID_BASE, 0x16c}, |
| 828 | + [DBG_PSE_PG_LMAC3_GROUP] = { DBG_INVALID_BASE, 0x130}, |
| 829 | + [DBG_PSE_LMAC3_PG_INFO] = { DBG_INVALID_BASE, 0x17c}, |
| 830 | + [DBG_PSE_PG_MDP_GROUP] = { DBG_INVALID_BASE, 0x134}, |
| 831 | + [DBG_PSE_MDP_PG_INFO] = { DBG_INVALID_BASE, 0x174}, |
| 832 | + [DBG_PSE_PG_PLE1_GROUP] = { DBG_INVALID_BASE, 0x120}, |
| 833 | + [DBG_PSE_PLE1_PG_INFO] = { DBG_INVALID_BASE, 0x160}, |
| 834 | + [DBG_AGG_AALCR0] = { DBG_INVALID_BASE, 0x028}, |
| 835 | + [DBG_AGG_AALCR1] = { DBG_INVALID_BASE, 0x144}, |
| 836 | + [DBG_AGG_AALCR2] = { DBG_INVALID_BASE, 0x14c}, |
| 837 | + [DBG_AGG_AALCR3] = { DBG_INVALID_BASE, 0x154}, |
| 838 | + [DBG_AGG_AALCR4] = { DBG_INVALID_BASE, 0x02c}, |
| 839 | + [DBG_AGG_B0BRR0] = { DBG_INVALID_BASE, 0x08c}, |
| 840 | + [DBG_AGG_B1BRR0] = { DBG_INVALID_BASE, 0x148}, |
| 841 | + [DBG_AGG_B2BRR0] = { DBG_INVALID_BASE, 0x150}, |
| 842 | + [DBG_AGG_B3BRR0] = { DBG_INVALID_BASE, 0x158}, |
| 843 | + [DBG_AGG_AWSCR0] = { DBG_INVALID_BASE, 0x05c}, |
| 844 | + [DBG_AGG_PCR0] = { DBG_INVALID_BASE, 0x06c}, |
| 845 | + [DBG_AGG_TTCR0] = { DBG_INVALID_BASE, 0x07c}, |
| 846 | + [DBG_MIB_M0ARNG0] = { DBG_INVALID_BASE, 0x0b0}, |
| 847 | + [DBG_MIB_M0DR2] = { DBG_INVALID_BASE, 0x7dc}, |
| 848 | + [DBG_MIB_M0DR13] = { DBG_INVALID_BASE, 0x7ec}, |
| 849 | +}; |
| 850 | + |
| 851 | +static const struct __dbg_mask mt7915_dbg_mask[] = { |
| 852 | + [DBG_MIB_M0SDR10_RX_MDRDY_COUNT]= {25, 0}, |
| 853 | + [DBG_MIB_M0SDR14_AMPDU] = {23, 0}, |
| 854 | + [DBG_MIB_M0SDR15_AMPDU_ACKED] = {23, 0}, |
| 855 | + [DBG_MIB_RX_FCS_ERROR_COUNT] = {15, 0}, |
| 856 | +}; |
| 857 | + |
| 858 | +static const struct __dbg_mask mt7916_dbg_mask[] = { |
| 859 | + [DBG_MIB_M0SDR10_RX_MDRDY_COUNT]= {31, 0}, |
| 860 | + [DBG_MIB_M0SDR14_AMPDU] = {31, 0}, |
| 861 | + [DBG_MIB_M0SDR15_AMPDU_ACKED] = {31, 0}, |
| 862 | + [DBG_MIB_RX_FCS_ERROR_COUNT] = {31, 16}, |
| 863 | +}; |
| 864 | + |
| 865 | +/* used to differentiate between generations */ |
| 866 | +struct mt7915_dbg_reg_desc { |
| 867 | + const u32 id; |
| 868 | + const u32 *base_rev; |
| 869 | + const struct __dbg_reg *reg_rev; |
| 870 | + const struct __dbg_mask *mask_rev; |
| 871 | +}; |
| 872 | + |
| 873 | +static const struct mt7915_dbg_reg_desc dbg_reg_s[] = { |
| 874 | + { 0x7915, |
| 875 | + mt7915_dbg_base, |
| 876 | + mt7915_dbg_reg, |
| 877 | + mt7915_dbg_mask |
| 878 | + }, |
| 879 | + { 0x7906, |
| 880 | + mt7916_dbg_base, |
| 881 | + mt7916_dbg_reg, |
| 882 | + mt7916_dbg_mask |
| 883 | + }, |
| 884 | + { 0x7986, |
| 885 | + mt7986_dbg_base, |
| 886 | + mt7916_dbg_reg, |
| 887 | + mt7916_dbg_mask |
| 888 | + }, |
| 889 | +}; |
| 890 | + |
| 891 | +struct bin_debug_hdr { |
| 892 | + __le32 magic_num; |
| 893 | + __le16 serial_id; |
| 894 | + __le16 msg_type; |
| 895 | + __le16 len; |
| 896 | + __le16 des_len; /* descriptor len for rxd */ |
| 897 | +} __packed; |
| 898 | + |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 899 | +/* fw wm info related strcture */ |
| 900 | +struct cos_msg_trace_t { |
| 901 | + u32 dest_id; |
| 902 | + u8 msg_id; |
| 903 | + u32 pcount; |
| 904 | + u32 qread; |
| 905 | + u32 ts_enq; |
| 906 | + u32 ts_deq; |
| 907 | + u32 ts_finshq; |
| 908 | +}; |
| 909 | + |
| 910 | +struct cos_task_info_struct { |
| 911 | + u32 task_name_ptr; |
| 912 | + u32 task_qname_ptr; |
| 913 | + u32 task_priority; |
| 914 | + u16 task_stack_size; |
| 915 | + u8 task_ext_qsize; |
| 916 | + u32 task_id; |
| 917 | + u32 task_ext_qid; |
| 918 | + u32 task_main_func; |
| 919 | + u32 task_init_func; |
| 920 | +}; |
| 921 | + |
| 922 | +struct cos_program_trace_t{ |
| 923 | + u32 dest_id; |
| 924 | + u32 msg_id; |
| 925 | + u32 msg_sn; |
| 926 | + u32 ts_gpt2; |
| 927 | + u32 LP; |
| 928 | + char name[12]; |
| 929 | +} ; |
| 930 | + |
| 931 | +struct cos_msg_type { |
| 932 | + u32 finish_cnt; |
| 933 | + u32 exe_time; |
| 934 | + u32 exe_peak; |
| 935 | +}; |
| 936 | + |
| 937 | +struct cos_task_type{ |
| 938 | + u32 tc_stack_start; |
| 939 | + u32 tc_stack_end; |
| 940 | + u32 tc_stack_pointer; |
| 941 | + u32 tc_stack_size; |
| 942 | + u32 tc_schedule_count; |
| 943 | + u8 tc_status; |
| 944 | + u8 tc_priority; |
| 945 | + u8 tc_weight; |
| 946 | + u8 RSVD[28]; |
| 947 | + u32 tc_entry_func; |
| 948 | + u32 tc_exe_start; |
| 949 | + u32 tc_exe_time; |
| 950 | + u32 tc_exe_peak; |
| 951 | + u32 tc_pcount; |
| 952 | +}; |
| 953 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 954 | +#define __DBG_REG_MAP(_dev, id, ofs) ((_dev)->dbg_reg->base_rev[(id)] + (ofs)) |
| 955 | +#define __DBG_REG_BASE(_dev, id) ((_dev)->dbg_reg->reg_rev[(id)].base) |
| 956 | +#define __DBG_REG_OFFS(_dev, id) ((_dev)->dbg_reg->reg_rev[(id)].offs) |
| 957 | + |
| 958 | +#define __DBG_MASK(_dev, id) GENMASK((_dev)->dbg_reg->mask_rev[(id)].end, \ |
| 959 | + (_dev)->dbg_reg->mask_rev[(id)].start) |
| 960 | +#define __DBG_REG(_dev, id) __DBG_REG_MAP((_dev), __DBG_REG_BASE((_dev), (id)), \ |
| 961 | + __DBG_REG_OFFS((_dev), (id))) |
| 962 | + |
| 963 | +#define __DBG_FIELD_GET(id, _reg) (((_reg) & __DBG_MASK(dev, (id))) >> \ |
| 964 | + dev->dbg_reg->mask_rev[(id)].start) |
| 965 | +#define __DBG_FIELD_PREP(id, _reg) (((_reg) << dev->dbg_reg->mask_rev[(id)].start) & \ |
| 966 | + __DBG_MASK(dev, (id))) |
| 967 | + |
| 968 | + |
| 969 | +#define MT_DBG_TX_RING_BASE __DBG_REG(dev, DBG_TX_RING_BASE) |
| 970 | +#define MT_DBG_RX_EVENT_RING_BASE __DBG_REG(dev, DBG_RX_EVENT_RING_BASE) |
| 971 | +#define MT_DBG_RX_STS_RING_BASE __DBG_REG(dev, DBG_RX_STS_RING_BASE) |
| 972 | +#define MT_DBG_RX_DATA_RING_BASE __DBG_REG(dev, DBG_RX_DATA_RING_BASE) |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 973 | +#define MT_DBG_WFDMA_WED_TX_CTRL_BASE __DBG_REG(dev, DBG_WFDMA_WED_TX_CTRL) |
| 974 | +#define MT_DBG_WFDMA_WED_RX_CTRL_BASE __DBG_REG(dev, DBG_WFDMA_WED_RX_CTRL) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 975 | + |
| 976 | +#define MT_DBG_TX_RING_CTRL(n) (MT_DBG_TX_RING_BASE + (0x10 * (n))) |
| 977 | +#define MT_DBG_RX_DATA_RING_CTRL(n) (MT_DBG_RX_DATA_RING_BASE + (0x10 * (n))) |
| 978 | +#define MT_DBG_RX_EVENT_RING_CTRL(n) (MT_DBG_RX_EVENT_RING_BASE + (0x10 * (n))) |
| 979 | + |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 980 | +#define MT_DBG_WFDMA_WED_TX_CTRL(n) (MT_DBG_WFDMA_WED_TX_CTRL_BASE + (0x10 * (n))) |
| 981 | +#define MT_DBG_WFDMA_WED_RX_CTRL(n) (MT_DBG_WFDMA_WED_RX_CTRL_BASE + (0x10 * (n))) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 982 | +/* WFDMA COMMON */ |
| 983 | +#define MT_DBG_INT_SOURCE_CSR __DBG_REG(dev, DBG_INT_SOURCE_CSR) |
| 984 | +#define MT_DBG_INT_MASK_CSR __DBG_REG(dev, DBG_INT_MASK_CSR) |
| 985 | +#define MT_DBG_INT1_SOURCE_CSR __DBG_REG(dev, DBG_INT1_SOURCE_CSR) |
| 986 | +#define MT_DBG_INT1_MASK_CSR __DBG_REG(dev, DBG_INT1_MASK_CSR) |
| 987 | + |
| 988 | +/* WFDMA0 */ |
| 989 | +#define MT_DBG_WFDMA0(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA0_BASE, (_ofs)) |
| 990 | + |
| 991 | +#define MT_DBG_WFDMA0_INT_SOURCE_CSR MT_DBG_WFDMA0(0x200) |
| 992 | +#define MT_DBG_WFDMA0_INT_MASK_CSR MT_DBG_WFDMA0(0x204) |
| 993 | + |
| 994 | +#define MT_DBG_WFDMA0_GLO_CFG MT_DBG_WFDMA0(0x208) |
| 995 | +#define MT_DBG_WFDMA0_GLO_CFG_TX_DMA_EN BIT(0) |
| 996 | +#define MT_DBG_WFDMA0_GLO_CFG_RX_DMA_EN BIT(2) |
| 997 | +#define MT_DBG_WFDMA0_GLO_CFG_TX_BUSY_MASK BIT(1) |
| 998 | +#define MT_DBG_WFDMA0_GLO_CFG_RX_BUSY_MASK BIT(3) |
| 999 | + |
| 1000 | + |
| 1001 | +/* WFDMA1 */ |
| 1002 | +#define MT_DBG_WFDMA1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA1_BASE, (_ofs)) |
| 1003 | +#define MT_DBG_WFDMA1_INT_SOURCE_CSR MT_DBG_WFDMA1(0x200) |
| 1004 | +#define MT_DBG_WFDMA1_INT_MASK_CSR MT_DBG_WFDMA1(0x204) |
| 1005 | + |
| 1006 | +#define MT_DBG_WFDMA1_GLO_CFG MT_DBG_WFDMA1(0x208) |
| 1007 | + |
| 1008 | +#define MT_DBG_WFDMA1_GLO_CFG_TX_DMA_EN BIT(0) |
| 1009 | +#define MT_DBG_WFDMA1_GLO_CFG_RX_DMA_EN BIT(2) |
| 1010 | +#define MT_DBG_WFDMA1_GLO_CFG_TX_BUSY_MASK BIT(1) |
| 1011 | +#define MT_DBG_WFDMA1_GLO_CFG_RX_BUSY_MASK BIT(3) |
| 1012 | + |
| 1013 | +/* WFDMA0 PCIE1 */ |
| 1014 | +#define MT_DBG_WFDMA0_PCIE1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA0_PCIE1_BASE, (_ofs)) |
| 1015 | + |
| 1016 | +#define MT_DBG_WFDMA0_PCIE1_INT_SOURCE_CSR MT_DBG_WFDMA0_PCIE1(0x200) |
| 1017 | +#define MT_DBG_WFDMA0_PCIE1_INT_MASK_CSR MT_DBG_WFDMA0_PCIE1(0x204) |
| 1018 | +#define MT_DBG_WFDMA0_PCIE1_GLO_CFG MT_DBG_WFDMA0_PCIE1(0x208) |
| 1019 | +#define MT_DBG_WFDMA0_PCIE1_RX1_CTRL0 MT_DBG_WFDMA1_PCIE1(0x510) |
| 1020 | + |
| 1021 | +#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN BIT(0) |
| 1022 | +#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK BIT(1) |
| 1023 | +#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN BIT(2) |
| 1024 | +#define MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK BIT(3) |
| 1025 | + |
| 1026 | +/* WFDMA1 PCIE1 */ |
| 1027 | +#define MT_DBG_WFDMA1_PCIE1(_ofs) __DBG_REG_MAP(dev, MT_DBG_WFDMA1_PCIE1_BASE, (_ofs)) |
| 1028 | +#define MT_DBG_WFDMA1_PCIE1_INT_SOURCE_CSR MT_DBG_WFDMA1_PCIE1(0x200) |
| 1029 | +#define MT_DBG_WFDMA1_PCIE1_INT_MASK_CSR MT_DBG_WFDMA1_PCIE1(0x204) |
| 1030 | +#define MT_DBG_WFDMA1_PCIE1_GLO_CFG MT_DBG_WFDMA1_PCIE1(0x208) |
| 1031 | +#define MT_DBG_WFDMA1_PCIE1_TX19_CTRL0 MT_DBG_WFDMA1_PCIE1(0x330) |
| 1032 | +#define MT_DBG_WFDMA1_PCIE1_RX2_CTRL0 MT_DBG_WFDMA1_PCIE1(0x520) |
| 1033 | + |
| 1034 | +#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_TX_DMA_EN BIT(0) |
| 1035 | +#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_TX_BUSY_MASK BIT(1) |
| 1036 | +#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_RX_DMA_EN BIT(2) |
| 1037 | +#define MT_DBG_WFDMA1_PCIE1_GLO_CFG_RX_BUSY_MASK BIT(3) |
| 1038 | + |
| 1039 | +#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_EN_MASK BIT(2) |
| 1040 | +#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_EN_MASK BIT(0) |
| 1041 | +#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_BUSY_MASK BIT(3) |
| 1042 | +#define MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_BUSY_MASK BIT(1) |
| 1043 | + |
| 1044 | + |
| 1045 | +/* WF DMA TOP: band 0(0x820E7000),band 1(0x820F7000) */ |
| 1046 | +#define MT_DBG_WF_DMA_BASE(_band) ((_band) ? 0x820F7000 : 0x820E7000) |
| 1047 | +#define MT_DBG_WF_DMA(_band, ofs) (MT_WF_DMA_BASE(_band) + (ofs)) |
| 1048 | + |
| 1049 | +#define MT_DBG_DMA_DCR0(_band) MT_DBG_WF_DMA((_band), 0x000) |
| 1050 | +#define MT_DBG_DMA_DCR0_MAX_RX_LEN GENMASK(15, 3) |
| 1051 | +#define MT_DBG_DMA_DCR0_RXD_G5_EN BIT(23) |
| 1052 | + |
| 1053 | +#define MT_DBG_DMA_ICSC_FR0(_band) MT_DBG_WF_DMA((_band), __DBG_REG_OFFS(dev, DBG_DMA_ICSC_FR0)) |
| 1054 | +#define MT_DBG_DMA_ICSC_FR0_RXBF_EN BIT(25) |
| 1055 | +#define MT_DBG_DMA_ICSC_FR0_EN BIT(24) |
| 1056 | +#define MT_DBG_DMA_ICSC_FR0_TOUT_MASK GENMASK(23, 16) |
| 1057 | +#define MT_DBG_DMA_ICSC_FR0_PID_MASK GENMASK(9, 8) |
| 1058 | +#define MT_DBG_DMA_ICSC_FR0_QID_MASK GENMASK(6, 0) |
| 1059 | + |
| 1060 | +#define MT_DBG_DMA_ICSC_FR1(_band) MT_DBG_WF_DMA((_band), __DBG_REG_OFFS(dev, DBG_DMA_ICSC_FR1)) |
| 1061 | +#define MT_DBG_DMA_ICSC_FR1_AGG_SIZE_MASK GENMASK(26, 16) |
| 1062 | +#define MT_DBG_DMA_ICSC_FR1_MAX_FRAME_SIZE_MASK GENMASK(10, 0) |
| 1063 | + |
| 1064 | +/* TMAC: band 0(0x820e4000), band 1(0x820f4000) */ |
| 1065 | +#define MT_DBG_WF_TMAC_BASE(_band) ((_band) ? 0x820f4000 : 0x820e4000) |
| 1066 | +#define MT_DBG_WF_TMAC(_band, ofs) (MT_DBG_WF_TMAC_BASE(_band) + (ofs)) |
| 1067 | + |
| 1068 | +#define MT_DBG_TMAC_ICSCR0(_band) MT_DBG_WF_TMAC((_band), __DBG_REG_OFFS(dev, DBG_TMAC_ICSCR0)) |
| 1069 | +#define MT_DBG_TMAC_ICSCR0_ICSRPT_EN BIT(0) |
| 1070 | + |
| 1071 | +/* RMAC: band 0(0x820E5000), band 1(0x820f5000) */ |
| 1072 | +#define MT_DBG_WF_RMAC_BASE(_band) ((_band) ? 0x820f5000 : 0x820E5000) |
| 1073 | +#define MT_DBG_WF_RMAC(_band, ofs) (MT_DBG_WF_RMAC_BASE(_band) + (ofs)) |
| 1074 | + |
| 1075 | +#define MT_DBG_RMAC_RXICSRPT(_band) MT_DBG_WF_RMAC((_band), __DBG_REG_OFFS(dev, DBG_RMAC_RXICSRPT)) |
| 1076 | +#define MT_DBG_RMAC_RXICSRPT_ICSRPT_EN BIT(0) |
| 1077 | + |
| 1078 | +/* MIB: band 0(0x820ed000), band 1(0x820fd000) */ |
| 1079 | +#define MT_DBG_MIB_BASE(_band) ((_band) ? 0x820fd000 : 0x820ed000) |
| 1080 | +#define MT_DBG_MIB(_band, ofs) (MT_DBG_MIB_BASE(_band) + (ofs)) |
| 1081 | + |
| 1082 | + |
| 1083 | +#define MT_DBG_MIB_M0SCR0(_band) MT_DBG_MIB((_band), 0x00) |
| 1084 | +#define MT_DBG_MIB_M0PBSCR(_band) MT_DBG_MIB((_band), 0x04) |
| 1085 | + |
| 1086 | +#define MT_DBG_MIB_M0SDR0(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR0)) |
| 1087 | +#define MT_DBG_MIB_M0SDR3(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR3)) |
| 1088 | +#define MT_DBG_MIB_RX_FCS_ERROR_COUNT_MASK __DBG_MASK(dev, DBG_MIB_RX_FCS_ERROR_COUNT) |
| 1089 | +#define MT_DBG_MIB_M0SDR4(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR4)) |
| 1090 | +#define MT_DBG_MIB_M0SDR5(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR5)) |
| 1091 | +#define MT_DBG_MIB_M0SDR6(_band) MT_DBG_MIB((_band), 0x20) |
| 1092 | +#define MT_DBG_MIB_M0SDR7(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR7)) |
| 1093 | +#define MT_DBG_MIB_M0SDR8(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR8)) |
| 1094 | +#define MT_DBG_MIB_M0SDR9(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR9)) |
| 1095 | +#define MT_DBG_MIB_M0SDR10(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR10)) |
| 1096 | +#define MT_DBG_MIB_M0SDR10_RX_MDRDY_COUNT_MASK __DBG_MASK(dev, DBG_MIB_M0SDR10_RX_MDRDY_COUNT) |
| 1097 | +#define MT_DBG_MIB_M0SDR11(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR11)) |
| 1098 | + |
| 1099 | +#define MT_DBG_MIB_M0SDR12(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR12)) |
| 1100 | + |
| 1101 | +#define MT_DBG_MIB_M0SDR14(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR14)) |
| 1102 | +#define MT_DBG_MIB_M0SDR14_AMPDU_MASK __DBG_MASK(dev, DBG_MIB_M0SDR14_AMPDU) |
| 1103 | +#define MT_DBG_MIB_M0SDR15(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR15)) |
| 1104 | +#define MT_DBG_MIB_M0SDR15_AMPDU_ACKED_MASK __DBG_MASK(dev, DBG_MIB_M0SDR15_AMPDU_ACKED) |
| 1105 | +#define MT_DBG_MIB_M0SDR16(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR16)) |
| 1106 | +#define MT_DBG_MIB_M0SDR17(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR17)) |
| 1107 | +#define MT_DBG_MIB_M0SDR18(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR18)) |
| 1108 | +#define MT_DBG_MIB_M0SDR19(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR19)) |
| 1109 | +#define MT_DBG_MIB_M0SDR20(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR20)) |
| 1110 | +#define MT_DBG_MIB_M0SDR21(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR21)) |
| 1111 | +#define MT_DBG_MIB_M0SDR22(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR22)) |
| 1112 | +#define MT_DBG_MIB_M0SDR23(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0SDR23)) |
| 1113 | +#define MT_DBG_MIB_M0DR0(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR0)) |
| 1114 | +#define MT_DBG_MIB_M0DR1(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR1)) |
| 1115 | + |
| 1116 | +#define MT_DBG_MIB_MUBF(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_MUBF)) |
| 1117 | +#define MT_DBG_MIB_M0DR6(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR6)) |
| 1118 | +#define MT_DBG_MIB_M0DR7(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR7)) |
| 1119 | +#define MT_DBG_MIB_M0DR8(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR8)) |
| 1120 | +#define MT_DBG_MIB_M0DR9(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR9)) |
| 1121 | +#define MT_DBG_MIB_M0DR10(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR10)) |
| 1122 | +#define MT_DBG_MIB_M0DR11(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR11)) |
| 1123 | + #define MT_DBG_MIB_M0DR12(_band) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR12)) |
| 1124 | + |
| 1125 | +/* WTBLON TOP: 0x820D4000/pcie(0x34000) rbus(0x434000) */ |
| 1126 | +#define MT_DBG_WTBLON_TOP_BASE 0x820D4000 |
| 1127 | +#define MT_DBG_WTBLON_TOP(ofs) (MT_WTBLON_TOP_BASE + (ofs)) |
| 1128 | +#define MT_DBG_WTBLON_TOP_WDUCR MT_DBG_WTBLON_TOP(__DBG_REG_OFFS(dev, DBG_WTBLON_WDUCR)) |
| 1129 | +#define MT_DBG_WTBLON_TOP_WDUCR_GROUP GENMASK(2, 0) |
| 1130 | + |
| 1131 | +#define WF_WTBLON_TOP_B0BTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1000) // 5000 |
| 1132 | +#define WF_WTBLON_TOP_B0BTBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1010) // 5010 |
| 1133 | +#define WF_WTBLON_TOP_B0BRCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1020) // 5020 |
| 1134 | +#define WF_WTBLON_TOP_B0BRBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1030) // 5030 |
| 1135 | +#define WF_WTBLON_TOP_B0BTDCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1040) // 5040 |
| 1136 | +#define WF_WTBLON_TOP_B0BRDCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1050) // 5050 |
| 1137 | +#define WF_WTBLON_TOP_B0MBTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1100) // 5100 |
| 1138 | +#define WF_WTBLON_TOP_B0MBTBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1140) // 5140 |
| 1139 | +#define WF_WTBLON_TOP_B0MBRCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1180) // 5180 |
| 1140 | +#define WF_WTBLON_TOP_B0MBRBCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x11C0) // 51C0 |
| 1141 | + |
| 1142 | +#define WF_WTBLON_TOP_B1BTCRn_ADDR (MT_DBG_WTBLON_TOP_BASE + 0x1800) // 5800 |
| 1143 | + |
| 1144 | +/* WTBLON TOP: 0x820C4000/pcie(0xa8000) rbus(0x4a8000) */ |
| 1145 | +#define MT_DBG_UWTBL_TOP_BASE 0x820C4000 |
| 1146 | +#define MT_DBG_UWTBL_TOP(ofs) (MT_DBG_UWTBL_TOP_BASE + (ofs)) |
| 1147 | + |
developer | ec56711 | 2022-10-11 11:02:55 +0800 | [diff] [blame] | 1148 | +#define MT_DBG_UWTBL_TOP_WDUCR MT_DBG_UWTBL_TOP(__DBG_REG_OFFS(dev, DBG_UWTBL_WDUCR)) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1149 | + |
| 1150 | +#define MT_UWTBL_TOP_WDUCR_TARGET BIT(31) |
| 1151 | +#define MT_UWTBL_TOP_WDUCR_GROUP GENMASK(3, 0) |
| 1152 | + |
| 1153 | + |
| 1154 | +/* WTBL : 0x820D8000/pcie(0x38000) rbus(0x438000) */ |
| 1155 | +#define MT_DBG_WTBL_BASE 0x820D8000 |
| 1156 | + |
| 1157 | +/* PLE related CRs. */ |
| 1158 | +#define MT_DBG_PLE_BASE 0x820C0000 |
| 1159 | +#define MT_DBG_PLE(ofs) (MT_DBG_PLE_BASE + (ofs)) |
| 1160 | + |
| 1161 | +#define MT_DBG_PLE_DRR_TAB_CTRL MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_DRR_TABLE_CTRL)) |
| 1162 | +#define MT_DBG_PLE_DRR_TAB_RD_OFS __DBG_REG_OFFS(dev, DBG_PLE_DRR_TABLE_RDATA) |
| 1163 | + |
| 1164 | +#define MT_DBG_PLE_DRR_TABLE_RDATA0 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x0) |
| 1165 | +#define MT_DBG_PLE_DRR_TABLE_RDATA1 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x4) |
| 1166 | +#define MT_DBG_PLE_DRR_TABLE_RDATA2 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x8) |
| 1167 | +#define MT_DBG_PLE_DRR_TABLE_RDATA3 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0xc) |
| 1168 | +#define MT_DBG_PLE_DRR_TABLE_RDATA4 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x10) |
| 1169 | +#define MT_DBG_PLE_DRR_TABLE_RDATA5 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x14) |
| 1170 | +#define MT_DBG_PLE_DRR_TABLE_RDATA6 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS + 0x18) |
| 1171 | +#define MT_DBG_PLE_DRR_TABLE_RDATA7 MT_DBG_PLE(MT_DBG_PLE_DRR_TAB_RD_OFS+ 0x1c) |
| 1172 | + |
| 1173 | +#define MT_DBG_PLE_PBUF_CTRL_ADDR MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PBUF_CTRL)) |
| 1174 | +#define MT_DBG_PLE_QUEUE_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_QUEUE_EMPTY)) |
| 1175 | +#define MT_DBG_PLE_FREEPG_CNT MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_FREEPG_CNT)) |
| 1176 | +#define MT_DBG_PLE_FREEPG_HEAD_TAIL MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_FREEPG_HEAD_TAIL)) |
| 1177 | +#define MT_DBG_PLE_PG_HIF_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_HIF_GROUP)) |
| 1178 | +#define MT_DBG_PLE_HIF_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_HIF_PG_INFO)) |
| 1179 | +#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_HIF_TXCMD_GROUP)) |
| 1180 | +#define MT_DBG_PLE_HIF_TXCMD_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_HIF_TXCMD_PG_INFO)) |
| 1181 | +#define MT_DBG_PLE_PG_CPU_GROUP MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_PG_CPU_GROUP)) |
| 1182 | +#define MT_DBG_PLE_CPU_PG_INFO MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_CPU_PG_INFO)) |
| 1183 | +#define PLE_FL_QUE_CTRL_OFFSET __DBG_REG_OFFS(dev, DBG_PLE_FL_QUE_CTRL) |
| 1184 | +#define MT_DBG_PLE_FL_QUE_CTRL0 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x0) |
| 1185 | +#define MT_DBG_PLE_FL_QUE_CTRL1 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x4) |
| 1186 | +#define MT_DBG_PLE_FL_QUE_CTRL2 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0x8) |
| 1187 | +#define MT_DBG_PLE_FL_QUE_CTRL3 MT_DBG_PLE(PLE_FL_QUE_CTRL_OFFSET + 0xc) |
| 1188 | +#define MT_DBG_PLE_NATIVE_TXCMD_Q_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_NATIVE_TXCMD_Q_EMPTY)) |
| 1189 | +#define MT_DBG_PLE_TXCMD_Q_EMPTY MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_TXCMD_Q_EMPTY)) |
| 1190 | + |
| 1191 | +#define MT_DBG_PLE_PBUF_CTRL_PAGE_SIZE_MASK BIT(31) |
| 1192 | +#define MT_DBG_PLE_PBUF_CTRL_OFFSET_MASK GENMASK(25, 17) |
| 1193 | +#define MT_DBG_PLE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK GENMASK(11, 0) |
| 1194 | + |
| 1195 | +#define MT_DBG_PLE_FREEPG_CNT_FREEPG_CNT_MASK GENMASK(11, 0) |
| 1196 | +#define MT_DBG_PLE_FREEPG_CNT_FFA_CNT_MASK GENMASK(27, 16) |
| 1197 | +#define MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK GENMASK(27, 16) |
| 1198 | +#define MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK GENMASK(11, 0) |
| 1199 | +#define MT_DBG_PLE_PG_HIF_GROUP_HIF_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1200 | +#define MT_DBG_PLE_PG_HIF_GROUP_HIF_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1201 | + |
| 1202 | +#define MT_DBG_PLE_HIF_PG_INFO_HIF_SRC_CNT_MASK GENMASK(27, 16) |
| 1203 | +#define MT_DBG_PLE_HIF_PG_INFO_HIF_RSV_CNT_MASK GENMASK(11, 0) |
| 1204 | + |
| 1205 | +#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1206 | +#define MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1207 | + |
| 1208 | +#define MT_DBG_PLE_HIF_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK GENMASK(27, 16) |
| 1209 | +#define MT_DBG_PLE_HIF_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK GENMASK(11, 0) |
| 1210 | + |
| 1211 | +#define MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK GENMASK(27, 16) |
| 1212 | +#define MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK GENMASK(11, 0) |
| 1213 | + |
| 1214 | +#define MT_DBG_PLE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1215 | +#define MT_DBG_PLE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1216 | + |
| 1217 | +#define MT_DBG_PLE_CPU_PG_INFO_CPU_SRC_CNT_MASK GENMASK(27, 16) |
| 1218 | +#define MT_DBG_PLE_CPU_PG_INFO_CPU_RSV_CNT_MASK GENMASK(11, 0) |
| 1219 | + |
| 1220 | +#define MT_DBG_PLE_Q_EMPTY_ALL_AC_EMPTY_MASK BIT(24) |
| 1221 | +#define MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK BIT(31) |
| 1222 | +#define MT_DBG_PLE_FL_QUE_CTRL0_Q_BUF_QID_MASK GENMASK(30, 24) |
| 1223 | + |
| 1224 | +#define MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT 24 |
| 1225 | +#define MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT 10 |
| 1226 | + |
| 1227 | +#define MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK GENMASK(27, 16) |
| 1228 | +#define MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK GENMASK(11, 0) |
| 1229 | +#define MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK GENMASK(11, 0) |
| 1230 | + |
| 1231 | +#define MT_DBG_PLE_STATION_PAUSE(n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_STATION_PAUSE) + ((n) << 2)) |
| 1232 | +#define MT_DBG_PLE_DIS_STA_MAP(n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_DIS_STA_MAP) + ((n) << 2)) |
| 1233 | +#define MT_DBG_PLE_AC_QEMPTY(ac, n) MT_DBG_PLE(__DBG_REG_OFFS(dev, DBG_PLE_AC_QEMPTY) + \ |
| 1234 | + __DBG_REG_OFFS(dev, DBG_PLE_AC_OFFSET) * (ac) + ((n) << 2)) |
| 1235 | + |
| 1236 | +#define MT_DBG_PLE_AMSDU_PACK_MSDU_CNT(n) MT_DBG_PLE(0x10e0 + ((n) << 2)) |
| 1237 | + |
| 1238 | +/* pseinfo related CRs. */ |
| 1239 | +#define MT_DBG_PSE_BASE 0x820C8000 |
| 1240 | +#define MT_DBG_PSE(ofs) (MT_DBG_PSE_BASE + (ofs)) |
| 1241 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 1242 | +#define MT_DBG_PSE_PBUF_CTRL MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PBUF_CTRL)) |
| 1243 | +#define MT_DBG_PSE_QUEUE_EMPTY MT_DBG_PSE(0x0b0) |
| 1244 | +#define MT_DBG_PSE_FREEPG_CNT MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_FREEPG_CNT)) |
| 1245 | +#define MT_DBG_PSE_FREEPG_HEAD_TAIL MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_FREEPG_HEAD_TAIL)) |
| 1246 | +#define MT_DBG_PSE_PG_HIF0_GROUP MT_DBG_PSE(0x110) |
| 1247 | +#define MT_DBG_PSE_HIF0_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_HIF0_PG_INFO)) |
| 1248 | +#define MT_DBG_PSE_PG_HIF1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_HIF1_GROUP)) |
| 1249 | +#define MT_DBG_PSE_HIF1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_HIF1_PG_INFO)) |
| 1250 | +#define MT_DBG_PSE_PG_CPU_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_CPU_GROUP)) |
| 1251 | +#define MT_DBG_PSE_CPU_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_CPU_PG_INFO)) |
| 1252 | +#define MT_DBG_PSE_PG_LMAC0_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC0_GROUP)) |
| 1253 | +#define MT_DBG_PSE_LMAC0_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC0_PG_INFO)) |
| 1254 | +#define MT_DBG_PSE_PG_LMAC1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC1_GROUP)) |
| 1255 | +#define MT_DBG_PSE_LMAC1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC1_PG_INFO)) |
| 1256 | +#define MT_DBG_PSE_PG_LMAC2_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC2_GROUP)) |
| 1257 | +#define MT_DBG_PSE_LMAC2_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC2_PG_INFO)) |
| 1258 | +#define MT_DBG_PSE_PG_PLE_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_PLE_GROUP)) |
| 1259 | +#define MT_DBG_PSE_PLE_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PLE_PG_INFO)) |
| 1260 | +#define MT_DBG_PSE_PG_LMAC3_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_LMAC3_GROUP)) |
| 1261 | +#define MT_DBG_PSE_LMAC3_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_LMAC3_PG_INFO)) |
| 1262 | +#define MT_DBG_PSE_PG_MDP_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_MDP_GROUP)) |
| 1263 | +#define MT_DBG_PSE_MDP_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_MDP_PG_INFO)) |
| 1264 | +#define MT_DBG_PSE_PG_PLE1_GROUP MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PG_PLE1_GROUP)) |
| 1265 | +#define MT_DBG_PSE_PLE1_PG_INFO MT_DBG_PSE(__DBG_REG_OFFS(dev, DBG_PSE_PLE1_PG_INFO)) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1266 | + |
| 1267 | +#define MT_DBG_PSE_PBUF_CTRL_PAGE_SIZE_CFG_MASK BIT(31) |
| 1268 | +#define MT_DBG_PSE_PBUF_CTRL_PBUF_OFFSET_MASK GENMASK(25, 17) |
| 1269 | +#define MT_DBG_PSE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK GENMASK(11, 0) |
| 1270 | +#define MT_DBG_PSE_QUEUE_EMPTY_RLS_Q_EMTPY_MASK BIT(31) |
| 1271 | +#define MT_DBG_PSE_QUEUE_EMPTY_MDP_RXIOC_QUEUE_EMPTY_MASK BIT(23) |
| 1272 | +#define MT_DBG_PSE_QUEUE_EMPTY_MDP_TXIOC_QUEUE_EMPTY_MASK BIT(22) |
| 1273 | +#define MT_DBG_PSE_QUEUE_EMPTY_SFD_PARK_QUEUE_EMPTY_MASK BIT(21) |
| 1274 | +#define MT_DBG_PSE_QUEUE_EMPTY_SEC_RX_QUEUE_EMPTY_SHFT BIT(20) |
| 1275 | +#define MT_DBG_PSE_QUEUE_EMPTY_SEC_TX_QUEUE_EMPTY_MASK BIT(19) |
| 1276 | +#define MT_DBG_PSE_QUEUE_EMPTY_MDP_RX_QUEUE_EMPTY_MASK BIT(18) |
| 1277 | +#define MT_DBG_PSE_QUEUE_EMPTY_MDP_TX_QUEUE_EMPTY_MASK BIT(17) |
| 1278 | +#define MT_DBG_PSE_QUEUE_EMPTY_LMAC_TX_QUEUE_EMPTY_MASK BIT(16) |
| 1279 | +#define MT_DBG_PSE_QUEUE_EMPTY_HIF_5_EMPTY_MASK BIT(13) |
| 1280 | +#define MT_DBG_PSE_QUEUE_EMPTY_HIF_4_EMPTY_MASK BIT(12) |
| 1281 | +#define MT_DBG_PSE_QUEUE_EMPTY_HIF_3_EMPTY_MASK BIT(11) |
| 1282 | +#define MT_DBG_PSE_QUEUE_EMPTY_HIF_2_EMPTY_MASK BIT(10) |
| 1283 | +#define MT_DBG_PSE_QUEUE_EMPTY_HIF_1_EMPTY_MASK BIT(9) |
| 1284 | +#define MT_DBG_PSE_QUEUE_EMPTY_HIF_0_EMPTY_MASK BIT(8) |
| 1285 | +#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q3_EMPTY_MASK BIT(3) |
| 1286 | +#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q2_EMPTY_MASK BIT(2) |
| 1287 | +#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q1_EMPTY_MASK BIT(1) |
| 1288 | +#define MT_DBG_PSE_QUEUE_EMPTY_CPU_Q0_EMPTY_MASK BIT(0) |
| 1289 | +#define MT_DBG_PSE_FREEPG_CNT_FFA_CNT_MASK GENMASK(27, 16) |
| 1290 | +#define MT_DBG_PSE_FREEPG_CNT_FREEPG_CNT_MASK GENMASK(11, 0) |
| 1291 | +#define MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK GENMASK(27, 16) |
| 1292 | +#define MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK GENMASK(11, 0) |
| 1293 | +#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1294 | +#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1295 | +#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1296 | +#define MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1297 | +#define MT_DBG_PSE_HIF0_PG_INFO_HIF0_SRC_CNT_MASK GENMASK(27, 16) |
| 1298 | +#define MT_DBG_PSE_HIF0_PG_INFO_HIF0_RSV_CNT_MASK GENMASK(11, 0) |
| 1299 | +#define MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1300 | +#define MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1301 | +#define MT_DBG_PSE_HIF1_PG_INFO_HIF1_SRC_CNT_MASK GENMASK(27, 16) |
| 1302 | +#define MT_DBG_PSE_HIF1_PG_INFO_HIF1_RSV_CNT_MASK GENMASK(11, 0) |
| 1303 | +#define MT_DBG_PSE_CPU_PG_INFO_CPU_SRC_CNT_MASK GENMASK(27, 16) |
| 1304 | +#define MT_DBG_PSE_CPU_PG_INFO_CPU_RSV_CNT_MASK GENMASK(11, 0) |
| 1305 | +#define MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1306 | +#define MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1307 | +#define MT_DBG_PSE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1308 | +#define MT_DBG_PSE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1309 | +#define MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK GENMASK(27, 16) |
| 1310 | +#define MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK GENMASK(11, 0) |
| 1311 | +#define MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1312 | +#define MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1313 | +#define MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_SRC_CNT_MASK GENMASK(27, 16) |
| 1314 | +#define MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_RSV_CNT_MASK GENMASK(11, 0) |
| 1315 | +#define MT_DBG_PSE_PG_LMAC1_GROUP_LMAC1_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1316 | +#define MT_DBG_TOP_PG_LMAC1_GROUP_LMAC1_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1317 | +#define MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_SRC_CNT_MASK GENMASK(27, 16) |
| 1318 | +#define MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_RSV_CNT_MASK GENMASK(11, 0) |
| 1319 | +#define MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1320 | +#define MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1321 | +#define MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_SRC_CNT_MASK GENMASK(27, 16) |
| 1322 | +#define MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_RSV_CNT_MASK GENMASK(11, 0) |
| 1323 | +#define MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1324 | +#define MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1325 | +#define MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_SRC_CNT_MASK GENMASK(27, 16) |
| 1326 | +#define MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_RSV_CNT_MASK GENMASK(11, 0) |
| 1327 | +#define MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1328 | +#define MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1329 | +#define MT_DBG_PSE_PG_MDP_GROUP_MDP_MAX_QUOTA_MASK GENMASK(27, 16) |
| 1330 | +#define MT_DBG_PSE_PG_MDP_GROUP_MDP_MIN_QUOTA_MASK GENMASK(11, 0) |
| 1331 | +#define MT_DBG_PSE_MDP_PG_INFO_MDP_SRC_CNT_MASK GENMASK(27, 16) |
| 1332 | +#define MT_DBG_PSE_MDP_PG_INFO_MDP_RSV_CNT_MASK GENMASK(11, 0) |
| 1333 | + |
| 1334 | +#define MT_DBG_PSE_FL_QUE_CTRL_0_ADDR MT_DBG_PLE(0x1b0) |
| 1335 | +#define MT_DBG_PSE_FL_QUE_CTRL_0_EXECUTE_MASK BIT(31) |
| 1336 | +#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_QID_SHFT 24 |
| 1337 | +#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_PID_SHFT 10 |
| 1338 | +#define MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_WLANID_MASK GENMASK(9, 0) |
| 1339 | + |
| 1340 | +#define MT_DBG_PSE_FL_QUE_CTRL_2_ADDR MT_DBG_PLE(0x1b8) |
| 1341 | +#define MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_TAIL_FID_MASK GENMASK(27, 16) |
| 1342 | +#define MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_HEAD_FID_MASK GENMASK(11, 0) |
| 1343 | + |
| 1344 | +#define MT_DBG_PSE_FL_QUE_CTRL_3_ADDR MT_DBG_PLE(0x1bc) |
| 1345 | +#define MT_DBG_PSE_FL_QUE_CTRL_3_QUEUE_PKT_NUM_MASK GENMASK(11, 0) |
| 1346 | + |
| 1347 | + |
| 1348 | +/* AGG */ |
| 1349 | +#define MT_DBG_AGG_BASE(_band) ((_band) ? 0x820f2000 : 0x820e2000) |
| 1350 | +#define MT_DBG_AGG(_band, ofs) (MT_DBG_AGG_BASE(_band) + (ofs)) |
| 1351 | + |
| 1352 | +#define MT_DBG_AGG_AALCR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR0)) |
| 1353 | +#define MT_DBG_AGG_AALCR1(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR1)) |
| 1354 | +#define MT_DBG_AGG_AALCR2(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR2)) |
| 1355 | +#define MT_DBG_AGG_AALCR3(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR3)) |
| 1356 | +#define MT_DBG_AGG_AALCR4(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AALCR4)) |
| 1357 | +#define MT_DBG_AGG_B0BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B0BRR0)) |
| 1358 | +#define MT_DBG_AGG_B1BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B1BRR0)) |
| 1359 | +#define MT_DBG_AGG_B2BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B2BRR0)) |
| 1360 | +#define MT_DBG_AGG_B3BRR0(_band) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_B3BRR0)) |
| 1361 | +#define MT_DBG_AGG_AWSCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_AWSCR0) + ((n) << 2)) |
| 1362 | +#define MT_DBG_AGG_PCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_PCR0) + ((n) << 2)) |
| 1363 | +#define MT_DBG_AGG_TTCR(_band, n) MT_DBG_AGG((_band), __DBG_REG_OFFS(dev, DBG_AGG_TTCR0) + ((n) << 2)) |
| 1364 | +#define MT_DBG_MIB_M0ARNG(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0ARNG0) + ((n) << 2)) |
| 1365 | +#define MT_DBG_MIB_M0DR2(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR2) + ((n) << 2)) |
| 1366 | +#define MT_DBG_MIB_M0DR13(_band, n) MT_DBG_MIB((_band), __DBG_REG_OFFS(dev, DBG_MIB_M0DR13) + ((n) << 2)) |
| 1367 | + |
| 1368 | +#define MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK GENMASK(31, 24) |
| 1369 | +#define MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK GENMASK(23, 16) |
| 1370 | +#define MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK GENMASK(15, 8) |
| 1371 | +#define MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK GENMASK(7, 0) |
| 1372 | +#define MT_DBG_AGG_AALCR4_ALTX0_AGG_LIMIT_MASK GENMASK(7, 0) |
| 1373 | + |
| 1374 | +#define MT_DBG_AGG_AWSCR0_WINSIZE3_MASK GENMASK(31, 24) |
| 1375 | +#define MT_DBG_AGG_AWSCR0_WINSIZE2_MASK GENMASK(23, 16) |
| 1376 | +#define MT_DBG_AGG_AWSCR0_WINSIZE1_MASK GENMASK(15, 8) |
| 1377 | +#define MT_DBG_AGG_AWSCR0_WINSIZE0_MASK GENMASK(7, 0) |
| 1378 | + |
| 1379 | +#define MT_DBG_AGG_AWSCR1_WINSIZE7_MASK GENMASK(31, 24) |
| 1380 | +#define MT_DBG_AGG_AWSCR1_WINSIZE6_MASK GENMASK(23, 16) |
| 1381 | +#define MT_DBG_AGG_AWSCR1_WINSIZE5_MASK GENMASK(15, 8) |
| 1382 | +#define MT_DBG_AGG_AWSCR1_WINSIZE4_MASK GENMASK(7, 0) |
| 1383 | + |
| 1384 | +#define MT_DBG_AGG_AWSCR2_WINSIZEB_MASK GENMASK(31, 24) |
| 1385 | +#define MT_DBG_AGG_AWSCR2_WINSIZEA_MASK GENMASK(23, 16) |
| 1386 | +#define MT_DBG_AGG_AWSCR2_WINSIZE9_MASK GENMASK(15, 8) |
| 1387 | +#define MT_DBG_AGG_AWSCR2_WINSIZE8_MASK GENMASK(7, 0) |
| 1388 | + |
| 1389 | +#define MT_DBG_AGG_AWSCR3_WINSIZEE_MASK GENMASK(23, 16) |
| 1390 | +#define MT_DBG_AGG_AWSCR3_WINSIZED_MASK GENMASK(15, 8) |
| 1391 | +#define MT_DBG_AGG_AWSCR3_WINSIZEC_MASK GENMASK(7, 0) |
| 1392 | + |
| 1393 | +#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL3_MASK GENMASK(31, 24) |
| 1394 | +#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL2_MASK GENMASK(23, 16) |
| 1395 | +#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL1_MASK GENMASK(15, 8) |
| 1396 | +#define MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL0_MASK GENMASK(7, 0) |
| 1397 | + |
| 1398 | +#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL7_MASK GENMASK(31, 24) |
| 1399 | +#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL6_MASK GENMASK(23, 16) |
| 1400 | +#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL5_MASK GENMASK(15, 8) |
| 1401 | +#define MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL4_MASK GENMASK(7, 0) |
| 1402 | + |
| 1403 | +#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL11_MASK GENMASK(31, 24) |
| 1404 | +#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL10_MASK GENMASK(23, 16) |
| 1405 | +#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL9_MASK GENMASK(15, 8) |
| 1406 | +#define MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL8_MASK GENMASK(7, 0) |
| 1407 | + |
| 1408 | +#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL14_MASK GENMASK(23, 16) |
| 1409 | +#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL13_MASK GENMASK(15, 8) |
| 1410 | +#define MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL12_MASK GENMASK(7, 0) |
| 1411 | + |
| 1412 | +#define MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK GENMASK(31, 16) |
| 1413 | +#define MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK GENMASK(15, 0) |
| 1414 | +#define MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK GENMASK(31, 16) |
| 1415 | +#define MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK GENMASK(15, 0) |
| 1416 | +#define MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK GENMASK(31, 16) |
| 1417 | +#define MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK GENMASK(15, 0) |
| 1418 | +#define MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK GENMASK(31, 16) |
| 1419 | +#define MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK GENMASK(15, 0) |
| 1420 | +#define MT_DBG_MIB_M0DR13_TRX_AGG_RANGE9_CNT_MASK GENMASK(31, 16) |
| 1421 | +#define MT_DBG_MIB_M0DR13_TRX_AGG_RANGE8_CNT_MASK GENMASK(15, 0) |
| 1422 | +#define MT_DBG_MIB_M0DR14_TRX_AGG_RANGE11_CNT_MASK GENMASK(31, 16) |
| 1423 | +#define MT_DBG_MIB_M0DR14_TRX_AGG_RANGE10_CNT_MASK GENMASK(15, 0) |
| 1424 | +#define MT_DBG_MIB_M0DR15_TRX_AGG_RANGE13_CNT_MASK GENMASK(31, 16) |
| 1425 | +#define MT_DBG_MIB_M0DR15_TRX_AGG_RANGE12_CNT_MASK GENMASK(15, 0) |
| 1426 | +#define MT_DBG_MIB_M0DR16_TRX_AGG_RANGE15_CNT_MASK GENMASK(31, 16) |
| 1427 | +#define MT_DBG_MIB_M0DR16_TRX_AGG_RANGE14_CNT_MASK GENMASK(15, 0) |
| 1428 | + |
| 1429 | +/* mt7915 host DMA*/ |
| 1430 | +#define MT_DBG_INT_DMA1_R0_DONE BIT(0) |
| 1431 | +#define MT_DBG_INT_DMA1_R1_DONE BIT(1) |
| 1432 | +#define MT_DBG_INT_DMA1_R2_DONE BIT(2) |
| 1433 | + |
| 1434 | +#define MT_DBG_INT_DMA1_T16_DONE BIT(26) |
| 1435 | +#define MT_DBG_INT_DMA1_T17_DONE BIT(27) |
| 1436 | +#define MT_DBG_INT_DMA1_T18_DONE BIT(30) |
| 1437 | +#define MT_DBG_INT_DMA1_T19_DONE BIT(31) |
| 1438 | +#define MT_DBG_INT_DMA1_T20_DONE BIT(15) |
| 1439 | + |
| 1440 | +#define MT_DBG_EXT_WRAP_INT_DMA0_R0_DONE BIT(16) |
| 1441 | +#define MT_DBG_EXT_WRAP_INT_DMA0_R1_DONE BIT(17) |
| 1442 | + |
| 1443 | +/* mt7986 host DMA */ |
| 1444 | +#define MT_DBG_INT_DMA0_R0_DONE BIT(0) |
| 1445 | +#define MT_DBG_INT_DMA0_R1_DONE BIT(1) |
| 1446 | +#define MT_DBG_INT_DMA0_R2_DONE BIT(2) |
| 1447 | +#define MT_DBG_INT_DMA0_R3_DONE BIT(3) |
| 1448 | +#define MT_DBG_INT_DMA0_R4_DONE BIT(22) |
| 1449 | +#define MT_DBG_INT_DMA0_R5_DONE BIT(23) |
| 1450 | + |
| 1451 | +#define MT_DBG_INT_DMA0_T16_DONE BIT(26) |
| 1452 | +#define MT_DBG_INT_DMA0_T17_DONE BIT(27) |
| 1453 | +#define MT_DBG_INT_DMA0_T18_DONE BIT(30) |
| 1454 | +#define MT_DBG_INT_DMA0_T19_DONE BIT(31) |
| 1455 | +#define MT_DBG_INT_DMA0_T20_DONE BIT(25) |
| 1456 | + |
| 1457 | +/* MCU DMA */ |
| 1458 | +#define WF_WFDMA_MCU_DMA0_BASE 0x54000000 |
| 1459 | +#define WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x200) // 0200 |
| 1460 | +#define WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0X204) // 0204 |
| 1461 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x208) // 0208 |
| 1462 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3] |
| 1463 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3 |
| 1464 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2] |
| 1465 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2 |
| 1466 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1] |
| 1467 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1 |
| 1468 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0] |
| 1469 | +#define WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0 |
| 1470 | + |
| 1471 | +#define WF_WFDMA_MCU_DMA1_BASE 0x55000000 |
| 1472 | +#define WF_WFDMA_MCU_DMA1_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x200) // 0200 |
| 1473 | +#define WF_WFDMA_MCU_DMA1_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0X204) // 0204 |
| 1474 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x208) // 0208 |
| 1475 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3] |
| 1476 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3 |
| 1477 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2] |
| 1478 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2 |
| 1479 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1] |
| 1480 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1 |
| 1481 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0] |
| 1482 | +#define WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0 |
| 1483 | +#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x300) // 0300 |
| 1484 | +#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x310) // 0310 |
| 1485 | +#define WF_WFDMA_MCU_DMA1_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x320) // 0320 |
| 1486 | +#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x500) // 0500 |
| 1487 | +#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x510) // 0510 |
| 1488 | +#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x520) // 0520 |
| 1489 | +#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x530) // 0530 |
| 1490 | +#define WF_WFDMA_MCU_DMA1_WPDMA_RX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_BASE + 0x540) // 0540 |
| 1491 | + |
| 1492 | +#define WF_WFDMA_MCU_DMA1_PCIE1_BASE 0x59000000 |
| 1493 | +#define WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_STA_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x200) // 0200 |
| 1494 | +#define WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_ENA_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0X204) // 0204 |
| 1495 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x208) // 0208 |
| 1496 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3] |
| 1497 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3 |
| 1498 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2] |
| 1499 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2 |
| 1500 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1] |
| 1501 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1 |
| 1502 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0] |
| 1503 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0 |
| 1504 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x320) // 0320 |
| 1505 | +#define WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA1_PCIE1_BASE + 0x530) // 0530 |
| 1506 | + |
| 1507 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x300) // 0300 |
| 1508 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x310) // 0310 |
| 1509 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x320) // 0320 |
| 1510 | +/* mt7986 add */ |
| 1511 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x330) // 0330 |
| 1512 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x340) // 0340 |
| 1513 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING5_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x350) // 0350 |
| 1514 | +#define WF_WFDMA_MCU_DMA0_WPDMA_TX_RING6_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x360) // 0360 |
| 1515 | + |
| 1516 | + |
| 1517 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x500) // 0500 |
| 1518 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x510) // 0510 |
| 1519 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x520) // 0520 |
| 1520 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x530) // 0530 |
| 1521 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x540) // 0540 |
| 1522 | + |
| 1523 | +/* mt7986 add */ |
| 1524 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING5_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x550) // 0550 |
| 1525 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING6_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x560) // 0560 |
| 1526 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING7_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x570) // 0570 |
| 1527 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING8_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x580) // 0580 |
| 1528 | +#define WF_WFDMA_MCU_DMA0_WPDMA_RX_RING9_CTRL0_ADDR (WF_WFDMA_MCU_DMA0_BASE + 0x590) // 0590 |
| 1529 | + |
| 1530 | +/* MEM DMA */ |
| 1531 | +#define WF_WFDMA_MEM_DMA_BASE 0x58000000 |
| 1532 | +#define WF_WFDMA_MEM_DMA_HOST_INT_STA_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x200) // 0200 |
| 1533 | +#define WF_WFDMA_MEM_DMA_HOST_INT_ENA_ADDR (WF_WFDMA_MEM_DMA_BASE + 0X204) // 0204 |
| 1534 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x208) // 0208 |
| 1535 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK 0x00000008 // RX_DMA_BUSY[3] |
| 1536 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT 3 |
| 1537 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_MASK 0x00000004 // RX_DMA_EN[2] |
| 1538 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_SHFT 2 |
| 1539 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK 0x00000002 // TX_DMA_BUSY[1] |
| 1540 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT 1 |
| 1541 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_MASK 0x00000001 // TX_DMA_EN[0] |
| 1542 | +#define WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_SHFT 0 |
| 1543 | +#define WF_WFDMA_MEM_DMA_WPDMA_TX_RING0_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x300) // 0300 |
| 1544 | +#define WF_WFDMA_MEM_DMA_WPDMA_TX_RING1_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x310) // 0310 |
| 1545 | +#define WF_WFDMA_MEM_DMA_WPDMA_RX_RING0_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x500) // 0500 |
| 1546 | +#define WF_WFDMA_MEM_DMA_WPDMA_RX_RING1_CTRL0_ADDR (WF_WFDMA_MEM_DMA_BASE + 0x510) // 0510 |
| 1547 | + |
| 1548 | +enum resource_attr { |
| 1549 | + HIF_TX_DATA, |
| 1550 | + HIF_TX_CMD, |
| 1551 | + HIF_TX_CMD_WM, /* direct path to WMCPU, only exist for WFDMA arch with 2 CPU */ |
| 1552 | + HIF_TX_FWDL, |
| 1553 | + HIF_RX_DATA, |
| 1554 | + HIF_RX_EVENT, |
| 1555 | + RING_ATTR_NUM |
| 1556 | +}; |
| 1557 | + |
| 1558 | +struct hif_pci_tx_ring_desc { |
| 1559 | + u32 hw_int_mask; |
| 1560 | + u16 ring_size; |
| 1561 | + enum resource_attr ring_attr; |
| 1562 | + u8 band_idx; |
| 1563 | + char *const ring_info; |
| 1564 | +}; |
| 1565 | + |
| 1566 | +struct hif_pci_rx_ring_desc { |
| 1567 | + u32 hw_desc_base; |
| 1568 | + u32 hw_int_mask; |
| 1569 | + u16 ring_size; |
| 1570 | + enum resource_attr ring_attr; |
| 1571 | + u16 max_rx_process_cnt; |
| 1572 | + u16 max_sw_read_idx_inc; |
| 1573 | + char *const ring_info; |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 1574 | + bool flags; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1575 | +}; |
| 1576 | + |
| 1577 | +const struct hif_pci_tx_ring_desc mt7915_tx_ring_layout[] = { |
| 1578 | + { |
| 1579 | + .hw_int_mask = MT_DBG_INT_DMA1_T16_DONE, |
| 1580 | + .ring_size = 128, |
| 1581 | + .ring_attr = HIF_TX_FWDL, |
| 1582 | + .ring_info = "FWDL" |
| 1583 | + }, |
| 1584 | + { |
| 1585 | + .hw_int_mask = MT_DBG_INT_DMA1_T17_DONE, |
| 1586 | + .ring_size = 256, |
| 1587 | + .ring_attr = HIF_TX_CMD_WM, |
| 1588 | + .ring_info = "cmd to WM" |
| 1589 | + }, |
| 1590 | + { |
| 1591 | + .hw_int_mask = MT_DBG_INT_DMA1_T18_DONE, |
| 1592 | + .ring_size = 2048, |
| 1593 | + .ring_attr = HIF_TX_DATA, |
| 1594 | + .ring_info = "band0 TXD" |
| 1595 | + }, |
| 1596 | + { |
| 1597 | + .hw_int_mask = MT_DBG_INT_DMA1_T19_DONE, |
| 1598 | + .ring_size = 2048, |
| 1599 | + .ring_attr = HIF_TX_DATA, |
| 1600 | + .ring_info = "band1 TXD" |
| 1601 | + }, |
| 1602 | + { |
| 1603 | + .hw_int_mask = MT_DBG_INT_DMA1_T20_DONE, |
| 1604 | + .ring_size = 256, |
| 1605 | + .ring_attr = HIF_TX_CMD, |
| 1606 | + .ring_info = "cmd to WA" |
| 1607 | + } |
| 1608 | +}; |
| 1609 | + |
| 1610 | +const struct hif_pci_rx_ring_desc mt7915_rx_ring_layout[] = { |
| 1611 | + { |
| 1612 | + .hw_int_mask = MT_DBG_EXT_WRAP_INT_DMA0_R0_DONE, |
| 1613 | + .ring_size = 1536, |
| 1614 | + .ring_attr = HIF_RX_DATA, |
| 1615 | + .ring_info = "band0 RX data" |
| 1616 | + }, |
| 1617 | + { |
| 1618 | + .hw_int_mask = MT_DBG_EXT_WRAP_INT_DMA0_R1_DONE, |
| 1619 | + .ring_size = 1536, |
| 1620 | + .ring_attr = HIF_RX_DATA, |
| 1621 | + .ring_info = "band1 RX data" |
| 1622 | + }, |
| 1623 | + { |
| 1624 | + .hw_int_mask = MT_DBG_INT_DMA1_R0_DONE, |
| 1625 | + .ring_size = 512, |
| 1626 | + .ring_attr = HIF_RX_EVENT, |
| 1627 | + .ring_info = "event from WM" |
| 1628 | + }, |
| 1629 | + { |
| 1630 | + .hw_int_mask = MT_DBG_INT_DMA1_R1_DONE, |
| 1631 | + .ring_size = 1024, |
| 1632 | + .ring_attr = HIF_RX_EVENT, |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 1633 | + .ring_info = "event from WA band0", |
| 1634 | + .flags = true |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1635 | + }, |
| 1636 | + { |
| 1637 | + .hw_int_mask = MT_DBG_INT_DMA1_R2_DONE, |
| 1638 | + .ring_size = 512, |
| 1639 | + .ring_attr = HIF_RX_EVENT, |
| 1640 | + .ring_info = "event from WA band1" |
| 1641 | + } |
| 1642 | +}; |
| 1643 | + |
| 1644 | +const struct hif_pci_tx_ring_desc mt7986_tx_ring_layout[] = { |
| 1645 | + { |
| 1646 | + .hw_int_mask = MT_DBG_INT_DMA0_T16_DONE, |
| 1647 | + .ring_size = 128, |
| 1648 | + .ring_attr = HIF_TX_FWDL, |
| 1649 | + .ring_info = "FWDL" |
| 1650 | + }, |
| 1651 | + { |
| 1652 | + .hw_int_mask = MT_DBG_INT_DMA0_T17_DONE, |
| 1653 | + .ring_size = 256, |
| 1654 | + .ring_attr = HIF_TX_CMD_WM, |
| 1655 | + .ring_info = "cmd to WM" |
| 1656 | + }, |
| 1657 | + { |
| 1658 | + .hw_int_mask = MT_DBG_INT_DMA0_T18_DONE, |
| 1659 | + .ring_size = 2048, |
| 1660 | + .ring_attr = HIF_TX_DATA, |
| 1661 | + .ring_info = "band0 TXD" |
| 1662 | + }, |
| 1663 | + { |
| 1664 | + .hw_int_mask = MT_DBG_INT_DMA0_T19_DONE, |
| 1665 | + .ring_size = 2048, |
| 1666 | + .ring_attr = HIF_TX_DATA, |
| 1667 | + .ring_info = "band1 TXD" |
| 1668 | + }, |
| 1669 | + { |
| 1670 | + .hw_int_mask = MT_DBG_INT_DMA0_T20_DONE, |
| 1671 | + .ring_size = 256, |
| 1672 | + .ring_attr = HIF_TX_CMD, |
| 1673 | + .ring_info = "cmd to WA" |
| 1674 | + } |
| 1675 | +}; |
| 1676 | + |
| 1677 | +const struct hif_pci_rx_ring_desc mt7986_rx_ring_layout[] = { |
| 1678 | + { |
| 1679 | + .hw_int_mask = MT_DBG_INT_DMA0_R4_DONE, |
| 1680 | + .ring_size = 1536, |
| 1681 | + .ring_attr = HIF_RX_DATA, |
| 1682 | + .ring_info = "band0 RX data" |
| 1683 | + }, |
| 1684 | + { |
| 1685 | + .hw_int_mask = MT_DBG_INT_DMA0_R5_DONE, |
| 1686 | + .ring_size = 1536, |
| 1687 | + .ring_attr = HIF_RX_DATA, |
| 1688 | + .ring_info = "band1 RX data" |
| 1689 | + }, |
| 1690 | + { |
| 1691 | + .hw_int_mask = MT_DBG_INT_DMA0_R0_DONE, |
| 1692 | + .ring_size = 512, |
| 1693 | + .ring_attr = HIF_RX_EVENT, |
| 1694 | + .ring_info = "event from WM" |
| 1695 | + }, |
| 1696 | + { |
| 1697 | + .hw_int_mask = MT_DBG_INT_DMA0_R1_DONE, |
| 1698 | + .ring_size = 512, |
| 1699 | + .ring_attr = HIF_RX_EVENT, |
| 1700 | + .ring_info = "event from WA" |
| 1701 | + }, |
| 1702 | + { |
| 1703 | + .hw_int_mask = MT_DBG_INT_DMA0_R2_DONE, |
| 1704 | + .ring_size = 1024, |
| 1705 | + .ring_attr = HIF_RX_EVENT, |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 1706 | + .ring_info = "STS WA band0", |
| 1707 | + .flags = true |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1708 | + }, |
| 1709 | + { |
| 1710 | + .hw_int_mask = MT_DBG_INT_DMA0_R3_DONE, |
| 1711 | + .ring_size = 512, |
| 1712 | + .ring_attr = HIF_RX_EVENT, |
| 1713 | + .ring_info = "STS WA band1" |
| 1714 | + }, |
| 1715 | +}; |
| 1716 | + |
| 1717 | +/* mibinfo related CRs. */ |
| 1718 | +#define BN0_WF_MIB_TOP_BASE 0x820ed000 |
| 1719 | +#define BN1_WF_MIB_TOP_BASE 0x820fd000 |
| 1720 | + |
| 1721 | +#define BN0_WF_MIB_TOP_BTOCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x400) // D400 |
| 1722 | +#define BN0_WF_MIB_TOP_BTBCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x428) // D428 |
| 1723 | +#define BN0_WF_MIB_TOP_BTDCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x4F0) // D4F0 |
| 1724 | + |
| 1725 | +#define BN0_WF_MIB_TOP_BSDR0_ADDR (BN0_WF_MIB_TOP_BASE + 0x688) // D688 |
| 1726 | +#define BN0_WF_MIB_TOP_BSDR1_ADDR (BN0_WF_MIB_TOP_BASE + 0x690) // D690 |
| 1727 | + |
| 1728 | +#define BN0_WF_MIB_TOP_BSDR2_ADDR (BN0_WF_MIB_TOP_BASE + 0x518) // D518 |
| 1729 | +#define BN0_WF_MIB_TOP_BSDR3_ADDR (BN0_WF_MIB_TOP_BASE + 0x520) // D520 |
| 1730 | +#define BN0_WF_MIB_TOP_BSDR4_ADDR (BN0_WF_MIB_TOP_BASE + 0x528) // D528 |
| 1731 | +#define BN0_WF_MIB_TOP_BSDR5_ADDR (BN0_WF_MIB_TOP_BASE + 0x530) // D530 |
| 1732 | +#define BN0_WF_MIB_TOP_BSDR6_ADDR (BN0_WF_MIB_TOP_BASE + 0x538) // D538 |
| 1733 | + |
| 1734 | +#define BN0_WF_MIB_TOP_BROCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x5B8) // D5B8 |
| 1735 | +#define BN0_WF_MIB_TOP_BRBCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x5E0) // D5E0 |
| 1736 | +#define BN0_WF_MIB_TOP_BRDCR_ADDR (BN0_WF_MIB_TOP_BASE + 0x630) // D630 |
| 1737 | + |
| 1738 | +#define BN0_WF_MIB_TOP_M0SDR0_BEACONTXCOUNT_MASK 0x0000FFFF // BEACONTXCOUNT[15..0] |
| 1739 | + |
| 1740 | +#define BN0_WF_MIB_TOP_M0SDR4_RX_FIFO_FULL_COUNT_MASK 0x0000FFFF // RX_FIFO_FULL_COUNT[15..0] |
| 1741 | + |
| 1742 | +#define BN0_WF_MIB_TOP_M0SDR5_RX_MPDU_COUNT_MASK 0xFFFFFFFF // RX_MPDU_COUNT[31..0] |
| 1743 | + |
| 1744 | +#define BN0_WF_MIB_TOP_M0SDR6_CHANNEL_IDLE_COUNT_MASK 0x0000FFFF // CHANNEL_IDLE_COUNT[15..0] |
| 1745 | + |
| 1746 | +#define BN1_WF_MIB_TOP_BTOCR_ADDR (BN1_WF_MIB_TOP_BASE + 0x400) // D400 |
| 1747 | + |
| 1748 | +#define BN0_WF_MIB_TOP_M0SDR7_VEC_MISS_COUNT_MASK 0x0000FFFF // VEC_MISS_COUNT[15..0] |
| 1749 | +#define BN0_WF_MIB_TOP_M0SDR8_DELIMITER_FAIL_COUNT_MASK 0x0000FFFF // DELIMITER_FAIL_COUNT[15..0] |
| 1750 | +#define BN0_WF_MIB_TOP_M0SDR9_CCA_NAV_TX_TIME_MASK 0x00FFFFFF // CCA_NAV_TX_TIME[23..0] |
| 1751 | + |
| 1752 | +#define BN0_WF_MIB_TOP_M0SDR11_RX_LEN_MISMATCH_MASK 0x0000FFFF // RX_LEN_MISMATCH[15..0] |
| 1753 | + |
| 1754 | +#define BN0_WF_MIB_TOP_M0SDR16_P_CCA_TIME_MASK 0x00FFFFFF // P_CCA_TIME[23..0] |
| 1755 | +#define BN0_WF_MIB_TOP_M0SDR17_S_CCA_TIME_MASK 0x00FFFFFF // S_CCA_TIME[23..0] |
| 1756 | +#define BN0_WF_MIB_TOP_M0SDR18_P_ED_TIME_MASK 0x00FFFFFF // P_ED_TIME[23..0] |
| 1757 | +#define BN0_WF_MIB_TOP_M0SDR19_CCK_MDRDY_TIME_MASK 0x00FFFFFF // CCK_MDRDY_TIME[23..0] |
| 1758 | +#define BN0_WF_MIB_TOP_M0SDR20_OFDM_LG_MIXED_VHT_MDRDY_TIME_MASK 0x00FFFFFF // OFDM_LG_MIXED_VHT_MDRDY_TIME[23..0] |
| 1759 | +#define BN0_WF_MIB_TOP_M0SDR21_OFDM_GREEN_MDRDY_TIME_MASK 0x00FFFFFF // OFDM_GREEN_MDRDY_TIME[23..0] |
| 1760 | + |
| 1761 | +#define BN0_WF_MIB_TOP_M0SDR22_ADDR (BN0_WF_MIB_TOP_BASE + 0x60) // D060 |
| 1762 | +#define BN0_WF_MIB_TOP_M0SDR23_ADDR (BN0_WF_MIB_TOP_BASE + 0x64) // D064 |
| 1763 | + |
| 1764 | +#define BN0_WF_MIB_TOP_M0SDR34_MUBF_TX_COUNT_MASK 0x0000FFFF // MUBF_TX_COUNT[15..0] |
| 1765 | + |
| 1766 | +#define BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_MASK 0xFFFF0000 // TX_40MHZ_CNT[31..16] |
| 1767 | +#define BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_SHFT 16 |
| 1768 | +#define BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_MASK 0x0000FFFF // TX_20MHZ_CNT[15..0] |
| 1769 | +#define BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_SHFT 0 |
| 1770 | + |
| 1771 | +#define BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_MASK 0xFFFF0000 // TX_160MHZ_CNT[31..16] |
| 1772 | +#define BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_SHFT 16 |
| 1773 | +#define BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_MASK 0x0000FFFF // TX_80MHZ_CNT[15..0] |
| 1774 | +#define BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_SHFT 0 |
| 1775 | + |
| 1776 | +#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_MASK 0xFFFF0000 // TX_DDLMT_RNG2_CNT[31..16] |
| 1777 | +#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_SHFT 16 |
| 1778 | +#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG1_CNT[15..0] |
| 1779 | +#define BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_SHFT 0 |
| 1780 | + |
| 1781 | +#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_MASK 0xFFFF0000 // TX_DDLMT_RNG4_CNT[31..16] |
| 1782 | +#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_SHFT 16 |
| 1783 | +#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG3_CNT[15..0] |
| 1784 | +#define BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_SHFT 0 |
| 1785 | + |
| 1786 | +#define BN0_WF_MIB_TOP_M0DR10_MU_FAIL_PPDU_CNT_MASK 0x0000FFFF // MU_FAIL_PPDU_CNT[15..0] |
| 1787 | + |
| 1788 | +#define BN0_WF_MIB_TOP_M0B0SDR0_ADDR (BN0_WF_MIB_TOP_BASE + 0x100) // D100 |
| 1789 | +#define BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_MASK 0xFFFF0000 // RTSRETRYCOUNT[31..16] |
| 1790 | +#define BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_SHFT 16 |
| 1791 | +#define BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_MASK 0x0000FFFF // RTSTXCOUNT[15..0] |
| 1792 | +#define BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_SHFT 0 |
| 1793 | +#define BN0_WF_MIB_TOP_M0B0SDR1_ADDR (BN0_WF_MIB_TOP_BASE + 0x104) // D104 |
| 1794 | +#define BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_MASK 0xFFFF0000 // ACKFAILCOUNT[31..16] |
| 1795 | +#define BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_SHFT 16 |
| 1796 | +#define BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_MASK 0x0000FFFF // BAMISSCOUNT[15..0] |
| 1797 | +#define BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_SHFT 0 |
| 1798 | +#define BN0_WF_MIB_TOP_M0B0SDR2_ADDR (BN0_WF_MIB_TOP_BASE + 0x108) // D108 |
| 1799 | +#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_MASK 0xFFFF0000 // FRAMERETRY2COUNT[31..16] |
| 1800 | +#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_SHFT 16 |
| 1801 | +#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_MASK 0x0000FFFF // FRAMERETRYCOUNT[15..0] |
| 1802 | +#define BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_SHFT 0 |
| 1803 | +#define BN0_WF_MIB_TOP_M0B0SDR3_ADDR (BN0_WF_MIB_TOP_BASE + 0x10C) // D10C |
| 1804 | +#define BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_MASK 0x0000FFFF // FRAMERETRY3COUNT[15..0] |
| 1805 | +#define BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_SHFT 0 |
| 1806 | +#define BN0_WF_MIB_TOP_M0DR12_TX_DDLMT_RNG0_CNT_MASK 0x0000FFFF // TX_DDLMT_RNG0_CNT[15..0] |
| 1807 | + |
| 1808 | + |
| 1809 | +#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK 0xFFFF0000 // TX_OK_COUNT2np1[31..16] |
| 1810 | +#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT 16 |
| 1811 | +#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK 0x0000FFFF // TX_OK_COUNT2n[15..0] |
| 1812 | +#define BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT 0 |
| 1813 | + |
| 1814 | +#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_MASK 0xFFFF0000 // TX_DATA_COUNT2np1[31..16] |
| 1815 | +#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_SHFT 16 |
| 1816 | +#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_MASK 0x0000FFFF // TX_DATA_COUNT2n[15..0] |
| 1817 | +#define BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_SHFT 0 |
| 1818 | + |
| 1819 | +#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK 0xFFFF0000 // RX_OK_COUNT2np1[31..16] |
| 1820 | +#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT 16 |
| 1821 | +#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK 0x0000FFFF // RX_OK_COUNT2n[15..0] |
| 1822 | +#define BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT 0 |
| 1823 | + |
| 1824 | +#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_MASK 0xFFFF0000 // RX_DATA_COUNT2np1[31..16] |
| 1825 | +#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_SHFT 16 |
| 1826 | +#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_MASK 0x0000FFFF // RX_DATA_COUNT2n[15..0] |
| 1827 | +#define BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_SHFT 0 |
| 1828 | + |
| 1829 | +#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_MASK 0xFFFF0000 // RTSTXCOUNT2np1[31..16] |
| 1830 | +#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_SHFT 16 |
| 1831 | +#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_MASK 0x0000FFFF // RTSTXCOUNT2n[15..0] |
| 1832 | +#define BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_SHFT 0 |
| 1833 | + |
| 1834 | +#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_MASK 0xFFFF0000 // RTSRETRYCOUNT2np1[31..16] |
| 1835 | +#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_SHFT 16 |
| 1836 | +#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_MASK 0x0000FFFF // RTSRETRYCOUNT2n[15..0] |
| 1837 | +#define BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_SHFT 0 |
| 1838 | + |
| 1839 | +#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_MASK 0xFFFF0000 // BAMISSCOUNT2np1[31..16] |
| 1840 | +#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_SHFT 16 |
| 1841 | +#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_MASK 0x0000FFFF // BAMISSCOUNT2n[15..0] |
| 1842 | +#define BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_SHFT 0 |
| 1843 | + |
| 1844 | +#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_MASK 0xFFFF0000 // ACKFAILCOUNT2np1[31..16] |
| 1845 | +#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_SHFT 16 |
| 1846 | +#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_MASK 0x0000FFFF // ACKFAILCOUNT2n[15..0] |
| 1847 | +#define BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_SHFT 0 |
| 1848 | + |
| 1849 | +#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_MASK 0xFFFF0000 // FRAMERETRYCOUNT2np1[31..16] |
| 1850 | +#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_SHFT 16 |
| 1851 | +#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_MASK 0x0000FFFF // FRAMERETRYCOUNT2n[15..0] |
| 1852 | +#define BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_SHFT 0 |
| 1853 | + |
| 1854 | +#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_MASK 0xFFFF0000 // FRAMERETRY2COUNT2np1[31..16] |
| 1855 | +#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_SHFT 16 |
| 1856 | +#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_MASK 0x0000FFFF // FRAMERETRY2COUNT2n[15..0] |
| 1857 | +#define BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_SHFT 0 |
| 1858 | + |
| 1859 | +#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_MASK 0xFFFF0000 // FRAMERETRY3COUNT2np1[31..16] |
| 1860 | +#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_SHFT 16 |
| 1861 | +#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_MASK 0x0000FFFF // FRAMERETRY3COUNT2n[15..0] |
| 1862 | +#define BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_SHFT 0 |
| 1863 | +/* TXD */ |
| 1864 | + |
| 1865 | +#define MT_TXD1_ETYP BIT(15) |
| 1866 | +#define MT_TXD1_VLAN BIT(14) |
| 1867 | +#define MT_TXD1_RMVL BIT(13) |
| 1868 | +#define MT_TXD1_AMS BIT(13) |
| 1869 | +#define MT_TXD1_EOSP BIT(12) |
| 1870 | +#define MT_TXD1_MRD BIT(11) |
| 1871 | + |
| 1872 | +#define MT_TXD7_CTXD BIT(26) |
| 1873 | +#define MT_TXD7_CTXD_CNT GENMASK(25, 23) |
| 1874 | +#define MT_TXD7_TAT GENMASK(9, 0) |
| 1875 | + |
| 1876 | +#endif |
| 1877 | +#endif |
| 1878 | diff --git a/mt7915/mtk_debugfs.c b/mt7915/mtk_debugfs.c |
| 1879 | new file mode 100644 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 1880 | index 0000000..275acc6 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1881 | --- /dev/null |
| 1882 | +++ b/mt7915/mtk_debugfs.c |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 1883 | @@ -0,0 +1,3622 @@ |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 1884 | +#include<linux/inet.h> |
| 1885 | +#include "mt7915.h" |
| 1886 | +#include "mt7915_debug.h" |
| 1887 | +#include "mac.h" |
| 1888 | +#include "mcu.h" |
| 1889 | + |
| 1890 | +#ifdef MTK_DEBUG |
| 1891 | +#define LWTBL_IDX2BASE_ID GENMASK(14, 8) |
| 1892 | +#define LWTBL_IDX2BASE_DW GENMASK(7, 2) |
| 1893 | +#define LWTBL_IDX2BASE(_id, _dw) (MT_DBG_WTBL_BASE | \ |
| 1894 | + FIELD_PREP(LWTBL_IDX2BASE_ID, _id) | \ |
| 1895 | + FIELD_PREP(LWTBL_IDX2BASE_DW, _dw)) |
| 1896 | + |
| 1897 | +#define UWTBL_IDX2BASE_ID GENMASK(12, 6) |
| 1898 | +#define UWTBL_IDX2BASE_DW GENMASK(5, 2) |
| 1899 | +#define UWTBL_IDX2BASE(_id, _dw) (MT_DBG_UWTBL_TOP_BASE | 0x2000 | \ |
| 1900 | + FIELD_PREP(UWTBL_IDX2BASE_ID, _id) | \ |
| 1901 | + FIELD_PREP(UWTBL_IDX2BASE_DW, _dw)) |
| 1902 | + |
| 1903 | +#define KEYTBL_IDX2BASE_KEY GENMASK(12, 6) |
| 1904 | +#define KEYTBL_IDX2BASE_DW GENMASK(5, 2) |
| 1905 | +#define KEYTBL_IDX2BASE(_key, _dw) (MT_DBG_UWTBL_TOP_BASE | 0x2000 | \ |
| 1906 | + FIELD_PREP(KEYTBL_IDX2BASE_KEY, _key) | \ |
| 1907 | + FIELD_PREP(KEYTBL_IDX2BASE_DW, _dw)) |
| 1908 | + |
| 1909 | +enum mt7915_wtbl_type { |
| 1910 | + WTBL_TYPE_LMAC, /* WTBL in LMAC */ |
| 1911 | + WTBL_TYPE_UMAC, /* WTBL in UMAC */ |
| 1912 | + WTBL_TYPE_KEY, /* Key Table */ |
| 1913 | + MAX_NUM_WTBL_TYPE |
| 1914 | +}; |
| 1915 | + |
| 1916 | +static int mt7915_wtbl_read_raw(struct mt7915_dev *dev, u16 idx, |
| 1917 | + enum mt7915_wtbl_type type, u16 start_dw, |
| 1918 | + u16 len, void *buf) |
| 1919 | +{ |
| 1920 | + u32 *dest_cpy = (u32 *)buf; |
| 1921 | + u32 size_dw = len; |
| 1922 | + u32 src = 0; |
| 1923 | + |
| 1924 | + if (!buf) |
| 1925 | + return 0xFF; |
| 1926 | + |
| 1927 | + if (type == WTBL_TYPE_LMAC) { |
| 1928 | + mt76_wr(dev, MT_DBG_WTBLON_TOP_WDUCR, |
| 1929 | + FIELD_PREP(MT_DBG_WTBLON_TOP_WDUCR_GROUP, (idx >> 7))); |
| 1930 | + src = LWTBL_IDX2BASE(idx, start_dw); |
| 1931 | + } else if (type == WTBL_TYPE_UMAC) { |
| 1932 | + mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR, |
| 1933 | + FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7))); |
| 1934 | + src = UWTBL_IDX2BASE(idx, start_dw); |
| 1935 | + } else if (type == WTBL_TYPE_KEY) { |
| 1936 | + mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR, |
| 1937 | + MT_UWTBL_TOP_WDUCR_TARGET | |
| 1938 | + FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7))); |
| 1939 | + src = KEYTBL_IDX2BASE(idx, start_dw); |
| 1940 | + } |
| 1941 | + |
| 1942 | + while (size_dw--) { |
| 1943 | + *dest_cpy++ = mt76_rr(dev, src); |
| 1944 | + src += 4; |
| 1945 | + }; |
| 1946 | + |
| 1947 | + return 0; |
| 1948 | +} |
| 1949 | + |
| 1950 | +static int mt7915_wtbl_write_raw(struct mt7915_dev *dev, u16 idx, |
| 1951 | + enum mt7915_wtbl_type type, u16 start_dw, |
| 1952 | + u32 val) |
| 1953 | +{ |
| 1954 | + u32 addr = 0; |
| 1955 | + |
| 1956 | + if (type == WTBL_TYPE_LMAC) { |
| 1957 | + mt76_wr(dev, MT_DBG_WTBLON_TOP_WDUCR, |
| 1958 | + FIELD_PREP(MT_WTBLON_TOP_WDUCR_GROUP, (idx >> 7))); |
| 1959 | + addr = LWTBL_IDX2BASE(idx, start_dw); |
| 1960 | + } else if (type == WTBL_TYPE_UMAC) { |
| 1961 | + mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR, |
| 1962 | + FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7))); |
| 1963 | + addr = UWTBL_IDX2BASE(idx, start_dw); |
| 1964 | + } else if (type == WTBL_TYPE_KEY) { |
| 1965 | + mt76_wr(dev, MT_DBG_UWTBL_TOP_WDUCR, |
| 1966 | + MT_UWTBL_TOP_WDUCR_TARGET | |
| 1967 | + FIELD_PREP(MT_UWTBL_TOP_WDUCR_GROUP, (idx >> 7))); |
| 1968 | + addr = KEYTBL_IDX2BASE(idx, start_dw); |
| 1969 | + } |
| 1970 | + |
| 1971 | + mt76_wr(dev, addr, val); |
| 1972 | + |
| 1973 | + return 0; |
| 1974 | +} |
| 1975 | + |
| 1976 | +void mt7915_packet_log_to_host(struct mt7915_dev *dev, const void *data, int len, int type, int des_len) |
| 1977 | +{ |
| 1978 | + struct bin_debug_hdr *hdr; |
| 1979 | + char *buf; |
| 1980 | + |
| 1981 | + if (len > 1500 - sizeof(*hdr)) |
| 1982 | + len = 1500 - sizeof(*hdr); |
| 1983 | + |
| 1984 | + buf = kzalloc(sizeof(*hdr) + len, GFP_KERNEL); |
| 1985 | + if (!buf) |
| 1986 | + return; |
| 1987 | + |
| 1988 | + hdr = (struct bin_debug_hdr *)buf; |
| 1989 | + hdr->magic_num = cpu_to_le32(PKT_BIN_DEBUG_MAGIC); |
| 1990 | + hdr->serial_id = cpu_to_le16(dev->dbg.fwlog_seq++); |
| 1991 | + hdr->msg_type = cpu_to_le16(type); |
| 1992 | + hdr->len = cpu_to_le16(len); |
| 1993 | + hdr->des_len = cpu_to_le16(des_len); |
| 1994 | + |
| 1995 | + memcpy(buf + sizeof(*hdr), data, len); |
| 1996 | + |
| 1997 | + mt7915_debugfs_rx_log(dev, buf, sizeof(*hdr) + len); |
| 1998 | +} |
| 1999 | + |
| 2000 | +static int |
| 2001 | +mt7915_fw_debug_module_set(void *data, u64 module) |
| 2002 | +{ |
| 2003 | + struct mt7915_dev *dev = data; |
| 2004 | + |
| 2005 | + dev->dbg.fw_dbg_module = module; |
| 2006 | + return 0; |
| 2007 | +} |
| 2008 | + |
| 2009 | +static int |
| 2010 | +mt7915_fw_debug_module_get(void *data, u64 *module) |
| 2011 | +{ |
| 2012 | + struct mt7915_dev *dev = data; |
| 2013 | + |
| 2014 | + *module = dev->dbg.fw_dbg_module; |
| 2015 | + return 0; |
| 2016 | +} |
| 2017 | + |
| 2018 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_module, mt7915_fw_debug_module_get, |
| 2019 | + mt7915_fw_debug_module_set, "%lld\n"); |
| 2020 | + |
| 2021 | +static int |
| 2022 | +mt7915_fw_debug_level_set(void *data, u64 level) |
| 2023 | +{ |
| 2024 | + struct mt7915_dev *dev = data; |
| 2025 | + |
| 2026 | + dev->dbg.fw_dbg_lv = level; |
| 2027 | + mt7915_mcu_fw_dbg_ctrl(dev, dev->dbg.fw_dbg_module, dev->dbg.fw_dbg_lv); |
| 2028 | + return 0; |
| 2029 | +} |
| 2030 | + |
| 2031 | +static int |
| 2032 | +mt7915_fw_debug_level_get(void *data, u64 *level) |
| 2033 | +{ |
| 2034 | + struct mt7915_dev *dev = data; |
| 2035 | + |
| 2036 | + *level = dev->dbg.fw_dbg_lv; |
| 2037 | + return 0; |
| 2038 | +} |
| 2039 | + |
| 2040 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_fw_debug_level, mt7915_fw_debug_level_get, |
| 2041 | + mt7915_fw_debug_level_set, "%lld\n"); |
| 2042 | + |
| 2043 | +#define MAX_TX_MODE 12 |
| 2044 | +static char *HW_TX_MODE_STR[] = {"CCK", "OFDM", "HT-Mix", "HT-GF", "VHT", |
| 2045 | + "N/A", "N/A", "N/A", "HE_SU", "HE_EXT_SU", |
| 2046 | + "HE_TRIG", "HE_MU", "N/A"}; |
| 2047 | +static char *HW_TX_RATE_CCK_STR[] = {"1M", "2Mlong", "5.5Mlong", "11Mlong", |
| 2048 | + "N/A", "2Mshort", "5.5Mshort", "11Mshort", |
| 2049 | + "N/A"}; |
| 2050 | +static char *HW_TX_RATE_OFDM_STR[] = {"6M", "9M", "12M", "18M", "24M", "36M", |
| 2051 | + "48M", "54M", "N/A"}; |
| 2052 | +static char *fcap_str[] = {"20MHz", "20/40MHz", "20/40/80MHz", |
| 2053 | + "20/40/80/160/80+80MHz"}; |
| 2054 | + |
| 2055 | +static char *hw_rate_ofdm_str(u16 ofdm_idx) |
| 2056 | +{ |
| 2057 | + switch (ofdm_idx) { |
| 2058 | + case 11: /* 6M */ |
| 2059 | + return HW_TX_RATE_OFDM_STR[0]; |
| 2060 | + |
| 2061 | + case 15: /* 9M */ |
| 2062 | + return HW_TX_RATE_OFDM_STR[1]; |
| 2063 | + |
| 2064 | + case 10: /* 12M */ |
| 2065 | + return HW_TX_RATE_OFDM_STR[2]; |
| 2066 | + |
| 2067 | + case 14: /* 18M */ |
| 2068 | + return HW_TX_RATE_OFDM_STR[3]; |
| 2069 | + |
| 2070 | + case 9: /* 24M */ |
| 2071 | + return HW_TX_RATE_OFDM_STR[4]; |
| 2072 | + |
| 2073 | + case 13: /* 36M */ |
| 2074 | + return HW_TX_RATE_OFDM_STR[5]; |
| 2075 | + |
| 2076 | + case 8: /* 48M */ |
| 2077 | + return HW_TX_RATE_OFDM_STR[6]; |
| 2078 | + |
| 2079 | + case 12: /* 54M */ |
| 2080 | + return HW_TX_RATE_OFDM_STR[7]; |
| 2081 | + |
| 2082 | + default: |
| 2083 | + return HW_TX_RATE_OFDM_STR[8]; |
| 2084 | + } |
| 2085 | +} |
| 2086 | + |
| 2087 | +static char *hw_rate_str(u8 mode, u16 rate_idx) |
| 2088 | +{ |
| 2089 | + if (mode == 0) |
| 2090 | + return rate_idx < 8 ? HW_TX_RATE_CCK_STR[rate_idx] : HW_TX_RATE_CCK_STR[8]; |
| 2091 | + else if (mode == 1) |
| 2092 | + return hw_rate_ofdm_str(rate_idx); |
| 2093 | + else |
| 2094 | + return "MCS"; |
| 2095 | +} |
| 2096 | + |
| 2097 | +static void parse_rate(struct seq_file *s, u16 rate_idx, u16 txrate) |
| 2098 | +{ |
| 2099 | + u16 txmode, mcs, nss, stbc; |
| 2100 | + |
| 2101 | + txmode = FIELD_GET(GENMASK(9, 6), txrate); |
| 2102 | + mcs = FIELD_GET(GENMASK(5, 0), txrate); |
| 2103 | + nss = FIELD_GET(GENMASK(12, 10), txrate); |
| 2104 | + stbc = FIELD_GET(BIT(13), txrate); |
| 2105 | + |
| 2106 | + seq_printf(s, "\tRate%d(0x%x):TxMode=%d(%s), TxRate=%d(%s), Nsts=%d, STBC=%d\n", |
| 2107 | + rate_idx + 1, txrate, |
| 2108 | + txmode, (txmode < MAX_TX_MODE ? HW_TX_MODE_STR[txmode] : HW_TX_MODE_STR[MAX_TX_MODE]), |
| 2109 | + mcs, hw_rate_str(txmode, mcs), nss, stbc); |
| 2110 | +} |
| 2111 | + |
| 2112 | +#define LWTBL_LEN_IN_DW 32 |
| 2113 | +#define UWTBL_LEN_IN_DW 8 |
| 2114 | +#define ONE_KEY_ENTRY_LEN_IN_DW 8 |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 2115 | +static int mt7915_sta_info(struct seq_file *s, void *data) |
| 2116 | +{ |
| 2117 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 2118 | + u8 lwtbl[LWTBL_LEN_IN_DW*4] = {0}; |
| 2119 | + u16 i = 0; |
| 2120 | + |
| 2121 | + for (i=0; i < mt7915_wtbl_size(dev); i++) { |
| 2122 | + mt7915_wtbl_read_raw(dev, i, WTBL_TYPE_LMAC, 0, |
| 2123 | + LWTBL_LEN_IN_DW, lwtbl); |
| 2124 | + if (lwtbl[4] || lwtbl[5] || lwtbl[6] || lwtbl[7] || lwtbl[0] || lwtbl[1]) |
| 2125 | + seq_printf(s, "wcid:%d\tAddr: %02x:%02x:%02x:%02x:%02x:%02x\n", |
| 2126 | + i, lwtbl[4], lwtbl[5], lwtbl[6], lwtbl[7], lwtbl[0], lwtbl[1]); |
| 2127 | + } |
| 2128 | + |
| 2129 | + return 0; |
| 2130 | +} |
| 2131 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2132 | +static int mt7915_wtbl_read(struct seq_file *s, void *data) |
| 2133 | +{ |
| 2134 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 2135 | + u8 lwtbl[LWTBL_LEN_IN_DW*4] = {0}; |
| 2136 | + int x; |
| 2137 | + u32 *addr = 0; |
| 2138 | + u32 dw_value = 0; |
| 2139 | + |
| 2140 | + mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_LMAC, 0, |
| 2141 | + LWTBL_LEN_IN_DW, lwtbl); |
| 2142 | + seq_printf(s, "Dump WTBL info of WLAN_IDX:%d\n", dev->wlan_idx); |
| 2143 | + seq_printf(s, "LMAC WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n", |
| 2144 | + MT_DBG_WTBLON_TOP_WDUCR, |
| 2145 | + mt76_rr(dev, MT_DBG_WTBLON_TOP_WDUCR), |
| 2146 | + LWTBL_IDX2BASE(dev->wlan_idx, 0)); |
| 2147 | + for (x = 0; x < LWTBL_LEN_IN_DW; x++) { |
| 2148 | + seq_printf(s, "DW%02d: %02x %02x %02x %02x\n", |
| 2149 | + x, |
| 2150 | + lwtbl[x * 4 + 3], |
| 2151 | + lwtbl[x * 4 + 2], |
| 2152 | + lwtbl[x * 4 + 1], |
| 2153 | + lwtbl[x * 4]); |
| 2154 | + } |
| 2155 | + |
| 2156 | + seq_printf(s, "\n\tAddr: %02x:%02x:%02x:%02x:%02x:%02x(D0[B0~15], D1[B0~31])\n", |
| 2157 | + lwtbl[4], lwtbl[5], lwtbl[6], lwtbl[7], lwtbl[0], lwtbl[1]); |
| 2158 | + |
| 2159 | + // DW0, DW1 |
| 2160 | + seq_printf(s, "LWTBL DW 0/1\n\t"); |
| 2161 | + addr = (u32 *)&(lwtbl[0]); |
| 2162 | + dw_value = *addr; |
| 2163 | + seq_printf(s, "MUAR_IDX:%lu/ ", FIELD_GET(GENMASK(21, 16), dw_value)); |
| 2164 | + seq_printf(s, "RCA1:%ld/ ", FIELD_GET(BIT(22), dw_value)); |
| 2165 | + seq_printf(s, "KID:%lu/ ", FIELD_GET(GENMASK(24, 23), dw_value)); |
| 2166 | + seq_printf(s, "RCID:%ld/ ", FIELD_GET(BIT(25), dw_value)); |
| 2167 | + seq_printf(s, "FROM_DS:%ld\n\t", FIELD_GET(BIT(26), dw_value)); |
| 2168 | + seq_printf(s, "TO_DS:%ld/ ", FIELD_GET(BIT(27), dw_value)); |
| 2169 | + seq_printf(s, "RV:%ld/ ", FIELD_GET(BIT(28), dw_value)); |
| 2170 | + seq_printf(s, "RCA2:%ld/ ", FIELD_GET(BIT(29), dw_value)); |
| 2171 | + seq_printf(s, "WPI_FLAG:%ld\n", FIELD_GET(BIT(30), dw_value)); |
| 2172 | + |
| 2173 | + // DW2 |
| 2174 | + seq_printf(s, "LWTBL DW 2\n\t"); |
| 2175 | + addr = (u32 *)&(lwtbl[2*4]); |
| 2176 | + dw_value = *addr; |
| 2177 | + seq_printf(s, "AID12:%lu/ ", FIELD_GET(GENMASK(11, 0), dw_value)); |
| 2178 | + seq_printf(s, "SU:%ld/ ", FIELD_GET(BIT(12), dw_value)); |
| 2179 | + seq_printf(s, "SPP_EN:%ld/ ", FIELD_GET(BIT(13), dw_value)); |
| 2180 | + seq_printf(s, "WPI_EVEN:%ld\n\t",FIELD_GET(BIT(14), dw_value)); |
| 2181 | + seq_printf(s, "CIPHER:%lu/ ", FIELD_GET(GENMASK(20, 16), dw_value)); |
| 2182 | + seq_printf(s, "CIPHER_IGTK:%lu/ ",FIELD_GET(GENMASK(22, 21), dw_value)); |
| 2183 | + seq_printf(s, "AAD_OM:%ld\n\t", FIELD_GET(BIT(15), dw_value)); |
| 2184 | + seq_printf(s, "SW:%ld/ ", FIELD_GET(BIT(24), dw_value)); |
| 2185 | + seq_printf(s, "UL:%ld/ ", FIELD_GET(BIT(25), dw_value)); |
| 2186 | + seq_printf(s, "TX_POWER_SAVE:%ld\n\t", FIELD_GET(BIT(26), dw_value)); |
| 2187 | + seq_printf(s, "QOS:%ld/ ", FIELD_GET(BIT(27), dw_value)); |
| 2188 | + seq_printf(s, "HT:%ld/ ", FIELD_GET(BIT(28), dw_value)); |
| 2189 | + seq_printf(s, "VHT:%ld/ ", FIELD_GET(BIT(29), dw_value)); |
| 2190 | + seq_printf(s, "HE:%ld/ ", FIELD_GET(BIT(30), dw_value)); |
| 2191 | + seq_printf(s, "MESH:%ld\n", FIELD_GET(BIT(31), dw_value)); |
| 2192 | + |
| 2193 | + // DW3 |
| 2194 | + seq_printf(s, "LWTBL DW 3\n\t"); |
| 2195 | + addr = (u32 *)&(lwtbl[3*4]); |
| 2196 | + dw_value = *addr; |
| 2197 | + seq_printf(s, "WMM_Q:%lu/ ", FIELD_GET(GENMASK(1, 0), dw_value)); |
| 2198 | + seq_printf(s, "RXD_DUP_MODE:%lu\n\t", FIELD_GET(GENMASK(3, 2), dw_value)); |
| 2199 | + seq_printf(s, "VLAN2ETH:%ld/ ", FIELD_GET(BIT(4), dw_value)); |
| 2200 | + seq_printf(s, "BEAM_CHG:%ld/ ", FIELD_GET(BIT(5), dw_value)); |
| 2201 | + seq_printf(s, "DIS_BA256:%ld\n\t", FIELD_GET(BIT(6), dw_value)); |
| 2202 | + seq_printf(s, "PFMU_IDX:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value)); |
| 2203 | + seq_printf(s, "ULPF_IDX:%lu\n\t", FIELD_GET(GENMASK(23, 16), dw_value)); |
| 2204 | + seq_printf(s, "RIBF:%ld/ ", FIELD_GET(BIT(24), dw_value)); |
| 2205 | + seq_printf(s, "ULPF:%ld\n\t", FIELD_GET(BIT(25), dw_value)); |
| 2206 | + seq_printf(s, "IGN_FBK:%ld/ ", FIELD_GET(BIT(26), dw_value)); |
| 2207 | + seq_printf(s, "TBF:%ld/ ", FIELD_GET(BIT(29), dw_value)); |
| 2208 | + seq_printf(s, "TBF_VHT:%ld/ ", FIELD_GET(BIT(30), dw_value)); |
| 2209 | + seq_printf(s, "TBF_HE:%ld\n", FIELD_GET(BIT(31), dw_value)); |
| 2210 | + |
| 2211 | + // DW4 |
| 2212 | + seq_printf(s, "LWTBL DW 4\n\t"); |
| 2213 | + addr = (u32 *)&(lwtbl[4*4]); |
| 2214 | + dw_value = *addr; |
| 2215 | + seq_printf(s, "ANT_ID_STS0:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value)); |
| 2216 | + seq_printf(s, "STS1:%lu/ ", FIELD_GET(GENMASK(5, 3), dw_value)); |
| 2217 | + seq_printf(s, "STS2:%lu/ ", FIELD_GET(GENMASK(8, 6), dw_value)); |
| 2218 | + seq_printf(s, "STS3:%lu\n\t", FIELD_GET(GENMASK(11, 9), dw_value)); |
| 2219 | + seq_printf(s, "ANT_ID_STS4:%lu/ ", FIELD_GET(GENMASK(14, 12), dw_value)); |
| 2220 | + seq_printf(s, "STS5:%lu/ ", FIELD_GET(GENMASK(17, 15), dw_value)); |
| 2221 | + seq_printf(s, "STS6:%ld/ ", FIELD_GET(GENMASK(20, 18), dw_value)); |
| 2222 | + seq_printf(s, "STS7:%lu\n\t", FIELD_GET(GENMASK(23, 21), dw_value)); |
| 2223 | + seq_printf(s, "CASCAD:%ld/ ", FIELD_GET(BIT(24), dw_value)); |
| 2224 | + seq_printf(s, "LDPC_HT:%ld/ ", FIELD_GET(BIT(25), dw_value)); |
| 2225 | + seq_printf(s, "LDPC_VHT:%ld/ ", FIELD_GET(BIT(26), dw_value)); |
| 2226 | + seq_printf(s, "LDPC_HE:%ld\n\t", FIELD_GET(BIT(27), dw_value)); |
| 2227 | + seq_printf(s, "DIS_RHTR:%ld/ ", FIELD_GET(BIT(28), dw_value)); |
| 2228 | + seq_printf(s, "ALL_ACK:%ld/ ", FIELD_GET(BIT(29), dw_value)); |
| 2229 | + seq_printf(s, "DROP:%ld/ ", FIELD_GET(BIT(30), dw_value)); |
| 2230 | + seq_printf(s, "ACK_EN:%ld\n", FIELD_GET(BIT(31), dw_value)); |
| 2231 | + |
| 2232 | + // DW5 |
| 2233 | + seq_printf(s, "LWTBL DW 5\n\t"); |
| 2234 | + addr = (u32 *)&(lwtbl[5*4]); |
| 2235 | + dw_value = *addr; |
| 2236 | + seq_printf(s, "AF:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value)); |
| 2237 | + seq_printf(s, "AF_HE:%lu/ ", FIELD_GET(GENMASK(4, 3), dw_value)); |
| 2238 | + seq_printf(s, "RTS:%ld/ ", FIELD_GET(BIT(5), dw_value)); |
| 2239 | + seq_printf(s, "SMPS:%ld/ ", FIELD_GET(BIT(6), dw_value)); |
| 2240 | + seq_printf(s, "DYN_BW:%ld\n\t", FIELD_GET(BIT(7), dw_value)); |
| 2241 | + seq_printf(s, "MMSS:%lu/ ", FIELD_GET(GENMASK(10, 8), dw_value)); |
| 2242 | + seq_printf(s, "USR:%ld/ ", FIELD_GET(BIT(11), dw_value)); |
| 2243 | + seq_printf(s, "SR_RATE:%lu/ ", FIELD_GET(GENMASK(14, 12), dw_value)); |
| 2244 | + seq_printf(s, "SR_ABORT:%ld\n\t", FIELD_GET(BIT(15), dw_value)); |
| 2245 | + seq_printf(s, "TX_POWER_OFFSET:%lu/ ", FIELD_GET(GENMASK(21, 16), dw_value)); |
| 2246 | + seq_printf(s, "WTBL_MPDU_SIZE:%lu\n\t", FIELD_GET(GENMASK(23, 22), dw_value)); |
| 2247 | + seq_printf(s, "PE:%lu/ ", FIELD_GET(GENMASK(25, 24), dw_value)); |
| 2248 | + seq_printf(s, "DOPPL:%ld/ ", FIELD_GET(BIT(26), dw_value)); |
| 2249 | + seq_printf(s, "TXOP_PS_CAP:%ld/ ", FIELD_GET(BIT(27), dw_value)); |
| 2250 | + seq_printf(s, "DONOT_UPDATE_I_PSM:%ld\n\t", FIELD_GET(BIT(28), dw_value)); |
| 2251 | + seq_printf(s, "I_PSM:%ld/ ", FIELD_GET(BIT(29), dw_value)); |
| 2252 | + seq_printf(s, "PSM:%ld/ ", FIELD_GET(BIT(30), dw_value)); |
| 2253 | + seq_printf(s, "SKIP_TX:%ld\n", FIELD_GET(BIT(31), dw_value)); |
| 2254 | + |
| 2255 | + // DW6 |
| 2256 | + seq_printf(s, "LWTBL DW 6\n\t"); |
| 2257 | + seq_printf(s, "TID 0/1/2/3/4/5/6/7 BA_WIN_SIZE:"); |
| 2258 | + addr = (u32 *)&(lwtbl[6*4]); |
| 2259 | + dw_value = *addr; |
| 2260 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(3, 0), dw_value)); |
| 2261 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(7, 4), dw_value)); |
| 2262 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(11, 8), dw_value)); |
| 2263 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(15, 12), dw_value)); |
| 2264 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(19, 16), dw_value)); |
| 2265 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(23, 20), dw_value)); |
| 2266 | + seq_printf(s, "%lu/ ", FIELD_GET(GENMASK(27, 24), dw_value)); |
| 2267 | + seq_printf(s, "%lu\n", FIELD_GET(GENMASK(31, 28), dw_value)); |
| 2268 | + |
| 2269 | + // DW7 |
| 2270 | + seq_printf(s, "LWTBL DW 7\n\t"); |
| 2271 | + addr = (u32 *)&(lwtbl[7*4]); |
| 2272 | + dw_value = *addr; |
| 2273 | + seq_printf(s, "CBRN:%lu/ ", FIELD_GET(GENMASK(2, 0), dw_value)); |
| 2274 | + seq_printf(s, "DBNSS_EN:%ld/ ", FIELD_GET(BIT(3), dw_value)); |
| 2275 | + seq_printf(s, "BAF_EN:%ld/ ", FIELD_GET(BIT(4), dw_value)); |
| 2276 | + seq_printf(s, "RDGBA:%ld\n\t", FIELD_GET(BIT(5), dw_value)); |
| 2277 | + seq_printf(s, "RDG:%ld/ ", FIELD_GET(BIT(6), dw_value)); |
| 2278 | + seq_printf(s, "SPE_IDX:%lu/ ", FIELD_GET(GENMASK(11, 7), dw_value)); |
| 2279 | + seq_printf(s, "G2:%ld/ ", FIELD_GET(BIT(12), dw_value)); |
| 2280 | + seq_printf(s, "G4:%ld/ ", FIELD_GET(BIT(13), dw_value)); |
| 2281 | + seq_printf(s, "G8:%ld/ ", FIELD_GET(BIT(14), dw_value)); |
| 2282 | + seq_printf(s, "G16:%ld\n\t", FIELD_GET(BIT(15), dw_value)); |
| 2283 | + seq_printf(s, "G2_LTF:%lu/ ", FIELD_GET(GENMASK(17, 16), dw_value)); |
| 2284 | + seq_printf(s, "G4_LTF:%lu/ ", FIELD_GET(GENMASK(19, 18), dw_value)); |
| 2285 | + seq_printf(s, "G8_LTF:%lu/ ", FIELD_GET(GENMASK(21, 20), dw_value)); |
| 2286 | + seq_printf(s, "G16_LTF:%lu\n\t", FIELD_GET(GENMASK(23, 22), dw_value)); |
| 2287 | + seq_printf(s, "G2_HE:%lu/ ", FIELD_GET(GENMASK(25, 24), dw_value)); |
| 2288 | + seq_printf(s, "G4_HE:%lu/ ", FIELD_GET(GENMASK(27, 27), dw_value)); |
| 2289 | + seq_printf(s, "G8_HE:%lu/ ", FIELD_GET(GENMASK(29, 28), dw_value)); |
| 2290 | + seq_printf(s, "G16_HE:%lu\n", FIELD_GET(GENMASK(31, 30), dw_value)); |
| 2291 | + |
| 2292 | + // DW8 |
| 2293 | + seq_printf(s, "LWTBL DW 8\n\t"); |
| 2294 | + addr = (u32 *)&(lwtbl[8*4]); |
| 2295 | + dw_value = *addr; |
| 2296 | + seq_printf(s, "FAIL_CNT_AC0:%lu/ ", FIELD_GET(GENMASK(4, 0), dw_value)); |
| 2297 | + seq_printf(s, "AC1:%lu/ ", FIELD_GET(GENMASK(9, 5), dw_value)); |
| 2298 | + seq_printf(s, "AC2:%lu/ ", FIELD_GET(GENMASK(14, 10), dw_value)); |
| 2299 | + seq_printf(s, "AC3:%lu\n\t", FIELD_GET(GENMASK(19, 15), dw_value)); |
| 2300 | + seq_printf(s, "PARTIAL_AID:%lu/ ", FIELD_GET(GENMASK(28, 20), dw_value)); |
| 2301 | + seq_printf(s, "CHK_PER:%lu\n", FIELD_GET(BIT(31), dw_value)); |
| 2302 | + |
| 2303 | + // DW9 |
| 2304 | + seq_printf(s, "LWTBL DW 9\n\t"); |
| 2305 | + addr = (u32 *)&(lwtbl[9*4]); |
| 2306 | + dw_value = *addr; |
| 2307 | + seq_printf(s, "RX_AVG_MPDU:%lu/ ", FIELD_GET(GENMASK(13, 0), dw_value)); |
| 2308 | + seq_printf(s, "PRITX_SW_MODE:%ld/ ", FIELD_GET(BIT(16), dw_value)); |
| 2309 | + seq_printf(s, "PRITX_PLR:%ld\n\t", FIELD_GET(BIT(17), dw_value)); |
| 2310 | + seq_printf(s, "PRITX_DCM:%ld/ ", FIELD_GET(BIT(18), dw_value)); |
| 2311 | + seq_printf(s, "PRITX_ER160:%ld/ ", FIELD_GET(BIT(19), dw_value)); |
| 2312 | + seq_printf(s, "PRITX_ERSU:%lu\n\t", FIELD_GET(BIT(20), dw_value)); |
| 2313 | + seq_printf(s, "MPDU_FAIL_CNT:%lu/ ", FIELD_GET(GENMASK(25, 23), dw_value)); |
| 2314 | + seq_printf(s, "MPDU_OK_CNT:%lu/ ", FIELD_GET(GENMASK(28, 26), dw_value)); |
| 2315 | + seq_printf(s, "RATE_IDX:%lu\n\t", FIELD_GET(GENMASK(31, 29), dw_value)); |
| 2316 | + seq_printf(s, "FCAP:%s\n", fcap_str[FIELD_GET(GENMASK(22, 21), dw_value)]); |
| 2317 | + |
| 2318 | + // DW10 |
| 2319 | + seq_printf(s, "LWTBL DW 10\n"); |
| 2320 | + addr = (u32 *)&(lwtbl[10*4]); |
| 2321 | + dw_value = *addr; |
| 2322 | + parse_rate(s, 0, FIELD_GET(GENMASK(13, 0), dw_value)); |
| 2323 | + parse_rate(s, 1, FIELD_GET(GENMASK(29, 16), dw_value)); |
| 2324 | + // DW11 |
| 2325 | + seq_printf(s, "LWTBL DW 11\n"); |
| 2326 | + addr = (u32 *)&(lwtbl[11*4]); |
| 2327 | + dw_value = *addr; |
| 2328 | + parse_rate(s, 2, FIELD_GET(GENMASK(13, 0), dw_value)); |
| 2329 | + parse_rate(s, 3, FIELD_GET(GENMASK(29, 16), dw_value)); |
| 2330 | + // DW12 |
| 2331 | + seq_printf(s, "LWTBL DW 12\n"); |
| 2332 | + addr = (u32 *)&(lwtbl[12*4]); |
| 2333 | + dw_value = *addr; |
| 2334 | + parse_rate(s, 4, FIELD_GET(GENMASK(13, 0), dw_value)); |
| 2335 | + parse_rate(s, 5, FIELD_GET(GENMASK(29, 16), dw_value)); |
| 2336 | + // DW13 |
| 2337 | + seq_printf(s, "LWTBL DW 13\n"); |
| 2338 | + addr = (u32 *)&(lwtbl[13*4]); |
| 2339 | + dw_value = *addr; |
| 2340 | + parse_rate(s, 6, FIELD_GET(GENMASK(13, 0), dw_value)); |
| 2341 | + parse_rate(s, 7, FIELD_GET(GENMASK(29, 16), dw_value)); |
| 2342 | + |
| 2343 | + //DW28 |
| 2344 | + seq_printf(s, "LWTBL DW 28\n\t"); |
| 2345 | + addr = (u32 *)&(lwtbl[28*4]); |
| 2346 | + dw_value = *addr; |
| 2347 | + seq_printf(s, "OM_INFO:%lu/ ", FIELD_GET(GENMASK(11, 0), dw_value)); |
| 2348 | + seq_printf(s, "OM_RXD_DUP_MODE:%u\n\t", !!(dw_value & BIT(12)) ); |
| 2349 | + |
| 2350 | + //DW29 |
| 2351 | + seq_printf(s, "LWTBL DW 29\n"); |
| 2352 | + addr = (u32 *)&(lwtbl[29*4]); |
| 2353 | + dw_value = *addr; |
| 2354 | + seq_printf(s, "USER_RSSI:%lu/ ", FIELD_GET(GENMASK(8, 0), dw_value)); |
| 2355 | + seq_printf(s, "USER_SNR:%lu/ ", FIELD_GET(GENMASK(14, 9), dw_value)); |
| 2356 | + seq_printf(s, "RAPID_REACTION_RATE:%lu/ ", FIELD_GET(GENMASK(26, 16), dw_value)); |
| 2357 | + seq_printf(s, "HT_AMSDU(Read Only):%u/ ", !!(dw_value & BIT(30)) ); |
| 2358 | + seq_printf(s, "AMSDU_CROSS_LG(Read Only):%u\n\t ", !!(dw_value & BIT(31))); |
| 2359 | + |
| 2360 | + //DW30 |
| 2361 | + seq_printf(s, "LWTBL DW 30\n\t"); |
| 2362 | + addr = (u32 *)&(lwtbl[30*4]); |
| 2363 | + dw_value = *addr; |
| 2364 | + seq_printf(s, "RCPI 0:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value)); |
| 2365 | + seq_printf(s, "RCPI 1:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value)); |
| 2366 | + seq_printf(s, "RCPI 2:%lu/ ", FIELD_GET(GENMASK(23, 16), dw_value)); |
| 2367 | + seq_printf(s, "RCPI 3:%lu\n\t", FIELD_GET(GENMASK(31, 24), dw_value)); |
| 2368 | + |
| 2369 | + //DW31 |
| 2370 | + seq_printf(s, "LWTBL DW 31\n\t"); |
| 2371 | + addr = (u32 *)&(lwtbl[31*4]); |
| 2372 | + dw_value = *addr; |
| 2373 | + seq_printf(s, "RCPI 4:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value)); |
| 2374 | + seq_printf(s, "RCPI 5:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value)); |
| 2375 | + seq_printf(s, "RCPI 6:%lu/ ", FIELD_GET(GENMASK(23, 16), dw_value)); |
| 2376 | + seq_printf(s, "RCPI 7:%lu\n\t", FIELD_GET(GENMASK(31, 24), dw_value)); |
| 2377 | + |
| 2378 | + return 0; |
| 2379 | +} |
| 2380 | + |
| 2381 | +static int mt7915_uwtbl_read(struct seq_file *s, void *data) |
| 2382 | +{ |
| 2383 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 2384 | + u8 uwtbl[UWTBL_LEN_IN_DW * 4] = {0}; |
| 2385 | + u8 keytbl[ONE_KEY_ENTRY_LEN_IN_DW*4] = {0}; |
| 2386 | + int x; |
| 2387 | + u32 *addr = 0; |
| 2388 | + u32 dw_value = 0; |
| 2389 | + u32 amsdu_len = 0; |
| 2390 | + u32 u2SN = 0; |
| 2391 | + u16 keyloc0, keyloc1; |
| 2392 | + |
| 2393 | + mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC, 0, |
| 2394 | + UWTBL_LEN_IN_DW, uwtbl); |
| 2395 | + seq_printf(s, "Dump WTBL info of WLAN_IDX:%d\n", dev->wlan_idx); |
| 2396 | + seq_printf(s, "UMAC WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n", |
developer | d8126d1 | 2023-02-17 11:50:45 +0800 | [diff] [blame] | 2397 | + MT_DBG_UWTBL_TOP_WDUCR, |
| 2398 | + mt76_rr(dev, MT_DBG_UWTBL_TOP_BASE), |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2399 | + UWTBL_IDX2BASE(dev->wlan_idx, 0)); |
| 2400 | + for (x = 0; x < UWTBL_LEN_IN_DW; x++) { |
| 2401 | + seq_printf(s, "DW%02d: %02x %02x %02x %02x\n", |
| 2402 | + x, |
| 2403 | + uwtbl[x * 4 + 3], |
| 2404 | + uwtbl[x * 4 + 2], |
| 2405 | + uwtbl[x * 4 + 1], |
| 2406 | + uwtbl[x * 4]); |
| 2407 | + } |
| 2408 | + |
| 2409 | + /* UMAC WTBL DW 0 */ |
| 2410 | + seq_printf(s, "\nUWTBL PN\n\t"); |
| 2411 | + addr = (u32 *)&(uwtbl[0]); |
| 2412 | + dw_value = *addr; |
| 2413 | + seq_printf(s, "PN0:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value)); |
| 2414 | + seq_printf(s, "PN1:%lu/ ", FIELD_GET(GENMASK(15, 8), dw_value)); |
| 2415 | + seq_printf(s, "PN2:%lu\n\t", FIELD_GET(GENMASK(23, 16), dw_value)); |
| 2416 | + seq_printf(s, "PN3:%lu/ ", FIELD_GET(GENMASK(31, 24), dw_value)); |
| 2417 | + |
| 2418 | + addr = (u32 *)&(uwtbl[1 * 4]); |
| 2419 | + dw_value = *addr; |
| 2420 | + seq_printf(s, "PN4:%lu/ ", FIELD_GET(GENMASK(7, 0), dw_value)); |
| 2421 | + seq_printf(s, "PN5:%lu\n", FIELD_GET(GENMASK(15, 8), dw_value)); |
| 2422 | + |
| 2423 | + /* UMAC WTBL DW SN part */ |
| 2424 | + seq_printf(s, "\nUWTBL SN\n"); |
| 2425 | + addr = (u32 *)&(uwtbl[2 * 4]); |
| 2426 | + dw_value = *addr; |
| 2427 | + seq_printf(s, "TID0_AC0_SN:%lu\n", FIELD_GET(GENMASK(11, 0), dw_value)); |
| 2428 | + seq_printf(s, "TID1_AC1_SN:%lu\n", FIELD_GET(GENMASK(23, 12), dw_value)); |
| 2429 | + |
| 2430 | + u2SN = FIELD_GET(GENMASK(31, 24), dw_value); |
| 2431 | + addr = (u32 *)&(uwtbl[3 * 4]); |
| 2432 | + dw_value = *addr; |
| 2433 | + u2SN |= FIELD_GET(GENMASK(3, 0), dw_value); |
| 2434 | + seq_printf(s, "TID2_AC2_SN:%u\n", u2SN); |
| 2435 | + seq_printf(s, "TID3_AC3_SN:%lu\n", FIELD_GET(GENMASK(15, 4), dw_value)); |
| 2436 | + seq_printf(s, "TID4_SN:%lu\n", FIELD_GET(GENMASK(27, 16), dw_value)); |
| 2437 | + |
| 2438 | + u2SN = FIELD_GET(GENMASK(31, 28), dw_value); |
| 2439 | + addr = (u32 *)&(uwtbl[4 * 4]); |
| 2440 | + dw_value = *addr; |
| 2441 | + u2SN |= FIELD_GET(GENMASK(7, 0), dw_value); |
| 2442 | + seq_printf(s, "TID5_SN:%u\n", u2SN); |
| 2443 | + seq_printf(s, "TID6_SN:%lu\n", FIELD_GET(GENMASK(19, 8), dw_value)); |
| 2444 | + seq_printf(s, "TID7_SN:%lu\n", FIELD_GET(GENMASK(31, 20), dw_value)); |
| 2445 | + |
| 2446 | + addr = (u32 *)&(uwtbl[1 * 4]); |
| 2447 | + dw_value = *addr; |
| 2448 | + seq_printf(s, "COM_SN:%lu\n", FIELD_GET(GENMASK(27, 16), dw_value)); |
| 2449 | + |
| 2450 | + /* UMAC WTBL DW 0 */ |
| 2451 | + seq_printf(s, "\nUWTBL others\n"); |
| 2452 | + |
| 2453 | + addr = (u32 *)&(uwtbl[5 * 4]); |
| 2454 | + dw_value = *addr; |
| 2455 | + keyloc0 = FIELD_GET(GENMASK(10, 0), dw_value); |
| 2456 | + keyloc1 = FIELD_GET(GENMASK(26, 16), dw_value); |
| 2457 | + seq_printf(s, "\tKey Loc 1/2:%lu/%lu\n", |
| 2458 | + FIELD_GET(GENMASK(10, 0), dw_value), |
| 2459 | + FIELD_GET(GENMASK(26, 16), dw_value)); |
| 2460 | + seq_printf(s, "\tUWTBL_QOS:%lu\n", FIELD_GET(BIT(27), dw_value)); |
| 2461 | + seq_printf(s, "\tUWTBL_HT_VHT_HE:%lu\n", FIELD_GET(BIT(28), dw_value)); |
| 2462 | + |
| 2463 | + addr = (u32 *)&(uwtbl[6*4]); |
| 2464 | + dw_value = *addr; |
| 2465 | + seq_printf(s, "\tHW AMSDU Enable:%lu\n", FIELD_GET(BIT(9), dw_value)); |
| 2466 | + |
| 2467 | + amsdu_len = FIELD_GET(GENMASK(5, 0), dw_value); |
| 2468 | + if (amsdu_len == 0) |
| 2469 | + seq_printf(s, "\tHW AMSDU Len:invalid (WTBL value=0x%x)\n", amsdu_len); |
| 2470 | + else if (amsdu_len == 1) |
| 2471 | + seq_printf(s, "\tHW AMSDU Len:%d~%d (WTBL value=0x%x)\n", |
| 2472 | + 1, |
| 2473 | + 255, |
| 2474 | + amsdu_len); |
| 2475 | + else |
| 2476 | + seq_printf(s, "\tHW AMSDU Len:%d~%d (WTBL value=0x%x)\n", |
| 2477 | + 256 * (amsdu_len - 1), |
| 2478 | + 256 * (amsdu_len - 1) + 255, |
| 2479 | + amsdu_len |
| 2480 | + ); |
| 2481 | + seq_printf(s, "\tHW AMSDU Num:%lu (WTBL value=0x%lx)\n", |
| 2482 | + FIELD_GET(GENMASK(8, 6), dw_value) + 1, |
| 2483 | + FIELD_GET(GENMASK(8, 6), dw_value)); |
| 2484 | + |
| 2485 | + /* Parse KEY link */ |
| 2486 | + seq_printf(s, "\n\tkeyloc0:%d\n", keyloc0); |
| 2487 | + if(keyloc0 != GENMASK(10, 0)) { |
| 2488 | + mt7915_wtbl_read_raw(dev, keyloc0, WTBL_TYPE_KEY, |
| 2489 | + 0, ONE_KEY_ENTRY_LEN_IN_DW, keytbl); |
| 2490 | + seq_printf(s, "KEY WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n", |
developer | d8126d1 | 2023-02-17 11:50:45 +0800 | [diff] [blame] | 2491 | + MT_DBG_UWTBL_TOP_WDUCR, |
| 2492 | + mt76_rr(dev, MT_DBG_UWTBL_TOP_BASE), |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2493 | + KEYTBL_IDX2BASE(keyloc0, 0)); |
| 2494 | + |
| 2495 | + for (x = 0; x < ONE_KEY_ENTRY_LEN_IN_DW; x++) { |
| 2496 | + seq_printf(s, "DW%02d: %02x %02x %02x %02x\n", |
| 2497 | + x, |
| 2498 | + keytbl[x * 4 + 3], |
| 2499 | + keytbl[x * 4 + 2], |
| 2500 | + keytbl[x * 4 + 1], |
| 2501 | + keytbl[x * 4]); |
| 2502 | + } |
| 2503 | + } |
| 2504 | + |
| 2505 | + seq_printf(s, "\n\tkeyloc1:%d\n", keyloc1); |
| 2506 | + if(keyloc1 != GENMASK(26, 16)) { |
| 2507 | + mt7915_wtbl_read_raw(dev, keyloc1, WTBL_TYPE_KEY, |
| 2508 | + 0, ONE_KEY_ENTRY_LEN_IN_DW, keytbl); |
| 2509 | + seq_printf(s, "KEY WTBL Addr: group:0x%x=0x%x addr: 0x%lx\n", |
developer | d8126d1 | 2023-02-17 11:50:45 +0800 | [diff] [blame] | 2510 | + MT_DBG_UWTBL_TOP_WDUCR, |
| 2511 | + mt76_rr(dev, MT_DBG_UWTBL_TOP_BASE), |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2512 | + KEYTBL_IDX2BASE(keyloc1, 0)); |
| 2513 | + |
| 2514 | + for (x = 0; x < ONE_KEY_ENTRY_LEN_IN_DW; x++) { |
| 2515 | + seq_printf(s, "DW%02d: %02x %02x %02x %02x\n", |
| 2516 | + x, |
| 2517 | + keytbl[x * 4 + 3], |
| 2518 | + keytbl[x * 4 + 2], |
| 2519 | + keytbl[x * 4 + 1], |
| 2520 | + keytbl[x * 4]); |
| 2521 | + } |
| 2522 | + } |
| 2523 | + return 0; |
| 2524 | +} |
| 2525 | + |
| 2526 | +static void |
| 2527 | +dump_dma_tx_ring_info(struct seq_file *s, struct mt7915_dev *dev, char *str, u32 ring_base) |
| 2528 | +{ |
| 2529 | + u32 base, cnt, cidx, didx, queue_cnt; |
| 2530 | + |
| 2531 | + base= mt76_rr(dev, ring_base); |
| 2532 | + cnt = mt76_rr(dev, ring_base + 4); |
| 2533 | + cidx = mt76_rr(dev, ring_base + 8); |
| 2534 | + didx = mt76_rr(dev, ring_base + 12); |
| 2535 | + queue_cnt = (cidx >= didx) ? (cidx - didx) : (cidx - didx + cnt); |
| 2536 | + |
| 2537 | + seq_printf(s, "%20s %10x %10x %10x %10x %10x\n", str, base, cnt, cidx, didx, queue_cnt); |
| 2538 | +} |
| 2539 | + |
| 2540 | +static void |
| 2541 | +dump_dma_rx_ring_info(struct seq_file *s, struct mt7915_dev *dev, char *str, u32 ring_base) |
| 2542 | +{ |
| 2543 | + u32 base, cnt, cidx, didx, queue_cnt; |
| 2544 | + |
| 2545 | + base= mt76_rr(dev, ring_base); |
| 2546 | + cnt = mt76_rr(dev, ring_base + 4); |
| 2547 | + cidx = mt76_rr(dev, ring_base + 8); |
| 2548 | + didx = mt76_rr(dev, ring_base + 12); |
| 2549 | + queue_cnt = (didx > cidx) ? (didx - cidx - 1) : (didx - cidx + cnt - 1); |
| 2550 | + |
| 2551 | + seq_printf(s, "%20s %10x %10x %10x %10x %10x\n", str, base, cnt, cidx, didx, queue_cnt); |
| 2552 | +} |
| 2553 | + |
| 2554 | +static void |
| 2555 | +mt7915_show_host_dma_info(struct seq_file *s, struct mt7915_dev *dev) |
| 2556 | +{ |
| 2557 | + u32 sys_ctrl[10] = {}; |
| 2558 | + |
| 2559 | + /* HOST DMA */ |
| 2560 | + sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT_SOURCE_CSR); |
| 2561 | + sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT_MASK_CSR); |
| 2562 | + sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_INT_SOURCE_CSR); |
| 2563 | + sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_INT_MASK_CSR); |
| 2564 | + sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA1_INT_SOURCE_CSR); |
| 2565 | + sys_ctrl[5] = mt76_rr(dev, MT_DBG_WFDMA1_INT_MASK_CSR); |
| 2566 | + sys_ctrl[6] = mt76_rr(dev, MT_DBG_WFDMA0_GLO_CFG); |
| 2567 | + sys_ctrl[7] = mt76_rr(dev, MT_DBG_WFDMA1_GLO_CFG); |
| 2568 | + seq_printf(s, "HOST_DMA Configuration\n"); |
| 2569 | + seq_printf(s, "%10s %10s %10s %10s %10s %10s\n", |
| 2570 | + "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy"); |
| 2571 | + seq_printf(s, "%10s %10x %10x\n", |
| 2572 | + "Merge", sys_ctrl[0], sys_ctrl[1]); |
| 2573 | + seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n", |
| 2574 | + "DMA0", sys_ctrl[2], sys_ctrl[3], sys_ctrl[6], |
| 2575 | + FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_TX_DMA_EN, sys_ctrl[6]), |
| 2576 | + FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_RX_DMA_EN, sys_ctrl[6]), |
| 2577 | + FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_TX_BUSY_MASK, sys_ctrl[6]), |
| 2578 | + FIELD_GET(MT_DBG_WFDMA0_GLO_CFG_RX_BUSY_MASK, sys_ctrl[6])); |
| 2579 | + |
| 2580 | + seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n", |
| 2581 | + "DMA1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[7], |
| 2582 | + FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_TX_DMA_EN, sys_ctrl[7]), |
| 2583 | + FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_RX_DMA_EN, sys_ctrl[7]), |
| 2584 | + FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[7]), |
| 2585 | + FIELD_GET(MT_DBG_WFDMA1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[7])); |
| 2586 | + |
| 2587 | + sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT1_SOURCE_CSR); |
| 2588 | + sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT1_MASK_CSR); |
| 2589 | + sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_INT_SOURCE_CSR); |
| 2590 | + sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_INT_MASK_CSR); |
| 2591 | + sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_INT_SOURCE_CSR); |
| 2592 | + sys_ctrl[5] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_INT_MASK_CSR); |
| 2593 | + sys_ctrl[6] = mt76_rr(dev, MT_DBG_WFDMA0_PCIE1_GLO_CFG); |
| 2594 | + sys_ctrl[7] = mt76_rr(dev, MT_DBG_WFDMA1_PCIE1_GLO_CFG); |
| 2595 | + seq_printf(s, "%10s %10x %10x\n", |
| 2596 | + "MergeP1", sys_ctrl[0], sys_ctrl[1]); |
| 2597 | + seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n", |
| 2598 | + "DMA0P1", sys_ctrl[2], sys_ctrl[3], sys_ctrl[6], |
| 2599 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN, sys_ctrl[6]), |
| 2600 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN, sys_ctrl[6]), |
| 2601 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[6]), |
| 2602 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[6])); |
| 2603 | + seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n", |
| 2604 | + "DMA1P1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[7], |
| 2605 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_DMA_EN, sys_ctrl[7]), |
| 2606 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_DMA_EN, sys_ctrl[7]), |
| 2607 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_TX_BUSY_MASK, sys_ctrl[7]), |
| 2608 | + FIELD_GET(MT_DBG_WFDMA0_PCIE1_GLO_CFG_RX_BUSY_MASK, sys_ctrl[7])); |
| 2609 | + |
| 2610 | + seq_printf(s, "HOST_DMA0 Ring Configuration\n"); |
| 2611 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2612 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2613 | + dump_dma_rx_ring_info(s, dev, "R0:Data0(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(0)); |
| 2614 | + dump_dma_rx_ring_info(s, dev, "R1:Data1(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(1)); |
| 2615 | + |
| 2616 | + seq_printf(s, "HOST_DMA0 PCIe 1 Ring Configuration\n"); |
| 2617 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2618 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2619 | + dump_dma_rx_ring_info(s, dev, "R1:Data1(MAC2H)", MT_DBG_WFDMA0_PCIE1_RX1_CTRL0); |
| 2620 | + |
| 2621 | + seq_printf(s, "HOST_DMA1 Ring Configuration\n"); |
| 2622 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2623 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2624 | + dump_dma_tx_ring_info(s, dev, "T16:FWDL", MT_DBG_TX_RING_CTRL(0)); |
| 2625 | + dump_dma_tx_ring_info(s, dev, "T17:Cmd(H2WM)", MT_DBG_TX_RING_CTRL(1)); |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2626 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) { |
| 2627 | + dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(0)); |
| 2628 | + dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(1)); |
| 2629 | + } else { |
| 2630 | + dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_TX_RING_CTRL(2)); |
| 2631 | + dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_TX_RING_CTRL(3)); |
| 2632 | + } |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2633 | + dump_dma_tx_ring_info(s, dev, "T20:Cmd(H2WA)", MT_DBG_TX_RING_CTRL(4)); |
| 2634 | + dump_dma_rx_ring_info(s, dev, "R0:Event(WM2H)", MT_DBG_RX_EVENT_RING_CTRL(0)); |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2635 | + if (mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| 2636 | + dump_dma_rx_ring_info(s, dev, "R1:TxDone(WA2H)", MT_DBG_WFDMA_WED_RX_CTRL(1)); |
| 2637 | + else |
| 2638 | + dump_dma_rx_ring_info(s, dev, "R1:Event0(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(1)); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2639 | + dump_dma_rx_ring_info(s, dev, "R2:Event1(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(2)); |
| 2640 | + |
| 2641 | + seq_printf(s, "HOST_DMA1 PCIe 1 Ring Configuration\n"); |
| 2642 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2643 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2644 | + dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA1_PCIE1_TX19_CTRL0); |
| 2645 | + dump_dma_rx_ring_info(s, dev, "R2:Event1(WA2H)", MT_DBG_WFDMA1_PCIE1_RX2_CTRL0); |
| 2646 | +} |
| 2647 | + |
| 2648 | +static void |
| 2649 | +mt7915_show_mcu_dma_info(struct seq_file *s, struct mt7915_dev *dev) |
| 2650 | +{ |
| 2651 | + u32 sys_ctrl[9] = {}; |
| 2652 | + |
| 2653 | + /* MCU DMA information */ |
| 2654 | + sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR); |
| 2655 | + sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR); |
| 2656 | + sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR); |
| 2657 | + |
| 2658 | + sys_ctrl[3] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_ADDR); |
| 2659 | + sys_ctrl[4] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_HOST_INT_STA_ADDR); |
| 2660 | + sys_ctrl[5] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_HOST_INT_ENA_ADDR); |
| 2661 | + sys_ctrl[6] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_ADDR); |
| 2662 | + sys_ctrl[7] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_STA_ADDR); |
| 2663 | + sys_ctrl[8] = mt76_rr(dev, WF_WFDMA_MCU_DMA1_PCIE1_HOST_INT_ENA_ADDR); |
| 2664 | + |
| 2665 | + seq_printf(s, "MCU_DMA Configuration\n"); |
| 2666 | + seq_printf(s, "%10s %10s %10s %10s %10s %10s\n", |
| 2667 | + "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy"); |
| 2668 | + seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n", |
| 2669 | + "DMA0", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0], |
| 2670 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT, |
| 2671 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT, |
| 2672 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT, |
| 2673 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT); |
| 2674 | + |
| 2675 | + seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n", |
| 2676 | + "DMA1", sys_ctrl[4], sys_ctrl[5], sys_ctrl[3], |
| 2677 | + (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT, |
| 2678 | + (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT, |
| 2679 | + (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT, |
| 2680 | + (sys_ctrl[3] & WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT); |
| 2681 | + seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n", |
| 2682 | + "DMA1P1", sys_ctrl[7], sys_ctrl[8], sys_ctrl[6], |
| 2683 | + (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_EN_SHFT, |
| 2684 | + (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_EN_SHFT, |
| 2685 | + (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT, |
| 2686 | + (sys_ctrl[6] & WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT); |
| 2687 | + |
| 2688 | + seq_printf(s, "MCU_DMA0 Ring Configuration\n"); |
| 2689 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2690 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2691 | + dump_dma_tx_ring_info(s, dev, "T0:TXD(WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR); |
| 2692 | + dump_dma_tx_ring_info(s, dev, "T1:TXCMD(WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR); |
| 2693 | + dump_dma_tx_ring_info(s, dev, "T2:TXD(WA2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR); |
| 2694 | + dump_dma_rx_ring_info(s, dev, "R0:Data(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR); |
| 2695 | + dump_dma_rx_ring_info(s, dev, "R1:TxDone(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR); |
| 2696 | + dump_dma_rx_ring_info(s, dev, "R2:SPL(MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR); |
| 2697 | + dump_dma_rx_ring_info(s, dev, "R3:TxDone(MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR); |
| 2698 | + dump_dma_rx_ring_info(s, dev, "R4:TXS(MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR); |
| 2699 | + |
| 2700 | + seq_printf(s, "MCU_DMA1 Ring Configuration\n"); |
| 2701 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2702 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2703 | + dump_dma_tx_ring_info(s, dev, "T0:Event(WM2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING0_CTRL0_ADDR); |
| 2704 | + dump_dma_tx_ring_info(s, dev, "T1:Event0(WA2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING1_CTRL0_ADDR); |
| 2705 | + dump_dma_tx_ring_info(s, dev, "T2:Event1(WA2H)", WF_WFDMA_MCU_DMA1_WPDMA_TX_RING2_CTRL0_ADDR); |
| 2706 | + dump_dma_rx_ring_info(s, dev, "R0:FWDL", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING0_CTRL0_ADDR); |
| 2707 | + dump_dma_rx_ring_info(s, dev, "R1:Cmd(H2WM)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING1_CTRL0_ADDR); |
| 2708 | + dump_dma_rx_ring_info(s, dev, "R2:TXD0(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING2_CTRL0_ADDR); |
| 2709 | + dump_dma_rx_ring_info(s, dev, "R3:TXD1(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING3_CTRL0_ADDR); |
| 2710 | + dump_dma_rx_ring_info(s, dev, "R4:Cmd(H2WA)", WF_WFDMA_MCU_DMA1_WPDMA_RX_RING4_CTRL0_ADDR); |
| 2711 | + |
| 2712 | + seq_printf(s, "MCU_DMA1 PCIe 1 Ring Configuration\n"); |
| 2713 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2714 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2715 | + dump_dma_tx_ring_info(s, dev, "T2:Event1(WA2H)", WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_TX_RING2_CTRL0_ADDR); |
| 2716 | + dump_dma_rx_ring_info(s, dev, "R3:TXD1(H2WA)", WF_WFDMA_MCU_DMA1_PCIE1_WPDMA_RX_RING3_CTRL0_ADDR); |
| 2717 | +} |
| 2718 | + |
| 2719 | +static void |
| 2720 | +mt7986_show_host_dma_info(struct seq_file *s, struct mt7915_dev *dev) |
| 2721 | +{ |
| 2722 | + u32 sys_ctrl[5] = {}; |
| 2723 | + |
| 2724 | + /* HOST DMA */ |
| 2725 | + sys_ctrl[0] = mt76_rr(dev, MT_DBG_INT_SOURCE_CSR); |
| 2726 | + sys_ctrl[1] = mt76_rr(dev, MT_DBG_INT_MASK_CSR); |
| 2727 | + sys_ctrl[2] = mt76_rr(dev, MT_DBG_WFDMA0_INT_SOURCE_CSR); |
| 2728 | + sys_ctrl[3] = mt76_rr(dev, MT_DBG_WFDMA0_INT_MASK_CSR); |
| 2729 | + sys_ctrl[4] = mt76_rr(dev, MT_DBG_WFDMA0_GLO_CFG); |
| 2730 | + |
| 2731 | + seq_printf(s, "HOST_DMA Configuration\n"); |
| 2732 | + seq_printf(s, "%10s %10s %10s %10s %10s %10s\n", |
| 2733 | + "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy"); |
| 2734 | + seq_printf(s, "%10s %10x %10x\n", |
| 2735 | + "Merge", sys_ctrl[0], sys_ctrl[1]); |
| 2736 | + seq_printf(s, "%10s %10x %10x %10x %4lx/%5lx %4lx/%5lx\n", |
| 2737 | + "DMA0", sys_ctrl[2], sys_ctrl[3], sys_ctrl[4], |
| 2738 | + FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_EN_MASK, sys_ctrl[4]), |
| 2739 | + FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_EN_MASK, sys_ctrl[4]), |
| 2740 | + FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_TX_DMA_BUSY_MASK, sys_ctrl[4]), |
| 2741 | + FIELD_GET(MT_DBG_WFDMA_HOST_DMA0_GLO_CFG_RX_DMA_BUSY_MASK, sys_ctrl[4])); |
| 2742 | + |
| 2743 | + |
| 2744 | + seq_printf(s, "HOST_DMA0 Ring Configuration\n"); |
| 2745 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2746 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2747 | + dump_dma_tx_ring_info(s, dev, "T16:FWDL", MT_DBG_TX_RING_CTRL(0)); |
| 2748 | + dump_dma_tx_ring_info(s, dev, "T17:Cmd(H2WM)", MT_DBG_TX_RING_CTRL(1)); |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2749 | + |
| 2750 | + if (is_mt7916(&dev->mt76) && mtk_wed_device_active(&dev->mt76.mmio.wed)) { |
| 2751 | + dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(0)); |
| 2752 | + dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_WFDMA_WED_TX_CTRL(1)); |
| 2753 | + } else { |
| 2754 | + dump_dma_tx_ring_info(s, dev, "T18:TXD0(H2WA)", MT_DBG_TX_RING_CTRL(2)); |
| 2755 | + dump_dma_tx_ring_info(s, dev, "T19:TXD1(H2WA)", MT_DBG_TX_RING_CTRL(3)); |
| 2756 | + } |
| 2757 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2758 | + dump_dma_tx_ring_info(s, dev, "T20:Cmd(H2WA)", MT_DBG_TX_RING_CTRL(4)); |
| 2759 | + dump_dma_rx_ring_info(s, dev, "R0:Event(WM2H)", MT_DBG_RX_DATA_RING_CTRL(0)); |
| 2760 | + dump_dma_rx_ring_info(s, dev, "R1:Event(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(1)); |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2761 | + if (is_mt7916(&dev->mt76) && mtk_wed_device_active(&dev->mt76.mmio.wed)) |
| 2762 | + dump_dma_rx_ring_info(s, dev, "R2:TxDone(WA2H)", MT_DBG_WFDMA_WED_RX_CTRL(1)); |
| 2763 | + else |
| 2764 | + dump_dma_rx_ring_info(s, dev, "R2:TxDone(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(2)); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2765 | + dump_dma_rx_ring_info(s, dev, "R3:TxDone1(WA2H)", MT_DBG_RX_EVENT_RING_CTRL(3)); |
| 2766 | + dump_dma_rx_ring_info(s, dev, "R4:Data0(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(0)); |
| 2767 | + dump_dma_rx_ring_info(s, dev, "R5:Data1(MAC2H)", MT_DBG_RX_DATA_RING_CTRL(1)); |
| 2768 | +} |
| 2769 | + |
| 2770 | +static void |
| 2771 | +mt7986_show_mcu_dma_info(struct seq_file *s, struct mt7915_dev *dev) |
| 2772 | +{ |
| 2773 | + u32 sys_ctrl[3] = {}; |
| 2774 | + |
| 2775 | + /* MCU DMA information */ |
| 2776 | + sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_ADDR); |
| 2777 | + sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_STA_ADDR); |
| 2778 | + sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MCU_DMA0_HOST_INT_ENA_ADDR); |
| 2779 | + |
| 2780 | + seq_printf(s, "MCU_DMA Configuration\n"); |
| 2781 | + seq_printf(s, "%10s %10s %10s %10s %10s %10s\n", |
| 2782 | + "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy"); |
| 2783 | + seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n", |
| 2784 | + "DMA0", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0], |
| 2785 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_EN_SHFT, |
| 2786 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_EN_SHFT, |
| 2787 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT, |
| 2788 | + (sys_ctrl[0] & WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MCU_DMA0_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT); |
| 2789 | + |
| 2790 | + seq_printf(s, "MCU_DMA0 Ring Configuration\n"); |
| 2791 | + seq_printf(s, "%22s %10s %10s %10s %10s %10s\n", |
| 2792 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2793 | + dump_dma_tx_ring_info(s, dev, "T0:Event (WM2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING0_CTRL0_ADDR); |
| 2794 | + dump_dma_tx_ring_info(s, dev, "T1:Event (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING1_CTRL0_ADDR); |
| 2795 | + dump_dma_tx_ring_info(s, dev, "T2:TxDone (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING2_CTRL0_ADDR); |
| 2796 | + dump_dma_tx_ring_info(s, dev, "T3:TxDone1 (WA2H)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING3_CTRL0_ADDR); |
| 2797 | + dump_dma_tx_ring_info(s, dev, "T4:TXD (WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING4_CTRL0_ADDR); |
| 2798 | + dump_dma_tx_ring_info(s, dev, "T5:TXCMD (WM2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING5_CTRL0_ADDR); |
| 2799 | + dump_dma_tx_ring_info(s, dev, "T6:TXD (WA2MAC)", WF_WFDMA_MCU_DMA0_WPDMA_TX_RING6_CTRL0_ADDR); |
| 2800 | + dump_dma_rx_ring_info(s, dev, "R0:FWDL", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING0_CTRL0_ADDR); |
| 2801 | + dump_dma_rx_ring_info(s, dev, "R1:Cmd (H2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING1_CTRL0_ADDR); |
| 2802 | + dump_dma_rx_ring_info(s, dev, "R2:TXD (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING2_CTRL0_ADDR); |
| 2803 | + dump_dma_rx_ring_info(s, dev, "R3:TXD1 (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING3_CTRL0_ADDR); |
| 2804 | + dump_dma_rx_ring_info(s, dev, "R4:Cmd (H2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING4_CTRL0_ADDR); |
| 2805 | + dump_dma_rx_ring_info(s, dev, "R5:Data (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING5_CTRL0_ADDR); |
| 2806 | + dump_dma_rx_ring_info(s, dev, "R6:TxDone/STS (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING6_CTRL0_ADDR); |
| 2807 | + dump_dma_rx_ring_info(s, dev, "R7:RPT (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING7_CTRL0_ADDR); |
| 2808 | + dump_dma_rx_ring_info(s, dev, "R8:TxDone/STS (MAC2WA)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING8_CTRL0_ADDR); |
| 2809 | + dump_dma_rx_ring_info(s, dev, "R9:Data1 (MAC2WM)", WF_WFDMA_MCU_DMA0_WPDMA_RX_RING9_CTRL0_ADDR); |
| 2810 | + |
| 2811 | +} |
| 2812 | + |
| 2813 | +static void |
| 2814 | +mt7915_show_dma_info(struct seq_file *s, struct mt7915_dev *dev) |
| 2815 | +{ |
| 2816 | + u32 sys_ctrl[10] = {}; |
| 2817 | + |
| 2818 | + if(is_mt7915(&dev->mt76)) { |
| 2819 | + mt7915_show_host_dma_info(s, dev); |
| 2820 | + mt7915_show_mcu_dma_info(s, dev); |
| 2821 | + } else { |
| 2822 | + mt7986_show_host_dma_info(s, dev); |
| 2823 | + mt7986_show_mcu_dma_info(s, dev); |
| 2824 | + } |
| 2825 | + |
| 2826 | + /* MEM DMA information */ |
| 2827 | + sys_ctrl[0] = mt76_rr(dev, WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_ADDR); |
| 2828 | + sys_ctrl[1] = mt76_rr(dev, WF_WFDMA_MEM_DMA_HOST_INT_STA_ADDR); |
| 2829 | + sys_ctrl[2] = mt76_rr(dev, WF_WFDMA_MEM_DMA_HOST_INT_ENA_ADDR); |
| 2830 | + |
| 2831 | + seq_printf(s, "MEM_DMA Configuration\n"); |
| 2832 | + seq_printf(s, "%10s %10s %10s %10s %10s %10s\n", |
| 2833 | + "DMA", "IntCSR", "IntMask", "Glocfg", "Tx/RxEn", "Tx/RxBusy"); |
| 2834 | + seq_printf(s, "%10s %10x %10x %10x %4x/%5x %4x/%5x\n", |
| 2835 | + "MEM", sys_ctrl[1], sys_ctrl[2], sys_ctrl[0], |
| 2836 | + (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_EN_SHFT, |
| 2837 | + (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_EN_SHFT, |
| 2838 | + (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_TX_DMA_BUSY_SHFT, |
| 2839 | + (sys_ctrl[0] & WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_MASK) >> WF_WFDMA_MEM_DMA_WPDMA_GLO_CFG_RX_DMA_BUSY_SHFT); |
| 2840 | + |
| 2841 | + seq_printf(s, "MEM_DMA Ring Configuration\n"); |
| 2842 | + seq_printf(s, "%20s %10s %10s %10s %10s %10s\n", |
| 2843 | + "Name", "Base", "Cnt", "CIDX", "DIDX", "QCnt"); |
| 2844 | + dump_dma_tx_ring_info(s, dev, "T0:CmdEvent(WM2WA)", WF_WFDMA_MEM_DMA_WPDMA_TX_RING0_CTRL0_ADDR); |
| 2845 | + dump_dma_tx_ring_info(s, dev, "T1:CmdEvent(WA2WM)", WF_WFDMA_MEM_DMA_WPDMA_TX_RING1_CTRL0_ADDR); |
| 2846 | + dump_dma_rx_ring_info(s, dev, "R0:CmdEvent(WM2WA)", WF_WFDMA_MEM_DMA_WPDMA_RX_RING0_CTRL0_ADDR); |
| 2847 | + dump_dma_rx_ring_info(s, dev, "R1:CmdEvent(WA2WM)", WF_WFDMA_MEM_DMA_WPDMA_RX_RING1_CTRL0_ADDR); |
| 2848 | +} |
| 2849 | + |
| 2850 | +static int mt7915_trinfo_read(struct seq_file *s, void *data) |
| 2851 | +{ |
| 2852 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 2853 | + const struct hif_pci_tx_ring_desc *tx_ring_layout; |
| 2854 | + const struct hif_pci_rx_ring_desc *rx_ring_layout; |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2855 | + struct mtk_wed_device *wed = &dev->mt76.mmio.wed; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2856 | + u32 tx_ring_num, rx_ring_num; |
| 2857 | + u32 tbase[5], tcnt[5]; |
| 2858 | + u32 tcidx[5], tdidx[5]; |
| 2859 | + u32 rbase[6], rcnt[6]; |
| 2860 | + u32 rcidx[6], rdidx[6]; |
| 2861 | + int idx; |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2862 | + bool flags = false; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2863 | + |
| 2864 | + if(is_mt7915(&dev->mt76)) { |
| 2865 | + tx_ring_layout = &mt7915_tx_ring_layout[0]; |
| 2866 | + rx_ring_layout = &mt7915_rx_ring_layout[0]; |
| 2867 | + tx_ring_num = ARRAY_SIZE(mt7915_tx_ring_layout); |
| 2868 | + rx_ring_num = ARRAY_SIZE(mt7915_rx_ring_layout); |
| 2869 | + } else { |
| 2870 | + tx_ring_layout = &mt7986_tx_ring_layout[0]; |
| 2871 | + rx_ring_layout = &mt7986_rx_ring_layout[0]; |
| 2872 | + tx_ring_num = ARRAY_SIZE(mt7986_tx_ring_layout); |
| 2873 | + rx_ring_num = ARRAY_SIZE(mt7986_rx_ring_layout); |
| 2874 | + } |
| 2875 | + |
| 2876 | + for (idx = 0; idx < tx_ring_num; idx++) { |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2877 | + if (mtk_wed_device_active(wed) && |
| 2878 | + (tx_ring_layout[idx].ring_attr == HIF_TX_DATA)) { |
| 2879 | + struct mt76_phy *phy = dev->mt76.phys[MT_BAND0]; |
| 2880 | + struct mt76_phy *ext_phy = dev->mt76.phys[MT_BAND1]; |
| 2881 | + struct mt76_queue *q; |
| 2882 | + |
| 2883 | + tbase[idx] = tcnt[idx] = tcidx[idx] = tdidx[idx] = 0; |
| 2884 | + |
| 2885 | + if (!phy) |
| 2886 | + continue; |
| 2887 | + |
| 2888 | + if (flags && !ext_phy) |
| 2889 | + continue; |
| 2890 | + |
| 2891 | + if (flags && ext_phy) |
| 2892 | + phy = ext_phy; |
| 2893 | + |
| 2894 | + q = phy->q_tx[0]; |
| 2895 | + |
| 2896 | + if (q->wed_regs) { |
| 2897 | + tbase[idx] = mtk_wed_device_reg_read(wed, q->wed_regs); |
| 2898 | + tcnt[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x04); |
| 2899 | + tcidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x08); |
| 2900 | + tdidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x0c); |
| 2901 | + } |
| 2902 | + |
| 2903 | + flags = true; |
| 2904 | + } else { |
| 2905 | + tbase[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx)); |
| 2906 | + tcnt[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x04); |
| 2907 | + tcidx[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x08); |
| 2908 | + tdidx[idx] = mt76_rr(dev, MT_DBG_TX_RING_CTRL(idx) + 0x0c);} |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2909 | + } |
| 2910 | + |
| 2911 | + for (idx = 0; idx < rx_ring_num; idx++) { |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2912 | + if (rx_ring_layout[idx].ring_attr == HIF_RX_DATA) { |
| 2913 | + if (mtk_wed_device_active(wed) && mtk_wed_get_rx_capa(wed)) { |
| 2914 | + struct mt76_queue *q = &dev->mt76.q_rx[MT_RXQ_MAIN]; |
| 2915 | + |
| 2916 | + rbase[idx] = rcnt[idx] = rcidx[idx] = rdidx[idx] = 0; |
| 2917 | + |
| 2918 | + if (idx == 1) |
| 2919 | + q = &dev->mt76.q_rx[MT_RXQ_BAND1]; |
| 2920 | + |
| 2921 | + if (q->wed_regs) { |
| 2922 | + rbase[idx] = mtk_wed_device_reg_read(wed, q->wed_regs); |
| 2923 | + rcnt[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x04); |
| 2924 | + rcidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x08); |
| 2925 | + rdidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x0c); |
| 2926 | + } |
| 2927 | + } else { |
| 2928 | + rbase[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx)); |
| 2929 | + rcnt[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x04); |
| 2930 | + rcidx[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x08); |
| 2931 | + rdidx[idx] = mt76_rr(dev, MT_DBG_RX_DATA_RING_CTRL(idx) + 0x0c); |
| 2932 | + } |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2933 | + } else { |
developer | 23c2234 | 2023-01-09 13:57:39 +0800 | [diff] [blame] | 2934 | + if (mtk_wed_device_active(wed) && rx_ring_layout[idx].flags) { |
| 2935 | + struct mt76_queue *q = &dev->mt76.q_rx[MT_RXQ_MAIN_WA]; |
| 2936 | + |
| 2937 | + if (is_mt7915(&dev->mt76)) |
| 2938 | + q = &dev->mt76.q_rx[MT_RXQ_MCU_WA]; |
| 2939 | + |
| 2940 | + rbase[idx] = mtk_wed_device_reg_read(wed, q->wed_regs); |
| 2941 | + rcnt[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x04); |
| 2942 | + rcidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x08); |
| 2943 | + rdidx[idx] = mtk_wed_device_reg_read(wed, q->wed_regs + 0x0c); |
| 2944 | + |
| 2945 | + } else { |
| 2946 | + rbase[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2)); |
| 2947 | + rcnt[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x04); |
| 2948 | + rcidx[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x08); |
| 2949 | + rdidx[idx] = mt76_rr(dev, MT_DBG_RX_EVENT_RING_CTRL(idx - 2) + 0x0c); |
| 2950 | + } |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 2951 | + } |
| 2952 | + } |
| 2953 | + |
| 2954 | + seq_printf(s, "=================================================\n"); |
| 2955 | + seq_printf(s, "TxRing Configuration\n"); |
| 2956 | + seq_printf(s, "%4s %10s %8s %1s %6s %6s %6s %6s\n", |
| 2957 | + "Idx", "Attr", "Reg", "Base", "Cnt", "CIDX", "DIDX", |
| 2958 | + "QCnt"); |
| 2959 | + for (idx = 0; idx < tx_ring_num; idx++) { |
| 2960 | + u32 queue_cnt; |
| 2961 | + |
| 2962 | + queue_cnt = (tcidx[idx] >= tdidx[idx]) ? |
| 2963 | + (tcidx[idx] - tdidx[idx]) : |
| 2964 | + (tcidx[idx] - tdidx[idx] + tcnt[idx]); |
| 2965 | + seq_printf(s, "%4d %8s %8x %10x %6x %6x %6x %6x\n", |
| 2966 | + idx, tx_ring_layout[idx].ring_info, |
| 2967 | + MT_DBG_TX_RING_CTRL(idx), tbase[idx], |
| 2968 | + tcnt[idx], tcidx[idx], tdidx[idx], queue_cnt); |
| 2969 | + } |
| 2970 | + |
| 2971 | + seq_printf(s, "RxRing Configuration\n"); |
| 2972 | + seq_printf(s, "%4s %10s %8s %10s %6s %6s %6s %6s\n", |
| 2973 | + "Idx", "Attr", "Reg", "Base", "Cnt", "CIDX", "DIDX", |
| 2974 | + "QCnt"); |
| 2975 | + |
| 2976 | + for (idx = 0; idx < rx_ring_num; idx++) { |
| 2977 | + u32 queue_cnt; |
| 2978 | + |
| 2979 | + queue_cnt = (rdidx[idx] > rcidx[idx]) ? |
| 2980 | + (rdidx[idx] - rcidx[idx] - 1) : |
| 2981 | + (rdidx[idx] - rcidx[idx] + rcnt[idx] - 1); |
| 2982 | + seq_printf(s, "%4d %8s %8x %10x %6x %6x %6x %6x\n", |
| 2983 | + idx, rx_ring_layout[idx].ring_info, |
| 2984 | + (idx < 2) ? MT_DBG_RX_DATA_RING_CTRL(idx): MT_DBG_RX_EVENT_RING_CTRL(idx - 2), |
| 2985 | + rbase[idx], rcnt[idx], rcidx[idx], rdidx[idx], queue_cnt); |
| 2986 | + } |
| 2987 | + |
| 2988 | + mt7915_show_dma_info(s, dev); |
| 2989 | + return 0; |
| 2990 | +} |
| 2991 | + |
| 2992 | +static int mt7915_drr_info(struct seq_file *s, void *data) |
| 2993 | +{ |
| 2994 | +#define DL_AC_START 0x00 |
| 2995 | +#define DL_AC_END 0x0F |
| 2996 | +#define UL_AC_START 0x10 |
| 2997 | +#define UL_AC_END 0x1F |
| 2998 | + |
| 2999 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 3000 | + u32 drr_sta_status[16]; |
| 3001 | + u32 drr_ctrl_def_val = 0x80220000, drr_ctrl_val = 0; |
| 3002 | + bool is_show = false; |
| 3003 | + int idx, sta_line = 0, sta_no = 0, max_sta_line = (mt7915_wtbl_size(dev) + 31) / 32; |
| 3004 | + seq_printf(s, "DRR Table STA Info:\n"); |
| 3005 | + |
| 3006 | + for (idx = DL_AC_START; idx <= DL_AC_END; idx++) { |
| 3007 | + is_show = true; |
| 3008 | + drr_ctrl_val = (drr_ctrl_def_val | idx); |
| 3009 | + mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val); |
| 3010 | + drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0); |
| 3011 | + drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1); |
| 3012 | + drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2); |
| 3013 | + drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3); |
| 3014 | + drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4); |
| 3015 | + drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5); |
| 3016 | + drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6); |
| 3017 | + drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7); |
| 3018 | + |
| 3019 | + if (is_mt7915(&dev->mt76) && max_sta_line > 8) { |
| 3020 | + drr_ctrl_val = (drr_ctrl_def_val | idx | 1 << 10); |
| 3021 | + mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val); |
| 3022 | + drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0); |
| 3023 | + drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1); |
| 3024 | + drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2); |
| 3025 | + drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3); |
| 3026 | + drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4); |
| 3027 | + drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5); |
| 3028 | + drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6); |
| 3029 | + drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7); |
| 3030 | + } |
| 3031 | + if (!is_mt7915(&dev->mt76)) |
| 3032 | + max_sta_line = 8; |
| 3033 | + |
| 3034 | + for (sta_line = 0; sta_line < max_sta_line; sta_line++) { |
| 3035 | + if (drr_sta_status[sta_line] > 0) { |
| 3036 | + for (sta_no = 0; sta_no < 32; sta_no++) { |
| 3037 | + if (((drr_sta_status[sta_line] & (0x1 << sta_no)) >> sta_no)) { |
| 3038 | + if (is_show) { |
| 3039 | + seq_printf(s, "\n DL AC%02d Queue Non-Empty STA:\n", idx); |
| 3040 | + is_show = false; |
| 3041 | + } |
| 3042 | + seq_printf(s, "%d ", sta_no + (sta_line * 32)); |
| 3043 | + } |
| 3044 | + } |
| 3045 | + } |
| 3046 | + } |
| 3047 | + } |
| 3048 | + |
| 3049 | + for (idx = UL_AC_START; idx <= UL_AC_END; idx++) { |
| 3050 | + is_show = true; |
| 3051 | + drr_ctrl_val = (drr_ctrl_def_val | idx); |
| 3052 | + mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val); |
| 3053 | + drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0); |
| 3054 | + drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1); |
| 3055 | + drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2); |
| 3056 | + drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3); |
| 3057 | + drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4); |
| 3058 | + drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5); |
| 3059 | + drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6); |
| 3060 | + drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7); |
| 3061 | + |
| 3062 | + if (is_mt7915(&dev->mt76) && max_sta_line > 8) { |
| 3063 | + drr_ctrl_val = (drr_ctrl_def_val | idx | 1 << 10); |
| 3064 | + mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val); |
| 3065 | + drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0); |
| 3066 | + drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1); |
| 3067 | + drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2); |
| 3068 | + drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3); |
| 3069 | + drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4); |
| 3070 | + drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5); |
| 3071 | + drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6); |
| 3072 | + drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7); |
| 3073 | + } |
| 3074 | + |
| 3075 | + if (!is_mt7915(&dev->mt76)) |
| 3076 | + max_sta_line = 8; |
| 3077 | + |
| 3078 | + for (sta_line = 0; sta_line < max_sta_line; sta_line++) { |
| 3079 | + if (drr_sta_status[sta_line] > 0) { |
| 3080 | + for (sta_no = 0; sta_no < 32; sta_no++) { |
| 3081 | + if (((drr_sta_status[sta_line] & (0x1 << sta_no)) >> sta_no)) { |
| 3082 | + if (is_show) { |
| 3083 | + seq_printf(s, "\n UL AC%02d Queue Non-Empty STA:\n", idx); |
| 3084 | + is_show = false; |
| 3085 | + } |
| 3086 | + seq_printf(s, "%d ", sta_no + (sta_line * 32)); |
| 3087 | + } |
| 3088 | + } |
| 3089 | + } |
| 3090 | + } |
| 3091 | + } |
| 3092 | + |
| 3093 | + for (idx = DL_AC_START; idx <= DL_AC_END; idx++) { |
| 3094 | + drr_ctrl_def_val = 0x80420000; |
| 3095 | + drr_ctrl_val = (drr_ctrl_def_val | idx); |
| 3096 | + mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val); |
| 3097 | + drr_sta_status[0] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0); |
| 3098 | + drr_sta_status[1] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1); |
| 3099 | + drr_sta_status[2] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2); |
| 3100 | + drr_sta_status[3] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3); |
| 3101 | + drr_sta_status[4] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4); |
| 3102 | + drr_sta_status[5] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5); |
| 3103 | + drr_sta_status[6] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6); |
| 3104 | + drr_sta_status[7] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7); |
| 3105 | + |
| 3106 | + if (is_mt7915(&dev->mt76) && max_sta_line > 8) { |
| 3107 | + drr_ctrl_val = (drr_ctrl_def_val | idx | 1<<10); |
| 3108 | + mt76_wr(dev, MT_DBG_PLE_DRR_TAB_CTRL, drr_ctrl_val); |
| 3109 | + drr_sta_status[8] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA0); |
| 3110 | + drr_sta_status[9] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA1); |
| 3111 | + drr_sta_status[10] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA2); |
| 3112 | + drr_sta_status[11] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA3); |
| 3113 | + drr_sta_status[12] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA4); |
| 3114 | + drr_sta_status[13] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA5); |
| 3115 | + drr_sta_status[14] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA6); |
| 3116 | + drr_sta_status[15] = mt76_rr(dev, MT_DBG_PLE_DRR_TABLE_RDATA7); |
| 3117 | + } |
| 3118 | + |
| 3119 | + seq_printf(s, "\nBSSGrp[%d]:\n", idx); |
| 3120 | + if (!is_mt7915(&dev->mt76)) |
| 3121 | + max_sta_line = 8; |
| 3122 | + |
| 3123 | + for (sta_line = 0; sta_line < max_sta_line; sta_line++) { |
| 3124 | + seq_printf(s, "0x%08x ", drr_sta_status[sta_line]); |
| 3125 | + |
| 3126 | + if ((sta_line % 4) == 3) |
| 3127 | + seq_printf(s, "\n"); |
| 3128 | + } |
| 3129 | + } |
| 3130 | + |
| 3131 | + return 0; |
| 3132 | +} |
| 3133 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3134 | +#define CR_NUM_OF_AC 17 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3135 | + |
| 3136 | +typedef enum _ENUM_UMAC_PORT_T { |
| 3137 | + ENUM_UMAC_HIF_PORT_0 = 0, |
| 3138 | + ENUM_UMAC_CPU_PORT_1 = 1, |
| 3139 | + ENUM_UMAC_LMAC_PORT_2 = 2, |
| 3140 | + ENUM_PLE_CTRL_PSE_PORT_3 = 3, |
| 3141 | + ENUM_UMAC_PSE_PLE_PORT_TOTAL_NUM = 4 |
| 3142 | +} ENUM_UMAC_PORT_T, *P_ENUM_UMAC_PORT_T; |
| 3143 | + |
| 3144 | +/* N9 MCU QUEUE LIST */ |
| 3145 | +typedef enum _ENUM_UMAC_CPU_P_QUEUE_T { |
| 3146 | + ENUM_UMAC_CTX_Q_0 = 0, |
| 3147 | + ENUM_UMAC_CTX_Q_1 = 1, |
| 3148 | + ENUM_UMAC_CTX_Q_2 = 2, |
| 3149 | + ENUM_UMAC_CTX_Q_3 = 3, |
| 3150 | + ENUM_UMAC_CRX = 0, |
| 3151 | + ENUM_UMAC_CIF_QUEUE_TOTAL_NUM = 4 |
| 3152 | +} ENUM_UMAC_CPU_P_QUEUE_T, *P_ENUM_UMAC_CPU_P_QUEUE_T; |
| 3153 | + |
| 3154 | +/* LMAC PLE TX QUEUE LIST */ |
| 3155 | +typedef enum _ENUM_UMAC_LMAC_PLE_TX_P_QUEUE_T { |
| 3156 | + ENUM_UMAC_LMAC_PLE_TX_Q_00 = 0x00, |
| 3157 | + ENUM_UMAC_LMAC_PLE_TX_Q_01 = 0x01, |
| 3158 | + ENUM_UMAC_LMAC_PLE_TX_Q_02 = 0x02, |
| 3159 | + ENUM_UMAC_LMAC_PLE_TX_Q_03 = 0x03, |
| 3160 | + |
| 3161 | + ENUM_UMAC_LMAC_PLE_TX_Q_10 = 0x04, |
| 3162 | + ENUM_UMAC_LMAC_PLE_TX_Q_11 = 0x05, |
| 3163 | + ENUM_UMAC_LMAC_PLE_TX_Q_12 = 0x06, |
| 3164 | + ENUM_UMAC_LMAC_PLE_TX_Q_13 = 0x07, |
| 3165 | + |
| 3166 | + ENUM_UMAC_LMAC_PLE_TX_Q_20 = 0x08, |
| 3167 | + ENUM_UMAC_LMAC_PLE_TX_Q_21 = 0x09, |
| 3168 | + ENUM_UMAC_LMAC_PLE_TX_Q_22 = 0x0a, |
| 3169 | + ENUM_UMAC_LMAC_PLE_TX_Q_23 = 0x0b, |
| 3170 | + |
| 3171 | + ENUM_UMAC_LMAC_PLE_TX_Q_30 = 0x0c, |
| 3172 | + ENUM_UMAC_LMAC_PLE_TX_Q_31 = 0x0d, |
| 3173 | + ENUM_UMAC_LMAC_PLE_TX_Q_32 = 0x0e, |
| 3174 | + ENUM_UMAC_LMAC_PLE_TX_Q_33 = 0x0f, |
| 3175 | + |
| 3176 | + ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 = 0x10, |
| 3177 | + ENUM_UMAC_LMAC_PLE_TX_Q_BMC_0 = 0x11, |
| 3178 | + ENUM_UMAC_LMAC_PLE_TX_Q_BNC_0 = 0x12, |
| 3179 | + ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0 = 0x13, |
| 3180 | + |
| 3181 | + ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 = 0x14, |
| 3182 | + ENUM_UMAC_LMAC_PLE_TX_Q_BMC_1 = 0x15, |
| 3183 | + ENUM_UMAC_LMAC_PLE_TX_Q_BNC_1 = 0x16, |
| 3184 | + ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1 = 0x17, |
| 3185 | + ENUM_UMAC_LMAC_PLE_TX_Q_NAF = 0x18, |
| 3186 | + ENUM_UMAC_LMAC_PLE_TX_Q_NBCN = 0x19, |
| 3187 | + ENUM_UMAC_LMAC_PLE_TX_Q_RELEASE = 0x1f, /* DE suggests not to use 0x1f, it's only for hw free queue */ |
| 3188 | + ENUM_UMAC_LMAC_QUEUE_TOTAL_NUM = 24, |
| 3189 | + |
| 3190 | +} ENUM_UMAC_LMAC_TX_P_QUEUE_T, *P_ENUM_UMAC_LMAC_TX_P_QUEUE_T; |
| 3191 | + |
| 3192 | +typedef struct _EMPTY_QUEUE_INFO_T { |
| 3193 | + char *QueueName; |
| 3194 | + u32 Portid; |
| 3195 | + u32 Queueid; |
| 3196 | +} EMPTY_QUEUE_INFO_T, *P_EMPTY_QUEUE_INFO_T; |
| 3197 | + |
| 3198 | +static EMPTY_QUEUE_INFO_T ple_queue_empty_info[] = { |
| 3199 | + {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0}, |
| 3200 | + {"CPU Q1", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_1}, |
| 3201 | + {"CPU Q2", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_2}, |
| 3202 | + {"CPU Q3", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_3}, |
| 3203 | + {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 4~7 not defined */ |
| 3204 | + {"ALTX Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0}, /* Q16 */ |
| 3205 | + {"BMC Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BMC_0}, |
| 3206 | + {"BCN Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BNC_0}, |
| 3207 | + {"PSMP Q0", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0}, |
| 3208 | + {"ALTX Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1}, |
| 3209 | + {"BMC Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BMC_1}, |
| 3210 | + {"BCN Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_BNC_1}, |
| 3211 | + {"PSMP Q1", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1}, |
| 3212 | + {"NAF Q", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_NAF}, |
| 3213 | + {"NBCN Q", ENUM_UMAC_LMAC_PORT_2, ENUM_UMAC_LMAC_PLE_TX_Q_NBCN}, |
| 3214 | + {NULL, 0, 0}, {NULL, 0, 0}, /* 18, 19 not defined */ |
| 3215 | + {"FIXFID Q", ENUM_UMAC_LMAC_PORT_2, 0x1a}, |
| 3216 | + {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, |
| 3217 | + {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 21~29 not defined */ |
| 3218 | + {"RLS Q", ENUM_PLE_CTRL_PSE_PORT_3, 0x7e}, |
| 3219 | + {"RLS2 Q", ENUM_PLE_CTRL_PSE_PORT_3, 0x7f} |
| 3220 | +}; |
| 3221 | + |
| 3222 | +static EMPTY_QUEUE_INFO_T ple_txcmd_queue_empty_info[] = { |
| 3223 | + {"AC00Q", ENUM_UMAC_LMAC_PORT_2, 0x40}, |
| 3224 | + {"AC01Q", ENUM_UMAC_LMAC_PORT_2, 0x41}, |
| 3225 | + {"AC02Q", ENUM_UMAC_LMAC_PORT_2, 0x42}, |
| 3226 | + {"AC03Q", ENUM_UMAC_LMAC_PORT_2, 0x43}, |
| 3227 | + {"AC10Q", ENUM_UMAC_LMAC_PORT_2, 0x44}, |
| 3228 | + {"AC11Q", ENUM_UMAC_LMAC_PORT_2, 0x45}, |
| 3229 | + {"AC12Q", ENUM_UMAC_LMAC_PORT_2, 0x46}, |
| 3230 | + {"AC13Q", ENUM_UMAC_LMAC_PORT_2, 0x47}, |
| 3231 | + {"AC20Q", ENUM_UMAC_LMAC_PORT_2, 0x48}, |
| 3232 | + {"AC21Q", ENUM_UMAC_LMAC_PORT_2, 0x49}, |
| 3233 | + {"AC22Q", ENUM_UMAC_LMAC_PORT_2, 0x4a}, |
| 3234 | + {"AC23Q", ENUM_UMAC_LMAC_PORT_2, 0x4b}, |
| 3235 | + {"AC30Q", ENUM_UMAC_LMAC_PORT_2, 0x4c}, |
| 3236 | + {"AC31Q", ENUM_UMAC_LMAC_PORT_2, 0x4d}, |
| 3237 | + {"AC32Q", ENUM_UMAC_LMAC_PORT_2, 0x4e}, |
| 3238 | + {"AC33Q", ENUM_UMAC_LMAC_PORT_2, 0x4f}, |
| 3239 | + {"ALTX Q0", ENUM_UMAC_LMAC_PORT_2, 0x50}, |
| 3240 | + {"TF Q0", ENUM_UMAC_LMAC_PORT_2, 0x51}, |
| 3241 | + {"TWT TSF-TF Q0", ENUM_UMAC_LMAC_PORT_2, 0x52}, |
| 3242 | + {"TWT DL Q0", ENUM_UMAC_LMAC_PORT_2, 0x53}, |
| 3243 | + {"TWT UL Q0", ENUM_UMAC_LMAC_PORT_2, 0x54}, |
| 3244 | + {"ALTX Q1", ENUM_UMAC_LMAC_PORT_2, 0x55}, |
| 3245 | + {"TF Q1", ENUM_UMAC_LMAC_PORT_2, 0x56}, |
| 3246 | + {"TWT TSF-TF Q1", ENUM_UMAC_LMAC_PORT_2, 0x57}, |
| 3247 | + {"TWT DL Q1", ENUM_UMAC_LMAC_PORT_2, 0x58}, |
| 3248 | + {"TWT UL Q1", ENUM_UMAC_LMAC_PORT_2, 0x59}, |
| 3249 | + {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, |
| 3250 | +}; |
| 3251 | + |
| 3252 | + |
| 3253 | + |
| 3254 | +static char* sta_ctrl_reg[] = {"ENABLE", "DISABLE", "PAUSE"}; |
| 3255 | +static u32 chip_show_sta_acq_info(struct seq_file *s, struct mt7915_dev *dev, u32 *ple_stat, |
| 3256 | + u32 *sta_pause, u32 *dis_sta_map, |
| 3257 | + u32 dumptxd) |
| 3258 | +{ |
| 3259 | + int i, j; |
| 3260 | + u32 total_nonempty_cnt = 0; |
| 3261 | + u32 ac_num = 9, all_ac_num; |
| 3262 | + |
| 3263 | + /* TDO: ac_num = 16 for mt7986 */ |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3264 | + if (!is_mt7915(&dev->mt76)) |
| 3265 | + ac_num = 17; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3266 | + |
| 3267 | + all_ac_num = ac_num * 4; |
| 3268 | + |
| 3269 | + for (j = 0; j < all_ac_num; j++) { /* show AC Q info */ |
| 3270 | + for (i = 0; i < 32; i++) { |
| 3271 | + if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) { |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3272 | + u32 hfid, tfid, pktcnt, ac_n = j / ac_num, ctrl = 0; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3273 | + u32 sta_num = i + (j % ac_num) * 32, fl_que_ctrl[3] = {0}; |
| 3274 | + //struct wifi_dev *wdev = wdev_search_by_wcid(pAd, sta_num); |
| 3275 | + u32 wmmidx = 0; |
| 3276 | + struct mt7915_sta *msta; |
| 3277 | + struct mt76_wcid *wcid; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3278 | + |
| 3279 | + wcid = rcu_dereference(dev->mt76.wcid[sta_num]); |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 3280 | + if (!wcid) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3281 | + printk("ERROR!! no found STA wcid=%d\n", sta_num); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3282 | + continue; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3283 | + } |
| 3284 | + msta = container_of(wcid, struct mt7915_sta, wcid); |
| 3285 | + wmmidx = msta->vif->mt76.wmm_idx; |
| 3286 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3287 | + seq_printf(s, "\tSTA%d AC%d: ", sta_num, ac_n); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3288 | + |
| 3289 | + fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK; |
| 3290 | + fl_que_ctrl[0] |= (ENUM_UMAC_LMAC_PORT_2 << MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3291 | + fl_que_ctrl[0] |= (ac_n << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3292 | + fl_que_ctrl[0] |= sta_num; |
| 3293 | + mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]); |
| 3294 | + fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2); |
| 3295 | + fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3); |
| 3296 | + hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]); |
| 3297 | + tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]); |
| 3298 | + pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]); |
| 3299 | + seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x", |
| 3300 | + tfid, hfid, pktcnt); |
| 3301 | + |
| 3302 | + if (((sta_pause[j % 6] & 0x1 << i) >> i) == 1) |
| 3303 | + ctrl = 2; |
| 3304 | + |
| 3305 | + if (((dis_sta_map[j % 6] & 0x1 << i) >> i) == 1) |
| 3306 | + ctrl = 1; |
| 3307 | + |
| 3308 | + seq_printf(s, " ctrl = %s", sta_ctrl_reg[ctrl]); |
| 3309 | + seq_printf(s, " (wmmidx=%d)\n", wmmidx); |
| 3310 | + |
| 3311 | + total_nonempty_cnt++; |
| 3312 | + |
| 3313 | + // TODO |
| 3314 | + //if (pktcnt > 0 && dumptxd > 0) |
| 3315 | + // ShowTXDInfo(pAd, hfid); |
| 3316 | + } |
| 3317 | + } |
| 3318 | + } |
| 3319 | + |
| 3320 | + return total_nonempty_cnt; |
| 3321 | +} |
| 3322 | + |
| 3323 | +static void chip_show_txcmdq_info(struct seq_file *s, struct mt7915_dev *dev, u32 ple_txcmd_stat) |
| 3324 | +{ |
| 3325 | + int i; |
| 3326 | + |
| 3327 | + seq_printf(s, "Nonempty TXCMD Q info:\n"); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3328 | + for (i = 0; i < 32; i++) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3329 | + if (((ple_txcmd_stat & (0x1 << i)) >> i) == 0) { |
| 3330 | + u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0}; |
| 3331 | + |
| 3332 | + if (ple_txcmd_queue_empty_info[i].QueueName != NULL) { |
| 3333 | + seq_printf(s, "\t%s: ", ple_txcmd_queue_empty_info[i].QueueName); |
| 3334 | + fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK; |
| 3335 | + fl_que_ctrl[0] |= (ple_txcmd_queue_empty_info[i].Portid << |
| 3336 | + MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT); |
| 3337 | + fl_que_ctrl[0] |= (ple_txcmd_queue_empty_info[i].Queueid << |
| 3338 | + MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT); |
| 3339 | + } else |
| 3340 | + continue; |
| 3341 | + |
| 3342 | + mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]); |
| 3343 | + fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2); |
| 3344 | + fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3); |
| 3345 | + hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]); |
| 3346 | + tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]); |
| 3347 | + pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]); |
| 3348 | + seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n", |
| 3349 | + tfid, hfid, pktcnt); |
| 3350 | + } |
| 3351 | + } |
| 3352 | +} |
| 3353 | + |
| 3354 | +static void chip_get_ple_acq_stat(struct mt7915_dev *dev, u32 *ple_stat) |
| 3355 | +{ |
| 3356 | + int i; |
| 3357 | + int cr_num = 9, all_cr_num; |
| 3358 | + u32 ac , index; |
| 3359 | + |
| 3360 | + /* TDO: cr_num = 16 for mt7986 */ |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3361 | + if(!is_mt7915(&dev->mt76)) |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3362 | + cr_num = 17; |
| 3363 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3364 | + all_cr_num = cr_num * 4; |
| 3365 | + |
| 3366 | + ple_stat[0] = mt76_rr(dev, MT_DBG_PLE_QUEUE_EMPTY); |
| 3367 | + |
| 3368 | + for(i = 0; i < all_cr_num; i++) { |
| 3369 | + ac = i / cr_num; |
| 3370 | + index = i % cr_num; |
| 3371 | + ple_stat[i + 1] = |
| 3372 | + mt76_rr(dev, MT_DBG_PLE_AC_QEMPTY(ac, index)); |
| 3373 | + |
| 3374 | + } |
| 3375 | +} |
| 3376 | + |
| 3377 | +static void chip_get_dis_sta_map(struct mt7915_dev *dev, u32 *dis_sta_map) |
| 3378 | +{ |
| 3379 | + int i; |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3380 | + u32 ac_num = 9; |
| 3381 | + |
| 3382 | + /* TDO: ac_num = 16 for mt7986 */ |
| 3383 | + if (!is_mt7915(&dev->mt76)) |
| 3384 | + ac_num = 17; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3385 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3386 | + for(i = 0; i < ac_num; i++) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3387 | + dis_sta_map[i] = mt76_rr(dev, MT_DBG_PLE_DIS_STA_MAP(i)); |
| 3388 | + } |
| 3389 | +} |
| 3390 | + |
| 3391 | +static void chip_get_sta_pause(struct mt7915_dev *dev, u32 *sta_pause) |
| 3392 | +{ |
| 3393 | + int i; |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3394 | + u32 ac_num = 9; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3395 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3396 | + /* TDO: ac_num = 16 for mt7986 */ |
| 3397 | + if (!is_mt7915(&dev->mt76)) |
| 3398 | + ac_num = 17; |
| 3399 | + |
| 3400 | + for(i = 0; i < ac_num; i++) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3401 | + sta_pause[i] = mt76_rr(dev, MT_DBG_PLE_STATION_PAUSE(i)); |
| 3402 | + } |
| 3403 | +} |
| 3404 | + |
| 3405 | +static int mt7915_pleinfo_read(struct seq_file *s, void *data) |
| 3406 | +{ |
| 3407 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 3408 | + u32 ple_buf_ctrl, pg_sz, pg_num; |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3409 | + u32 ple_stat[70] = {0}, pg_flow_ctrl[8] = {0}; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3410 | + u32 ple_native_txcmd_stat; |
| 3411 | + u32 ple_txcmd_stat; |
| 3412 | + u32 sta_pause[CR_NUM_OF_AC] = {0}, dis_sta_map[CR_NUM_OF_AC] = {0}; |
| 3413 | + u32 fpg_cnt, ffa_cnt, fpg_head, fpg_tail, hif_max_q, hif_min_q; |
| 3414 | + u32 rpg_hif, upg_hif, cpu_max_q, cpu_min_q, rpg_cpu, upg_cpu; |
| 3415 | + int i, j; |
| 3416 | + u32 ac_num = 9, all_ac_num; |
| 3417 | + |
| 3418 | + /* TDO: ac_num = 16 for mt7986 */ |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3419 | + if (!is_mt7915(&dev->mt76)) |
| 3420 | + ac_num = 17; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3421 | + |
| 3422 | + all_ac_num = ac_num * 4; |
| 3423 | + |
| 3424 | + ple_buf_ctrl = mt76_rr(dev, MT_DBG_PLE_PBUF_CTRL_ADDR); |
| 3425 | + chip_get_ple_acq_stat(dev, ple_stat); |
| 3426 | + ple_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_TXCMD_Q_EMPTY); |
| 3427 | + ple_native_txcmd_stat = mt76_rr(dev, MT_DBG_PLE_NATIVE_TXCMD_Q_EMPTY); |
| 3428 | + pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PLE_FREEPG_CNT); |
| 3429 | + pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FREEPG_HEAD_TAIL); |
| 3430 | + pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_GROUP); |
| 3431 | + pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PLE_HIF_PG_INFO); |
| 3432 | + pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PLE_PG_CPU_GROUP); |
| 3433 | + pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PLE_CPU_PG_INFO); |
| 3434 | + pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PLE_PG_HIF_TXCMD_GROUP); |
| 3435 | + pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PLE_HIF_TXCMD_PG_INFO); |
| 3436 | + chip_get_dis_sta_map(dev, dis_sta_map); |
| 3437 | + chip_get_sta_pause(dev, sta_pause); |
| 3438 | + |
| 3439 | + seq_printf(s, "PLE Configuration Info:\n"); |
| 3440 | + seq_printf(s, "\tPacket Buffer Control(0x%x): 0x%08x\n", |
| 3441 | + MT_DBG_PLE_PBUF_CTRL_ADDR, ple_buf_ctrl); |
| 3442 | + |
| 3443 | + pg_sz = FIELD_GET(MT_DBG_PLE_PBUF_CTRL_PAGE_SIZE_MASK, ple_buf_ctrl); |
| 3444 | + seq_printf(s, "\t\tPage Size=%d(%d bytes per page)\n", |
| 3445 | + pg_sz, (pg_sz == 1 ? 128 : 64)); |
| 3446 | + seq_printf(s, "\t\tPage Offset=%ld(in unit of 2KB)\n", |
| 3447 | + FIELD_GET(MT_DBG_PLE_PBUF_CTRL_OFFSET_MASK, ple_buf_ctrl)); |
| 3448 | + |
| 3449 | + pg_num = FIELD_GET(MT_DBG_PLE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK, ple_buf_ctrl); |
| 3450 | + seq_printf(s, "\t\tTotal Page=%d pages\n", pg_num); |
| 3451 | + |
| 3452 | + /* Page Flow Control */ |
| 3453 | + seq_printf(s, "PLE Page Flow Control:\n"); |
| 3454 | + seq_printf(s, "\tFree page counter(0x%x): 0x%08x\n", |
| 3455 | + MT_DBG_PLE_FREEPG_CNT, pg_flow_ctrl[0]); |
| 3456 | + fpg_cnt = FIELD_GET(MT_DBG_PLE_FREEPG_CNT_FREEPG_CNT_MASK, pg_flow_ctrl[0]); |
| 3457 | + |
| 3458 | + seq_printf(s, "\t\tThe toal page number of free=0x%03x\n", fpg_cnt); |
| 3459 | + ffa_cnt = FIELD_GET(MT_DBG_PLE_FREEPG_CNT_FFA_CNT_MASK, pg_flow_ctrl[0]); |
| 3460 | + |
| 3461 | + seq_printf(s, "\t\tThe free page numbers of free for all=0x%03x\n", ffa_cnt); |
| 3462 | + seq_printf(s, "\tFree page head and tail(0x%x): 0x%08x\n", |
| 3463 | + MT_DBG_PLE_FREEPG_HEAD_TAIL, pg_flow_ctrl[1]); |
| 3464 | + |
| 3465 | + fpg_head = FIELD_GET(MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK, pg_flow_ctrl[1]); |
| 3466 | + fpg_tail = FIELD_GET(MT_DBG_PLE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK, pg_flow_ctrl[1]); |
| 3467 | + seq_printf(s, "\t\tThe tail/head page of free page list=0x%03x/0x%03x\n", fpg_tail, fpg_head); |
| 3468 | + seq_printf(s, "\tReserved page counter of HIF group(0x%x): 0x%08x\n", |
| 3469 | + MT_DBG_PLE_PG_HIF_GROUP, pg_flow_ctrl[2]); |
| 3470 | + seq_printf(s, "\tHIF group page status(0x%x): 0x%08x\n", |
| 3471 | + MT_DBG_PLE_HIF_PG_INFO, pg_flow_ctrl[3]); |
| 3472 | + |
| 3473 | + hif_min_q = FIELD_GET(MT_DBG_PLE_PG_HIF_GROUP_HIF_MIN_QUOTA_MASK, pg_flow_ctrl[2]); |
| 3474 | + hif_max_q = FIELD_GET(MT_DBG_PLE_PG_HIF_GROUP_HIF_MAX_QUOTA_MASK, pg_flow_ctrl[2]); |
| 3475 | + seq_printf(s, "\t\tThe max/min quota pages of HIF group=0x%03x/0x%03x\n", hif_max_q, hif_min_q); |
| 3476 | + |
| 3477 | + rpg_hif = FIELD_GET(MT_DBG_PLE_HIF_PG_INFO_HIF_RSV_CNT_MASK, pg_flow_ctrl[3]); |
| 3478 | + upg_hif = FIELD_GET(MT_DBG_PLE_HIF_PG_INFO_HIF_SRC_CNT_MASK, pg_flow_ctrl[3]); |
| 3479 | + seq_printf(s, "\t\tThe used/reserved pages of HIF group=0x%03x/0x%03x\n", upg_hif, rpg_hif); |
| 3480 | + |
| 3481 | + seq_printf(s, "\tReserved page counter of HIF_TXCMD group(0x%x): 0x%08x\n", |
| 3482 | + MT_DBG_PLE_PG_HIF_TXCMD_GROUP, pg_flow_ctrl[6]); |
| 3483 | + seq_printf(s, "\tHIF_TXCMD group page status(0x%x): 0x%08x\n", |
| 3484 | + MT_DBG_PLE_HIF_TXCMD_PG_INFO, pg_flow_ctrl[7]); |
| 3485 | + cpu_min_q = FIELD_GET(MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MIN_QUOTA_MASK, pg_flow_ctrl[6]); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3486 | + cpu_max_q = FIELD_GET(MT_DBG_PLE_PG_HIF_TXCMD_GROUP_HIF_TXCMD_MAX_QUOTA_MASK, pg_flow_ctrl[6]); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3487 | + seq_printf(s, "\t\tThe max/min quota pages of HIF_TXCMD group=0x%03x/0x%03x\n", cpu_max_q, cpu_min_q); |
| 3488 | + |
| 3489 | + rpg_cpu = FIELD_GET(MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_RSV_CNT_MASK, pg_flow_ctrl[7]); |
| 3490 | + upg_cpu = FIELD_GET(MT_DBG_PLE_TXCMD_PG_INFO_HIF_TXCMD_SRC_CNT_MASK, pg_flow_ctrl[7]); |
| 3491 | + seq_printf(s, "\t\tThe used/reserved pages of HIF_TXCMD group=0x%03x/0x%03x\n", upg_cpu, rpg_cpu); |
| 3492 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3493 | + seq_printf(s, "\tReserved page counter of CPU group(0x%x): 0x%08x\n", |
| 3494 | + MT_DBG_PLE_PG_CPU_GROUP, pg_flow_ctrl[4]); |
| 3495 | + seq_printf(s, "\tCPU group page status(0x%x): 0x%08x\n", |
| 3496 | + MT_DBG_PLE_CPU_PG_INFO, pg_flow_ctrl[5]); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3497 | + cpu_min_q = FIELD_GET(MT_DBG_PLE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK, pg_flow_ctrl[4]); |
| 3498 | + cpu_max_q = FIELD_GET(MT_DBG_PLE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK, pg_flow_ctrl[4]); |
| 3499 | + seq_printf(s, "\t\tThe max/min quota pages of CPU group=0x%03x/0x%03x\n", cpu_max_q, cpu_min_q); |
| 3500 | + |
| 3501 | + rpg_cpu = FIELD_GET(MT_DBG_PLE_CPU_PG_INFO_CPU_RSV_CNT_MASK, pg_flow_ctrl[5]); |
| 3502 | + upg_cpu = FIELD_GET(MT_DBG_PLE_CPU_PG_INFO_CPU_SRC_CNT_MASK, pg_flow_ctrl[5]); |
| 3503 | + seq_printf(s, "\t\tThe used/reserved pages of CPU group=0x%03x/0x%03x\n", upg_cpu, rpg_cpu); |
| 3504 | + |
| 3505 | + if ((ple_stat[0] & MT_DBG_PLE_Q_EMPTY_ALL_AC_EMPTY_MASK) == 0) { |
| 3506 | + for (j = 0; j < all_ac_num; j++) { |
| 3507 | + if (j % ac_num == 0) { |
| 3508 | + seq_printf(s, "\n\tNonempty AC%d Q of STA#: ", j / ac_num); |
| 3509 | + } |
| 3510 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3511 | + for (i = 0; i < 32; i++) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3512 | + if (((ple_stat[j + 1] & (0x1 << i)) >> i) == 0) { |
| 3513 | + seq_printf(s, "%d ", i + (j % ac_num) * 32); |
| 3514 | + } |
| 3515 | + } |
| 3516 | + } |
| 3517 | + |
| 3518 | + seq_printf(s, "\n"); |
| 3519 | + } |
| 3520 | + |
| 3521 | + seq_printf(s, "non-native/native txcmd queue empty = %d/%d\n", ple_txcmd_stat, ple_native_txcmd_stat); |
| 3522 | + |
| 3523 | + seq_printf(s, "Nonempty Q info:\n"); |
| 3524 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 3525 | + for (i = 0; i < 32; i++) { |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 3526 | + if (((ple_stat[0] & (0x1 << i)) >> i) == 0) { |
| 3527 | + u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0}; |
| 3528 | + |
| 3529 | + if (ple_queue_empty_info[i].QueueName != NULL) { |
| 3530 | + seq_printf(s, "\t%s: ", ple_queue_empty_info[i].QueueName); |
| 3531 | + fl_que_ctrl[0] |= MT_DBG_PLE_FL_QUE_CTRL0_EXECUTE_MASK; |
| 3532 | + fl_que_ctrl[0] |= (ple_queue_empty_info[i].Portid << MT_PLE_FL_QUE_CTRL0_Q_BUF_PID_SHFT); |
| 3533 | + fl_que_ctrl[0] |= (ple_queue_empty_info[i].Queueid << MT_PLE_FL_QUE_CTRL0_Q_BUF_QID_SHFT); |
| 3534 | + } else |
| 3535 | + continue; |
| 3536 | + |
| 3537 | + if (ple_queue_empty_info[i].Queueid >= ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_0 && |
| 3538 | + ple_queue_empty_info[i].Queueid <= ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_0) |
| 3539 | + /* band0 set TGID 0, bit31 = 0 */ |
| 3540 | + mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x0); |
| 3541 | + else if (ple_queue_empty_info[i].Queueid >= ENUM_UMAC_LMAC_PLE_TX_Q_ALTX_1 && |
| 3542 | + ple_queue_empty_info[i].Queueid <= ENUM_UMAC_LMAC_PLE_TX_Q_PSMP_1) |
| 3543 | + /* band1 set TGID 1, bit31 = 1 */ |
| 3544 | + mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL1, 0x80000000); |
| 3545 | + |
| 3546 | + mt76_wr(dev, MT_DBG_PLE_FL_QUE_CTRL0, fl_que_ctrl[0]); |
| 3547 | + fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL2); |
| 3548 | + fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PLE_FL_QUE_CTRL3); |
| 3549 | + hfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_HEAD_FID_MASK, fl_que_ctrl[1]); |
| 3550 | + tfid = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL2_Q_TAIL_FID_MASK, fl_que_ctrl[1]); |
| 3551 | + pktcnt = FIELD_GET(MT_DBG_PLE_FL_QUE_CTRL3_Q_PKT_NUM_MASK, fl_que_ctrl[2]); |
| 3552 | + seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n", |
| 3553 | + tfid, hfid, pktcnt); |
| 3554 | + |
| 3555 | + /* TODO */ |
| 3556 | + //if (pktcnt > 0 && dumptxd > 0) |
| 3557 | + // ShowTXDInfo(pAd, hfid); |
| 3558 | + } |
| 3559 | + } |
| 3560 | + |
| 3561 | + chip_show_sta_acq_info(s, dev, ple_stat, sta_pause, dis_sta_map, 0/*dumptxd*/); |
| 3562 | + chip_show_txcmdq_info(s, dev, ple_native_txcmd_stat); |
| 3563 | + |
| 3564 | + return 0; |
| 3565 | +} |
| 3566 | + |
| 3567 | +typedef enum _ENUM_UMAC_PLE_CTRL_P3_QUEUE_T { |
| 3568 | + ENUM_UMAC_PLE_CTRL_P3_Q_0X1E = 0x1e, |
| 3569 | + ENUM_UMAC_PLE_CTRL_P3_Q_0X1F = 0x1f, |
| 3570 | + ENUM_UMAC_PLE_CTRL_P3_TOTAL_NUM = 2 |
| 3571 | +} ENUM_UMAC_PLE_CTRL_P3_QUEUE_T, *P_ENUM_UMAC_PLE_CTRL_P3_QUEUE_T; |
| 3572 | + |
| 3573 | +static EMPTY_QUEUE_INFO_T pse_queue_empty_info[] = { |
| 3574 | + {"CPU Q0", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_0}, |
| 3575 | + {"CPU Q1", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_1}, |
| 3576 | + {"CPU Q2", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_2}, |
| 3577 | + {"CPU Q3", ENUM_UMAC_CPU_PORT_1, ENUM_UMAC_CTX_Q_3}, |
| 3578 | + {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 4~7 not defined */ |
| 3579 | + {"HIF Q0", ENUM_UMAC_HIF_PORT_0, 0}, /* Q8 */ |
| 3580 | + {"HIF Q1", ENUM_UMAC_HIF_PORT_0, 1}, |
| 3581 | + {"HIF Q2", ENUM_UMAC_HIF_PORT_0, 2}, |
| 3582 | + {"HIF Q3", ENUM_UMAC_HIF_PORT_0, 3}, |
| 3583 | + {"HIF Q4", ENUM_UMAC_HIF_PORT_0, 4}, |
| 3584 | + {"HIF Q5", ENUM_UMAC_HIF_PORT_0, 5}, |
| 3585 | + {NULL, 0, 0}, {NULL, 0, 0}, /* 14~15 not defined */ |
| 3586 | + {"LMAC Q", ENUM_UMAC_LMAC_PORT_2, 0}, |
| 3587 | + {"MDP TX Q", ENUM_UMAC_LMAC_PORT_2, 1}, |
| 3588 | + {"MDP RX Q", ENUM_UMAC_LMAC_PORT_2, 2}, |
| 3589 | + {"SEC TX Q", ENUM_UMAC_LMAC_PORT_2, 3}, |
| 3590 | + {"SEC RX Q", ENUM_UMAC_LMAC_PORT_2, 4}, |
| 3591 | + {"SFD_PARK Q", ENUM_UMAC_LMAC_PORT_2, 5}, |
| 3592 | + {"MDP_TXIOC Q", ENUM_UMAC_LMAC_PORT_2, 6}, |
| 3593 | + {"MDP_RXIOC Q", ENUM_UMAC_LMAC_PORT_2, 7}, |
| 3594 | + {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, {NULL, 0, 0}, /* 24~30 not defined */ |
| 3595 | + {"RLS Q", ENUM_PLE_CTRL_PSE_PORT_3, ENUM_UMAC_PLE_CTRL_P3_Q_0X1F} |
| 3596 | +}; |
| 3597 | + |
| 3598 | +static int mt7915_pseinfo_read(struct seq_file *s, void *data) |
| 3599 | +{ |
| 3600 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 3601 | + u32 pse_buf_ctrl, pg_sz, pg_num; |
| 3602 | + u32 pse_stat, pg_flow_ctrl[22] = {0}; |
| 3603 | + u32 fpg_cnt, ffa_cnt, fpg_head, fpg_tail; |
| 3604 | + u32 max_q, min_q, rsv_pg, used_pg; |
| 3605 | + int i; |
| 3606 | + |
| 3607 | + pse_buf_ctrl = mt76_rr(dev, MT_DBG_PSE_PBUF_CTRL); |
| 3608 | + pse_stat = mt76_rr(dev, MT_DBG_PSE_QUEUE_EMPTY); |
| 3609 | + pg_flow_ctrl[0] = mt76_rr(dev, MT_DBG_PSE_FREEPG_CNT); |
| 3610 | + pg_flow_ctrl[1] = mt76_rr(dev, MT_DBG_PSE_FREEPG_HEAD_TAIL); |
| 3611 | + pg_flow_ctrl[2] = mt76_rr(dev, MT_DBG_PSE_PG_HIF0_GROUP); |
| 3612 | + pg_flow_ctrl[3] = mt76_rr(dev, MT_DBG_PSE_HIF0_PG_INFO); |
| 3613 | + pg_flow_ctrl[4] = mt76_rr(dev, MT_DBG_PSE_PG_HIF1_GROUP); |
| 3614 | + pg_flow_ctrl[5] = mt76_rr(dev, MT_DBG_PSE_HIF1_PG_INFO); |
| 3615 | + pg_flow_ctrl[6] = mt76_rr(dev, MT_DBG_PSE_PG_CPU_GROUP); |
| 3616 | + pg_flow_ctrl[7] = mt76_rr(dev, MT_DBG_PSE_CPU_PG_INFO); |
| 3617 | + pg_flow_ctrl[8] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC0_GROUP); |
| 3618 | + pg_flow_ctrl[9] = mt76_rr(dev, MT_DBG_PSE_LMAC0_PG_INFO); |
| 3619 | + pg_flow_ctrl[10] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC1_GROUP); |
| 3620 | + pg_flow_ctrl[11] = mt76_rr(dev, MT_DBG_PSE_LMAC1_PG_INFO); |
| 3621 | + pg_flow_ctrl[12] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC2_GROUP); |
| 3622 | + pg_flow_ctrl[13] = mt76_rr(dev, MT_DBG_PSE_LMAC2_PG_INFO); |
| 3623 | + pg_flow_ctrl[14] = mt76_rr(dev, MT_DBG_PSE_PG_PLE_GROUP); |
| 3624 | + pg_flow_ctrl[15] = mt76_rr(dev, MT_DBG_PSE_PLE_PG_INFO); |
| 3625 | + pg_flow_ctrl[16] = mt76_rr(dev, MT_DBG_PSE_PG_LMAC3_GROUP); |
| 3626 | + pg_flow_ctrl[17] = mt76_rr(dev, MT_DBG_PSE_LMAC3_PG_INFO); |
| 3627 | + pg_flow_ctrl[18] = mt76_rr(dev, MT_DBG_PSE_PG_MDP_GROUP); |
| 3628 | + pg_flow_ctrl[19] = mt76_rr(dev, MT_DBG_PSE_MDP_PG_INFO); |
| 3629 | + pg_flow_ctrl[20] = mt76_rr(dev, MT_DBG_PSE_PG_PLE1_GROUP); |
| 3630 | + pg_flow_ctrl[21] = mt76_rr(dev,MT_DBG_PSE_PLE1_PG_INFO); |
| 3631 | + |
| 3632 | + /* Configuration Info */ |
| 3633 | + seq_printf(s, "PSE Configuration Info:\n"); |
| 3634 | + seq_printf(s, "\tPacket Buffer Control(0x82068014): 0x%08x\n", pse_buf_ctrl); |
| 3635 | + pg_sz = FIELD_GET(MT_DBG_PSE_PBUF_CTRL_PAGE_SIZE_CFG_MASK, pse_buf_ctrl); |
| 3636 | + |
| 3637 | + seq_printf(s, "\t\tPage Size=%d(%d bytes per page)\n", pg_sz, (pg_sz == 1 ? 256 : 128)); |
| 3638 | + seq_printf(s, "\t\tPage Offset=%ld(in unit of 64KB)\n", |
| 3639 | + FIELD_GET(MT_DBG_PSE_PBUF_CTRL_PBUF_OFFSET_MASK, pse_buf_ctrl)); |
| 3640 | + pg_num = FIELD_GET(MT_DBG_PSE_PBUF_CTRL_TOTAL_PAGE_NUM_MASK, pse_buf_ctrl); |
| 3641 | + |
| 3642 | + seq_printf(s, "\t\tTotal page numbers=%d pages\n", pg_num); |
| 3643 | + |
| 3644 | + /* Page Flow Control */ |
| 3645 | + seq_printf(s, "PSE Page Flow Control:\n"); |
| 3646 | + seq_printf(s, "\tFree page counter(0x82068100): 0x%08x\n", pg_flow_ctrl[0]); |
| 3647 | + fpg_cnt = FIELD_GET(MT_DBG_PSE_FREEPG_CNT_FREEPG_CNT_MASK, pg_flow_ctrl[0]); |
| 3648 | + seq_printf(s, "\t\tThe toal page number of free=0x%03x\n", fpg_cnt); |
| 3649 | + |
| 3650 | + ffa_cnt = FIELD_GET(MT_DBG_PSE_FREEPG_CNT_FFA_CNT_MASK, pg_flow_ctrl[0]); |
| 3651 | + seq_printf(s, "\t\tThe free page numbers of free for all=0x%03x\n", ffa_cnt); |
| 3652 | + |
| 3653 | + seq_printf(s, "\tFree page head and tail(0x82068104): 0x%08x\n", pg_flow_ctrl[1]); |
| 3654 | + fpg_head = FIELD_GET(MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_HEAD_MASK, pg_flow_ctrl[1]); |
| 3655 | + |
| 3656 | + fpg_tail = FIELD_GET(MT_DBG_PSE_FREEPG_HEAD_TAIL_FREEPG_TAIL_MASK, pg_flow_ctrl[1]); |
| 3657 | + seq_printf(s, "\t\tThe tail/head page of free page list=0x%03x/0x%03x\n", fpg_tail, fpg_head); |
| 3658 | + seq_printf(s, "\tReserved page counter of HIF0 group(0x82068110): 0x%08x\n", pg_flow_ctrl[2]); |
| 3659 | + seq_printf(s, "\tHIF0 group page status(0x82068114): 0x%08x\n", pg_flow_ctrl[3]); |
| 3660 | + min_q = FIELD_GET(MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MIN_QUOTA_MASK, pg_flow_ctrl[2]); |
| 3661 | + max_q = FIELD_GET(MT_DBG_PSE_PG_HIF0_GROUP_HIF0_MAX_QUOTA_MASK, pg_flow_ctrl[2]); |
| 3662 | + seq_printf(s, "\t\tThe max/min quota pages of HIF0 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3663 | + rsv_pg = FIELD_GET(MT_DBG_PSE_HIF0_PG_INFO_HIF0_RSV_CNT_MASK, pg_flow_ctrl[3]);; |
| 3664 | + used_pg = FIELD_GET(MT_DBG_PSE_HIF0_PG_INFO_HIF0_SRC_CNT_MASK, pg_flow_ctrl[3]); |
| 3665 | + seq_printf(s, "\t\tThe used/reserved pages of HIF0 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3666 | + seq_printf(s, "\tReserved page counter of HIF1 group(0x82068118): 0x%08x\n", pg_flow_ctrl[4]); |
| 3667 | + seq_printf(s, "\tHIF1 group page status(0x8206811c): 0x%08x\n", pg_flow_ctrl[5]); |
| 3668 | + min_q = FIELD_GET(MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MIN_QUOTA_MASK, pg_flow_ctrl[4]); |
| 3669 | + max_q = FIELD_GET(MT_DBG_PSE_PG_HIF1_GROUP_HIF1_MAX_QUOTA_MASK, pg_flow_ctrl[4]); |
| 3670 | + seq_printf(s, "\t\tThe max/min quota pages of HIF1 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3671 | + rsv_pg = FIELD_GET(MT_DBG_PSE_HIF1_PG_INFO_HIF1_RSV_CNT_MASK, pg_flow_ctrl[5]); |
| 3672 | + used_pg = FIELD_GET(MT_DBG_PSE_HIF1_PG_INFO_HIF1_SRC_CNT_MASK, pg_flow_ctrl[5]); |
| 3673 | + |
| 3674 | + seq_printf(s, "\t\tThe used/reserved pages of HIF1 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3675 | + seq_printf(s, "\tReserved page counter of CPU group(0x82068150): 0x%08x\n", pg_flow_ctrl[6]); |
| 3676 | + seq_printf(s, "\tCPU group page status(0x82068154): 0x%08x\n", pg_flow_ctrl[7]); |
| 3677 | + min_q = FIELD_GET(MT_DBG_PSE_PG_CPU_GROUP_CPU_MIN_QUOTA_MASK, pg_flow_ctrl[6]); |
| 3678 | + max_q = FIELD_GET(MT_DBG_PSE_PG_CPU_GROUP_CPU_MAX_QUOTA_MASK, pg_flow_ctrl[6]); |
| 3679 | + seq_printf(s, "\t\tThe max/min quota pages of CPU group=0x%03x/0x%03x\n", max_q, min_q); |
| 3680 | + rsv_pg = FIELD_GET(MT_DBG_PSE_CPU_PG_INFO_CPU_RSV_CNT_MASK, pg_flow_ctrl[7]); |
| 3681 | + used_pg = FIELD_GET(MT_DBG_PSE_CPU_PG_INFO_CPU_SRC_CNT_MASK, pg_flow_ctrl[7]); |
| 3682 | + seq_printf(s, "\t\tThe used/reserved pages of CPU group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3683 | + seq_printf(s, "\tReserved page counter of LMAC0 group(0x82068170): 0x%08x\n", pg_flow_ctrl[8]); |
| 3684 | + seq_printf(s, "\tLMAC0 group page status(0x82068174): 0x%08x\n", pg_flow_ctrl[9]); |
| 3685 | + min_q = FIELD_GET(MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MIN_QUOTA_MASK, pg_flow_ctrl[8]); |
| 3686 | + max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC0_GROUP_LMAC0_MAX_QUOTA_MASK, pg_flow_ctrl[8]); |
| 3687 | + seq_printf(s, "\t\tThe max/min quota pages of LMAC0 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3688 | + rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_RSV_CNT_MASK, pg_flow_ctrl[9]); |
| 3689 | + used_pg = FIELD_GET(MT_DBG_PSE_LMAC0_PG_INFO_LMAC0_SRC_CNT_MASK, pg_flow_ctrl[9]); |
| 3690 | + seq_printf(s, "\t\tThe used/reserved pages of LMAC0 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3691 | + seq_printf(s, "\tReserved page counter of LMAC1 group(0x82068178): 0x%08x\n", pg_flow_ctrl[10]); |
| 3692 | + seq_printf(s, "\tLMAC1 group page status(0x8206817c): 0x%08x\n", pg_flow_ctrl[11]); |
| 3693 | + min_q = FIELD_GET(MT_DBG_TOP_PG_LMAC1_GROUP_LMAC1_MIN_QUOTA_MASK, pg_flow_ctrl[10]); |
| 3694 | + max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC1_GROUP_LMAC1_MAX_QUOTA_MASK, pg_flow_ctrl[10]); |
| 3695 | + seq_printf(s, "\t\tThe max/min quota pages of LMAC1 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3696 | + rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_RSV_CNT_MASK, pg_flow_ctrl[11]); |
| 3697 | + used_pg = FIELD_GET(MT_DBG_PSE_LMAC1_PG_INFO_LMAC1_SRC_CNT_MASK, pg_flow_ctrl[11]); |
| 3698 | + seq_printf(s, "\t\tThe used/reserved pages of LMAC1 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3699 | + seq_printf(s, "\tReserved page counter of LMAC2 group(0x82068180): 0x%08x\n", pg_flow_ctrl[11]); |
| 3700 | + seq_printf(s, "\tLMAC2 group page status(0x82068184): 0x%08x\n", pg_flow_ctrl[12]); |
| 3701 | + min_q = FIELD_GET(MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MIN_QUOTA_MASK, pg_flow_ctrl[12]); |
| 3702 | + max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC2_GROUP_LMAC2_MAX_QUOTA_MASK, pg_flow_ctrl[12]); |
| 3703 | + seq_printf(s, "\t\tThe max/min quota pages of LMAC2 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3704 | + rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_RSV_CNT_MASK, pg_flow_ctrl[13]); |
| 3705 | + used_pg = FIELD_GET(MT_DBG_PSE_LMAC2_PG_INFO_LMAC2_SRC_CNT_MASK, pg_flow_ctrl[13]); |
| 3706 | + seq_printf(s, "\t\tThe used/reserved pages of LMAC2 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3707 | + |
| 3708 | + seq_printf(s, "\tReserved page counter of LMAC3 group(0x82068188): 0x%08x\n", pg_flow_ctrl[16]); |
| 3709 | + seq_printf(s, "\tLMAC3 group page status(0x8206818c): 0x%08x\n", pg_flow_ctrl[17]); |
| 3710 | + min_q = FIELD_GET(MT_DBG_TOP_PG_LMAC3_GROUP_LMAC3_MIN_QUOTA_MASK, pg_flow_ctrl[16]); |
| 3711 | + max_q = FIELD_GET(MT_DBG_PSE_PG_LMAC3_GROUP_LMAC3_MAX_QUOTA_MASK, pg_flow_ctrl[16]); |
| 3712 | + seq_printf(s, "\t\tThe max/min quota pages of LMAC3 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3713 | + rsv_pg = FIELD_GET(MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_RSV_CNT_MASK, pg_flow_ctrl[17]); |
| 3714 | + used_pg = FIELD_GET(MT_DBG_PSE_LMAC3_PG_INFO_LMAC3_SRC_CNT_MASK, pg_flow_ctrl[17]); |
| 3715 | + seq_printf(s, "\t\tThe used/reserved pages of LMAC3 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3716 | + |
| 3717 | + seq_printf(s, "\tReserved page counter of PLE group(0x82068160): 0x%08x\n", pg_flow_ctrl[14]); |
| 3718 | + seq_printf(s, "\tPLE group page status(0x82068164): 0x%08x\n", pg_flow_ctrl[15]); |
| 3719 | + min_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK, pg_flow_ctrl[14]); |
| 3720 | + max_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK, pg_flow_ctrl[14]); |
| 3721 | + seq_printf(s, "\t\tThe max/min quota pages of PLE group=0x%03x/0x%03x\n", max_q, min_q); |
| 3722 | + rsv_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK, pg_flow_ctrl[15]); |
| 3723 | + used_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK, pg_flow_ctrl[15]); |
| 3724 | + seq_printf(s, "\t\tThe used/reserved pages of PLE group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3725 | + |
| 3726 | + seq_printf(s, "\tReserved page counter of PLE1 group(0x82068168): 0x%08x\n", pg_flow_ctrl[14]); |
| 3727 | + seq_printf(s, "\tPLE1 group page status(0x8206816c): 0x%08x\n", pg_flow_ctrl[15]); |
| 3728 | + min_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MIN_QUOTA_MASK, pg_flow_ctrl[20]); |
| 3729 | + max_q = FIELD_GET(MT_DBG_PSE_PG_PLE_GROUP_PLE_MAX_QUOTA_MASK, pg_flow_ctrl[20]); |
| 3730 | + seq_printf(s, "\t\tThe max/min quota pages of PLE1 group=0x%03x/0x%03x\n", max_q, min_q); |
| 3731 | + rsv_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_RSV_CNT_MASK, pg_flow_ctrl[21]); |
| 3732 | + used_pg = FIELD_GET(MT_DBG_PSE_PLE_PG_INFO_PLE_SRC_CNT_MASK, pg_flow_ctrl[21]); |
| 3733 | + seq_printf(s, "\t\tThe used/reserved pages of PLE1 group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3734 | + |
| 3735 | + seq_printf(s, "\tReserved page counter of MDP group(0x82068198): 0x%08x\n", pg_flow_ctrl[18]); |
| 3736 | + seq_printf(s, "\tMDP group page status(0x8206819c): 0x%08x\n", pg_flow_ctrl[19]); |
| 3737 | + min_q = FIELD_GET(MT_DBG_PSE_PG_MDP_GROUP_MDP_MIN_QUOTA_MASK, pg_flow_ctrl[18]); |
| 3738 | + max_q = FIELD_GET(MT_DBG_PSE_PG_MDP_GROUP_MDP_MAX_QUOTA_MASK, pg_flow_ctrl[18]); |
| 3739 | + seq_printf(s, "\t\tThe max/min quota pages of MDP group=0x%03x/0x%03x\n", max_q, min_q); |
| 3740 | + rsv_pg = FIELD_GET(MT_DBG_PSE_MDP_PG_INFO_MDP_RSV_CNT_MASK, pg_flow_ctrl[19]); |
| 3741 | + used_pg = FIELD_GET(MT_DBG_PSE_MDP_PG_INFO_MDP_SRC_CNT_MASK, pg_flow_ctrl[19]); |
| 3742 | + seq_printf(s, "\t\tThe used/reserved pages of MDP group=0x%03x/0x%03x\n", used_pg, rsv_pg); |
| 3743 | + |
| 3744 | + /* Queue Empty Status */ |
| 3745 | + seq_printf(s, "PSE Queue Empty Status:\n"); |
| 3746 | + seq_printf(s, "\tQUEUE_EMPTY(0x820680b0): 0x%08x\n", pse_stat); |
| 3747 | + seq_printf(s, "\t\tCPU Q0/1/2/3 empty=%ld/%ld/%ld/%ld\n", |
| 3748 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q0_EMPTY_MASK, pse_stat), |
| 3749 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q1_EMPTY_MASK, pse_stat), |
| 3750 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q2_EMPTY_MASK, pse_stat), |
| 3751 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_CPU_Q3_EMPTY_MASK, pse_stat)); |
| 3752 | + |
| 3753 | + seq_printf(s, "\t\tHIF Q0/1/2/3/4/5 empty=%ld/%ld/%ld/%ld/%ld/%ld\n", |
| 3754 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_0_EMPTY_MASK, pse_stat), |
| 3755 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_1_EMPTY_MASK, pse_stat), |
| 3756 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_2_EMPTY_MASK, pse_stat), |
| 3757 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_3_EMPTY_MASK, pse_stat), |
| 3758 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_4_EMPTY_MASK, pse_stat), |
| 3759 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_HIF_5_EMPTY_MASK, pse_stat)); |
| 3760 | + |
| 3761 | + seq_printf(s, "\t\tLMAC TX Q empty=%ld\n", |
| 3762 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_LMAC_TX_QUEUE_EMPTY_MASK, pse_stat)); |
| 3763 | + seq_printf(s, "\t\tMDP TX Q/RX Q empty=%ld/%ld\n", |
| 3764 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_TX_QUEUE_EMPTY_MASK, pse_stat), |
| 3765 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_RX_QUEUE_EMPTY_MASK, pse_stat)); |
| 3766 | + seq_printf(s, "\t\tSEC TX Q/RX Q empty=%ld/%ld\n", |
| 3767 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SEC_TX_QUEUE_EMPTY_MASK, pse_stat), |
| 3768 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SEC_RX_QUEUE_EMPTY_SHFT, pse_stat)); |
| 3769 | + seq_printf(s, "\t\tSFD PARK Q empty=%ld\n", |
| 3770 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_SFD_PARK_QUEUE_EMPTY_MASK, pse_stat)); |
| 3771 | + seq_printf(s, "\t\tMDP TXIOC Q/RXIOC Q empty=%ld/%ld\n", |
| 3772 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_TXIOC_QUEUE_EMPTY_MASK, pse_stat), |
| 3773 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_MDP_RXIOC_QUEUE_EMPTY_MASK, pse_stat)); |
| 3774 | + seq_printf(s, "\t\tRLS Q empty=%ld\n", |
| 3775 | + FIELD_GET(MT_DBG_PSE_QUEUE_EMPTY_RLS_Q_EMTPY_MASK, pse_stat)); |
| 3776 | + seq_printf(s, "Nonempty Q info:\n"); |
| 3777 | + |
| 3778 | + for (i = 0; i < 31; i++) { |
| 3779 | + if (((pse_stat & (0x1 << i)) >> i) == 0) { |
| 3780 | + u32 hfid, tfid, pktcnt, fl_que_ctrl[3] = {0}; |
| 3781 | + |
| 3782 | + if (pse_queue_empty_info[i].QueueName != NULL) { |
| 3783 | + seq_printf(s, "\t%s: ", pse_queue_empty_info[i].QueueName); |
| 3784 | + fl_que_ctrl[0] |= MT_DBG_PSE_FL_QUE_CTRL_0_EXECUTE_MASK; |
| 3785 | + fl_que_ctrl[0] |= (pse_queue_empty_info[i].Portid << MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_PID_SHFT); |
| 3786 | + fl_que_ctrl[0] |= (pse_queue_empty_info[i].Queueid << MT_DBG_PSE_FL_QUE_CTRL_0_Q_BUF_QID_SHFT); |
| 3787 | + } else |
| 3788 | + continue; |
| 3789 | + |
| 3790 | + fl_que_ctrl[0] |= (0x1 << 31); |
| 3791 | + |
| 3792 | + mt76_wr(dev, MT_DBG_PSE_FL_QUE_CTRL_0_ADDR, fl_que_ctrl[0]); |
| 3793 | + fl_que_ctrl[1] = mt76_rr(dev, MT_DBG_PSE_FL_QUE_CTRL_2_ADDR); |
| 3794 | + fl_que_ctrl[2] = mt76_rr(dev, MT_DBG_PSE_FL_QUE_CTRL_3_ADDR); |
| 3795 | + |
| 3796 | + hfid = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_HEAD_FID_MASK, fl_que_ctrl[1]); |
| 3797 | + tfid = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_2_QUEUE_TAIL_FID_MASK, fl_que_ctrl[1]); |
| 3798 | + pktcnt = FIELD_GET(MT_DBG_PSE_FL_QUE_CTRL_3_QUEUE_PKT_NUM_MASK, fl_que_ctrl[2]); |
| 3799 | + seq_printf(s, "tail/head fid = 0x%03x/0x%03x, pkt cnt = 0x%03x\n", |
| 3800 | + tfid, hfid, pktcnt); |
| 3801 | + } |
| 3802 | + } |
| 3803 | + |
| 3804 | + return 0; |
| 3805 | +} |
| 3806 | + |
| 3807 | +static int mt7915_mibinfo_read_per_band(struct seq_file *s, int band_idx) |
| 3808 | +{ |
| 3809 | +#define BSS_NUM 4 |
| 3810 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 3811 | + u32 mac_val0, mac_val, mac_val1, idx, band_offset = 0; |
| 3812 | + u32 msdr6, msdr7, msdr8, msdr9, msdr10, msdr16, msdr17, msdr18, msdr19, msdr20, msdr21; |
| 3813 | + u32 mbxsdr[BSS_NUM][7]; |
| 3814 | + u32 mbtcr[16], mbtbcr[16], mbrcr[16], mbrbcr[16]; |
| 3815 | + u32 btcr[BSS_NUM], btbcr[BSS_NUM], brcr[BSS_NUM], brbcr[BSS_NUM], btdcr[BSS_NUM], brdcr[BSS_NUM]; |
| 3816 | + u32 mu_cnt[5]; |
| 3817 | + u32 ampdu_cnt[3]; |
| 3818 | + unsigned long per; |
| 3819 | + |
| 3820 | + seq_printf(s, "Band %d MIB Status\n", band_idx); |
| 3821 | + seq_printf(s, "===============================\n"); |
| 3822 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SCR0(band_idx)); |
| 3823 | + seq_printf(s, "MIB Status Control=0x%x\n", mac_val); |
| 3824 | + if (is_mt7915(&dev->mt76)) { |
| 3825 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0PBSCR(band_idx)); |
| 3826 | + seq_printf(s, "MIB Per-BSS Status Control=0x%x\n", mac_val); |
| 3827 | + } |
| 3828 | + |
| 3829 | + msdr6 = mt76_rr(dev, MT_DBG_MIB_M0SDR6(band_idx)); |
| 3830 | + msdr7 = mt76_rr(dev, MT_DBG_MIB_M0SDR7(band_idx)); |
| 3831 | + msdr8 = mt76_rr(dev, MT_DBG_MIB_M0SDR8(band_idx)); |
| 3832 | + msdr9 = mt76_rr(dev, MT_DBG_MIB_M0SDR9(band_idx)); |
| 3833 | + msdr10 = mt76_rr(dev, MT_DBG_MIB_M0SDR10(band_idx)); |
| 3834 | + msdr16 = mt76_rr(dev, MT_DBG_MIB_M0SDR16(band_idx)); |
| 3835 | + msdr17 = mt76_rr(dev, MT_DBG_MIB_M0SDR17(band_idx)); |
| 3836 | + msdr18 = mt76_rr(dev, MT_DBG_MIB_M0SDR18(band_idx)); |
| 3837 | + msdr19 = mt76_rr(dev, MT_DBG_MIB_M0SDR19(band_idx)); |
| 3838 | + msdr20 = mt76_rr(dev, MT_DBG_MIB_M0SDR20(band_idx)); |
| 3839 | + msdr21 = mt76_rr(dev, MT_DBG_MIB_M0SDR21(band_idx)); |
| 3840 | + ampdu_cnt[0] = mt76_rr(dev, MT_DBG_MIB_M0SDR12(band_idx)); |
| 3841 | + ampdu_cnt[1] = mt76_rr(dev, MT_DBG_MIB_M0SDR14(band_idx)); |
| 3842 | + ampdu_cnt[2] = mt76_rr(dev, MT_DBG_MIB_M0SDR15(band_idx)); |
| 3843 | + ampdu_cnt[1] &= MT_DBG_MIB_M0SDR14_AMPDU_MASK; |
| 3844 | + ampdu_cnt[2] &= MT_DBG_MIB_M0SDR15_AMPDU_ACKED_MASK; |
| 3845 | + |
| 3846 | + seq_printf(s, "===Phy/Timing Related Counters===\n"); |
| 3847 | + seq_printf(s, "\tChannelIdleCnt=0x%x\n", msdr6 & BN0_WF_MIB_TOP_M0SDR6_CHANNEL_IDLE_COUNT_MASK); |
| 3848 | + seq_printf(s, "\tCCA_NAV_Tx_Time=0x%x\n", msdr9 & BN0_WF_MIB_TOP_M0SDR9_CCA_NAV_TX_TIME_MASK); |
| 3849 | + seq_printf(s, "\tRx_MDRDY_CNT=0x%lx\n", msdr10 & MT_DBG_MIB_M0SDR10_RX_MDRDY_COUNT_MASK); |
| 3850 | + seq_printf(s, "\tCCK_MDRDY_TIME=0x%x, OFDM_MDRDY_TIME=0x%x, OFDM_GREEN_MDRDY_TIME=0x%x\n", |
| 3851 | + msdr19 & BN0_WF_MIB_TOP_M0SDR19_CCK_MDRDY_TIME_MASK, |
| 3852 | + msdr20 & BN0_WF_MIB_TOP_M0SDR20_OFDM_LG_MIXED_VHT_MDRDY_TIME_MASK, |
| 3853 | + msdr21 & BN0_WF_MIB_TOP_M0SDR21_OFDM_GREEN_MDRDY_TIME_MASK); |
| 3854 | + seq_printf(s, "\tPrim CCA Time=0x%x\n", msdr16 & BN0_WF_MIB_TOP_M0SDR16_P_CCA_TIME_MASK); |
| 3855 | + seq_printf(s, "\tSec CCA Time=0x%x\n", msdr17 & BN0_WF_MIB_TOP_M0SDR17_S_CCA_TIME_MASK); |
| 3856 | + seq_printf(s, "\tPrim ED Time=0x%x\n", msdr18 & BN0_WF_MIB_TOP_M0SDR18_P_ED_TIME_MASK); |
| 3857 | + |
| 3858 | + seq_printf(s, "===Tx Related Counters(Generic)===\n"); |
| 3859 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR0(band_idx)); |
| 3860 | + dev->dbg.bcn_total_cnt[band_idx] += (mac_val & BN0_WF_MIB_TOP_M0SDR0_BEACONTXCOUNT_MASK); |
| 3861 | + seq_printf(s, "\tBeaconTxCnt=0x%x\n",dev->dbg.bcn_total_cnt[band_idx]); |
| 3862 | + dev->dbg.bcn_total_cnt[band_idx] = 0; |
| 3863 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR0(band_idx)); |
| 3864 | + seq_printf(s, "\tTx 20MHz Cnt=0x%x\n", mac_val & BN0_WF_MIB_TOP_M0DR0_TX_20MHZ_CNT_MASK); |
| 3865 | + seq_printf(s, "\tTx 40MHz Cnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR0_TX_40MHZ_CNT_SHFT); |
| 3866 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR1(band_idx)); |
| 3867 | + seq_printf(s, "\tTx 80MHz Cnt=0x%x\n", mac_val & BN0_WF_MIB_TOP_M0DR1_TX_80MHZ_CNT_MASK); |
| 3868 | + seq_printf(s, "\tTx 160MHz Cnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR1_TX_160MHZ_CNT_SHFT); |
| 3869 | + seq_printf(s, "\tAMPDU Cnt=0x%x\n", ampdu_cnt[0]); |
| 3870 | + seq_printf(s, "\tAMPDU MPDU Cnt=0x%x\n", ampdu_cnt[1]); |
| 3871 | + seq_printf(s, "\tAMPDU MPDU Ack Cnt=0x%x\n", ampdu_cnt[2]); |
| 3872 | + per = (ampdu_cnt[2] == 0 ? 0 : 1000 * (ampdu_cnt[1] - ampdu_cnt[2]) / ampdu_cnt[1]); |
| 3873 | + seq_printf(s, "\tAMPDU MPDU PER=%ld.%1ld%%\n", per / 10, per % 10); |
| 3874 | + |
| 3875 | + seq_printf(s, "===MU Related Counters===\n"); |
| 3876 | + mu_cnt[0] = mt76_rr(dev, MT_DBG_MIB_MUBF(band_idx)); |
| 3877 | + mu_cnt[1] = mt76_rr(dev, MT_DBG_MIB_M0DR8(band_idx)); |
| 3878 | + mu_cnt[2] = mt76_rr(dev, MT_DBG_MIB_M0DR9(band_idx)); |
| 3879 | + mu_cnt[3] = mt76_rr(dev, MT_DBG_MIB_M0DR10(band_idx)); |
| 3880 | + mu_cnt[4] = mt76_rr(dev, MT_DBG_MIB_M0DR11(band_idx)); |
| 3881 | + seq_printf(s, "\tMUBF_TX_COUNT=0x%x\n", mu_cnt[0] & BN0_WF_MIB_TOP_M0SDR34_MUBF_TX_COUNT_MASK); |
| 3882 | + seq_printf(s, "\tMU_TX_MPDU_COUNT(Ok+Fail)=0x%x\n", mu_cnt[1]); |
| 3883 | + seq_printf(s, "\tMU_TX_OK_MPDU_COUNT=0x%x\n", mu_cnt[2]); |
| 3884 | + seq_printf(s, "\tMU_TO_SU_PPDU_COUNT=0x%x\n", mu_cnt[3] & BN0_WF_MIB_TOP_M0DR10_MU_FAIL_PPDU_CNT_MASK); |
| 3885 | + seq_printf(s, "\tSU_TX_OK_MPDU_COUNT=0x%x\n", mu_cnt[4]); |
| 3886 | + |
| 3887 | + seq_printf(s, "===Rx Related Counters(Generic)===\n"); |
| 3888 | + seq_printf(s, "\tVector Mismacth Cnt=0x%x\n", msdr7 & BN0_WF_MIB_TOP_M0SDR7_VEC_MISS_COUNT_MASK); |
| 3889 | + seq_printf(s, "\tDelimiter Fail Cnt=0x%x\n", msdr8 & BN0_WF_MIB_TOP_M0SDR8_DELIMITER_FAIL_COUNT_MASK); |
| 3890 | + |
| 3891 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR3(band_idx)); |
| 3892 | + seq_printf(s, "\tRxFCSErrCnt=0x%lx\n", __DBG_FIELD_GET(DBG_MIB_RX_FCS_ERROR_COUNT, mac_val)); |
| 3893 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR4(band_idx)); |
| 3894 | + seq_printf(s, "\tRxFifoFullCnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR4_RX_FIFO_FULL_COUNT_MASK)); |
| 3895 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR11(band_idx)); |
| 3896 | + seq_printf(s, "\tRxLenMismatch=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR11_RX_LEN_MISMATCH_MASK)); |
| 3897 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR5(band_idx)); |
| 3898 | + seq_printf(s, "\tRxMPDUCnt=0x%x\n", (mac_val & BN0_WF_MIB_TOP_M0SDR5_RX_MPDU_COUNT_MASK)); |
| 3899 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR22(band_idx)); |
| 3900 | + seq_printf(s, "\tRx AMPDU Cnt=0x%x\n", mac_val); |
| 3901 | + /* TODO: shiang-MT7615, is MIB_M0SDR23 used for Rx total byte count for all or just AMPDU only??? */ |
| 3902 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0SDR23(band_idx)); |
| 3903 | + seq_printf(s, "\tRx Total ByteCnt=0x%x\n", mac_val); |
| 3904 | + |
| 3905 | + if (is_mt7915(&dev->mt76)) { |
| 3906 | + band_offset = WF_WTBLON_TOP_B1BTCRn_ADDR - WF_WTBLON_TOP_B0BTCRn_ADDR;//check |
| 3907 | + seq_printf(s, "===Per-BSS Related Tx/Rx Counters===\n"); |
| 3908 | + seq_printf(s, "BSS Idx TxCnt/DataCnt TxByteCnt RxCnt/DataCnt RxByteCnt\n"); |
| 3909 | + |
| 3910 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 3911 | + btcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTCRn_ADDR + band_offset + idx * 4); |
| 3912 | + btbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTBCRn_ADDR + band_offset + idx * 4); |
| 3913 | + brcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRCRn_ADDR + band_offset + idx * 4); |
| 3914 | + brbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRBCRn_ADDR + band_offset + idx * 4); |
| 3915 | + btdcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BTDCRn_ADDR + band_offset + idx * 4); |
| 3916 | + brdcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0BRDCRn_ADDR + band_offset + idx * 4); |
| 3917 | + } |
| 3918 | + |
| 3919 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 3920 | + seq_printf(s, "%d\t 0x%x/0x%x\t 0x%x \t 0x%x/0x%x \t 0x%x\n", |
| 3921 | + idx, btcr[idx], btdcr[idx], btbcr[idx], |
| 3922 | + brcr[idx], brdcr[idx], brbcr[idx]); |
| 3923 | + } |
| 3924 | + |
| 3925 | + band_offset = (BN1_WF_MIB_TOP_BASE - BN0_WF_MIB_TOP_BASE) * band_idx; |
| 3926 | + seq_printf(s, "===Per-MBSS Related MIB Counters===\n"); |
| 3927 | + seq_printf(s, "BSS Idx RTSTx/RetryCnt BAMissCnt AckFailCnt FrmRetry1/2/3Cnt\n"); |
| 3928 | + |
| 3929 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 3930 | + mbxsdr[idx][0] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR0_ADDR + band_offset + idx * 0x10); |
| 3931 | + mbxsdr[idx][1] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR1_ADDR + band_offset + idx * 0x10); |
| 3932 | + mbxsdr[idx][2] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR2_ADDR + band_offset + idx * 0x10); |
| 3933 | + mbxsdr[idx][3] = mt76_rr(dev, BN0_WF_MIB_TOP_M0B0SDR3_ADDR + band_offset + idx * 0x10); |
| 3934 | + } |
| 3935 | + |
| 3936 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 3937 | + seq_printf(s, "%d:\t0x%08x/0x%08x 0x%08x \t 0x%08x \t 0x%08x/0x%08x/0x%08x\n", |
| 3938 | + idx, (mbxsdr[idx][0] & BN0_WF_MIB_TOP_M0B0SDR0_RTSTXCOUNT_MASK), |
| 3939 | + (mbxsdr[idx][0] & BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR0_RTSRETRYCOUNT_SHFT, |
| 3940 | + (mbxsdr[idx][1] & BN0_WF_MIB_TOP_M0B0SDR1_BAMISSCOUNT_MASK), |
| 3941 | + (mbxsdr[idx][1] & BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR1_ACKFAILCOUNT_SHFT, |
| 3942 | + (mbxsdr[idx][2] & BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRYCOUNT_MASK), |
| 3943 | + (mbxsdr[idx][2] & BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_MASK) >> BN0_WF_MIB_TOP_M0B0SDR2_FRAMERETRY2COUNT_SHFT, |
| 3944 | + (mbxsdr[idx][3] & BN0_WF_MIB_TOP_M0B0SDR3_FRAMERETRY3COUNT_MASK)); |
| 3945 | + } |
| 3946 | + |
| 3947 | + band_offset = WF_WTBLON_TOP_B1BTCRn_ADDR - WF_WTBLON_TOP_B0BTCRn_ADDR; |
| 3948 | + seq_printf(s, "===Per-MBSS Related Tx/Rx Counters===\n"); |
| 3949 | + seq_printf(s, "MBSSIdx TxCnt TxByteCnt RxCnt RxByteCnt\n"); |
| 3950 | + |
| 3951 | + for (idx = 0; idx < 16; idx++) { |
| 3952 | + mbtcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBTCRn_ADDR + band_offset + idx * 4); |
| 3953 | + mbtbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBTBCRn_ADDR + band_offset + idx * 4); |
| 3954 | + mbrcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBRCRn_ADDR + band_offset + idx * 4); |
| 3955 | + mbrbcr[idx] = mt76_rr(dev, WF_WTBLON_TOP_B0MBRBCRn_ADDR + band_offset + idx * 4); |
| 3956 | + } |
| 3957 | + |
| 3958 | + for (idx = 0; idx < 16; idx++) { |
| 3959 | + seq_printf(s, "%d\t 0x%08x\t 0x%08x \t 0x%08x \t 0x%08x\n", |
| 3960 | + idx, mbtcr[idx], mbtbcr[idx], mbrcr[idx], mbrbcr[idx]); |
| 3961 | + } |
| 3962 | + return 0; |
| 3963 | + } else { |
| 3964 | + u32 btocr[BSS_NUM], mbtocr[16],mbrocr[16], brocr[BSS_NUM]; |
| 3965 | + u8 bss_nums = BSS_NUM; |
| 3966 | + |
| 3967 | + band_offset = (BN1_WF_MIB_TOP_BTOCR_ADDR - BN0_WF_MIB_TOP_BTOCR_ADDR) * band_idx; |
| 3968 | + seq_printf(s, "===Per-BSS Related Tx/Rx Counters===\n"); |
| 3969 | + seq_printf(s, "BSS Idx TxCnt/DataCnt TxByteCnt RxCnt/DataCnt RxByteCnt\n"); |
| 3970 | + |
| 3971 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 3972 | + btocr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTOCR_ADDR + band_offset + (idx >> 1) * 4)); |
| 3973 | + btdcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTDCR_ADDR + band_offset + (idx >> 1) * 4)); |
| 3974 | + btbcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BTBCR_ADDR + band_offset + (idx * 4))); |
| 3975 | + brocr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BROCR_ADDR + band_offset + (idx >> 1) * 4)); |
| 3976 | + brdcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BRDCR_ADDR + band_offset + (idx >> 1) * 4)); |
| 3977 | + brbcr[idx] = mt76_rr(dev, (BN0_WF_MIB_TOP_BRBCR_ADDR + band_offset + (idx * 4))); |
| 3978 | + |
| 3979 | + if ((idx % 2) == 0) { |
| 3980 | + btocr[idx] = ((btocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT); |
| 3981 | + btdcr[idx] = ((btdcr[idx] & BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2n_SHFT); |
| 3982 | + brocr[idx] = ((brocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT); |
| 3983 | + brdcr[idx] = ((brdcr[idx] & BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2n_SHFT); |
| 3984 | + } else { |
| 3985 | + btocr[idx] = ((btocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT); |
| 3986 | + btdcr[idx] = ((btdcr[idx] & BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTDCR_TX_DATA_COUNT2np1_SHFT); |
| 3987 | + brocr[idx] = ((brocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT); |
| 3988 | + brdcr[idx] = ((brdcr[idx] & BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BRDCR_RX_DATA_COUNT2np1_SHFT); |
| 3989 | + } |
| 3990 | + } |
| 3991 | + |
| 3992 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 3993 | + seq_printf(s, "%d\t 0x%x/0x%x\t 0x%x \t 0x%x/0x%x \t 0x%x\n", |
| 3994 | + idx, btocr[idx], btdcr[idx], btbcr[idx], brocr[idx], brdcr[idx], brbcr[idx]); |
| 3995 | + } |
| 3996 | + |
| 3997 | + band_offset = (BN1_WF_MIB_TOP_BASE - BN0_WF_MIB_TOP_BASE) * band_idx; |
| 3998 | + seq_printf(s, "===Per-MBSS Related MIB Counters===\n"); |
| 3999 | + seq_printf(s, "BSS Idx RTSTx/RetryCnt BAMissCnt AckFailCnt FrmRetry1/2/3Cnt\n"); |
| 4000 | + |
| 4001 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 4002 | + mbxsdr[idx][0] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR0_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4003 | + mbxsdr[idx][1] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR1_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4004 | + mbxsdr[idx][2] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR2_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4005 | + mbxsdr[idx][3] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR3_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4006 | + mbxsdr[idx][4] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR4_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4007 | + mbxsdr[idx][5] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR5_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4008 | + mbxsdr[idx][6] = mt76_rr(dev, BN0_WF_MIB_TOP_BSDR6_ADDR + band_offset + ((idx >> 1) * 4)); |
| 4009 | + |
| 4010 | + if ((idx % 2) == 0) { |
| 4011 | + mbxsdr[idx][0] = ((mbxsdr[idx][0] & BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2n_SHFT); |
| 4012 | + mbxsdr[idx][1] = ((mbxsdr[idx][1] & BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2n_SHFT); |
| 4013 | + mbxsdr[idx][2] = ((mbxsdr[idx][2] & BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2n_SHFT); |
| 4014 | + mbxsdr[idx][3] = ((mbxsdr[idx][3] & BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2n_SHFT); |
| 4015 | + mbxsdr[idx][4] = ((mbxsdr[idx][4] & BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2n_SHFT); |
| 4016 | + mbxsdr[idx][5] = ((mbxsdr[idx][5] & BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2n_SHFT); |
| 4017 | + mbxsdr[idx][6] = ((mbxsdr[idx][6] & BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_MASK) >> BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2n_SHFT); |
| 4018 | + } else { |
| 4019 | + mbxsdr[idx][0] = ((mbxsdr[idx][0] & BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR0_RTSTXCOUNT2np1_SHFT); |
| 4020 | + mbxsdr[idx][1] = ((mbxsdr[idx][1] & BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR1_RTSRETRYCOUNT2np1_SHFT); |
| 4021 | + mbxsdr[idx][2] = ((mbxsdr[idx][2] & BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR2_BAMISSCOUNT2np1_SHFT); |
| 4022 | + mbxsdr[idx][3] = ((mbxsdr[idx][3] & BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR3_ACKFAILCOUNT2np1_SHFT); |
| 4023 | + mbxsdr[idx][4] = ((mbxsdr[idx][4] & BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR4_FRAMERETRYCOUNT2np1_SHFT); |
| 4024 | + mbxsdr[idx][5] = ((mbxsdr[idx][5] & BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR5_FRAMERETRY2COUNT2np1_SHFT); |
| 4025 | + mbxsdr[idx][6] = ((mbxsdr[idx][6] & BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BSDR6_FRAMERETRY3COUNT2np1_SHFT); |
| 4026 | + } |
| 4027 | + } |
| 4028 | + |
| 4029 | + for (idx = 0; idx < BSS_NUM; idx++) { |
| 4030 | + seq_printf(s, "%d:\t0x%x/0x%x 0x%x \t 0x%x \t 0x%x/0x%x/0x%x\n", |
| 4031 | + idx, |
| 4032 | + mbxsdr[idx][0], mbxsdr[idx][1], mbxsdr[idx][2], mbxsdr[idx][3], |
| 4033 | + mbxsdr[idx][4], mbxsdr[idx][5], mbxsdr[idx][6]); |
| 4034 | + } |
| 4035 | + |
| 4036 | + band_offset = (BN1_WF_MIB_TOP_BTOCR_ADDR - BN0_WF_MIB_TOP_BTOCR_ADDR) * band_idx; |
| 4037 | + seq_printf(s, "===Per-MBSS Related Tx/Rx Counters===\n"); |
| 4038 | + seq_printf(s, "MBSSIdx TxCnt TxByteCnt RxCnt RxByteCnt\n"); |
| 4039 | + |
| 4040 | + for (idx = 0; idx < 16; idx++) { |
| 4041 | + mbtocr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BTOCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + ((idx >> 1) * 4))); |
| 4042 | + mbtbcr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BTBCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + (idx * 4))); |
| 4043 | + mbrocr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BROCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + ((idx >> 1) * 4))); |
| 4044 | + mbrbcr[idx] = mt76_rr(dev, BN0_WF_MIB_TOP_BRBCR_ADDR + band_offset + (((bss_nums >> 1) * 4) + (idx * 4))); |
| 4045 | + |
| 4046 | + if ((idx % 2) == 0) { |
| 4047 | + mbtocr[idx] = ((mbtocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2n_SHFT); |
| 4048 | + mbrocr[idx] = ((mbrocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2n_SHFT); |
| 4049 | + } else { |
| 4050 | + mbtocr[idx] = ((mbtocr[idx] & BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BTOCR_TX_OK_COUNT2np1_SHFT); |
| 4051 | + mbrocr[idx] = ((mbrocr[idx] & BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_MASK) >> BN0_WF_MIB_TOP_BROCR_RX_OK_COUNT2np1_SHFT); |
| 4052 | + } |
| 4053 | + } |
| 4054 | + |
| 4055 | + for (idx = 0; idx < 16; idx++) { |
| 4056 | + seq_printf(s, "%d\t 0x%08x\t 0x%08x \t 0x%08x \t 0x%08x\n", |
| 4057 | + idx, mbtocr[idx], mbtbcr[idx], mbrocr[idx], mbrbcr[idx]); |
| 4058 | + } |
| 4059 | + } |
| 4060 | + |
| 4061 | + seq_printf(s, "===Dummy delimiter insertion result===\n"); |
| 4062 | + mac_val0 = mt76_rr(dev, MT_DBG_MIB_M0DR11(band_idx)); |
| 4063 | + mac_val = mt76_rr(dev, MT_DBG_MIB_M0DR6(band_idx)); |
| 4064 | + mac_val1 = mt76_rr(dev, MT_DBG_MIB_M0DR7(band_idx)); |
| 4065 | + seq_printf(s, "Range0 = %d\t Range1 = %d\t Range2 = %d\t Range3 = %d\t Range4 = %d\n", |
| 4066 | + (mac_val0 & BN0_WF_MIB_TOP_M0DR12_TX_DDLMT_RNG0_CNT_MASK), |
| 4067 | + (mac_val & BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG1_CNT_MASK), |
| 4068 | + (mac_val & BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR6_TX_DDLMT_RNG2_CNT_SHFT, |
| 4069 | + (mac_val1 & BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG3_CNT_MASK), |
| 4070 | + (mac_val1 & BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_MASK) >> BN0_WF_MIB_TOP_M0DR7_TX_DDLMT_RNG4_CNT_SHFT); |
| 4071 | + |
| 4072 | + return 0; |
| 4073 | +} |
| 4074 | + |
| 4075 | +static int mt7915_mibinfo_band0(struct seq_file *s, void *data) |
| 4076 | +{ |
| 4077 | + mt7915_mibinfo_read_per_band(s, 0); |
| 4078 | + return 0; |
| 4079 | +} |
| 4080 | + |
| 4081 | +static int mt7915_mibinfo_band1(struct seq_file *s, void *data) |
| 4082 | +{ |
| 4083 | + mt7915_mibinfo_read_per_band(s, 1); |
| 4084 | + return 0; |
| 4085 | +} |
| 4086 | + |
| 4087 | +static int mt7915_token_read(struct seq_file *s, void *data) |
| 4088 | +{ |
| 4089 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4090 | + int id, count = 0; |
| 4091 | + struct mt76_txwi_cache *txwi; |
| 4092 | + |
| 4093 | + seq_printf(s, "Cut through token:\n"); |
| 4094 | + spin_lock_bh(&dev->mt76.token_lock); |
| 4095 | + idr_for_each_entry(&dev->mt76.token, txwi, id) { |
| 4096 | + seq_printf(s, "%4d ", id); |
| 4097 | + count++; |
| 4098 | + if (count % 8 == 0) |
| 4099 | + seq_printf(s, "\n"); |
| 4100 | + } |
| 4101 | + spin_unlock_bh(&dev->mt76.token_lock); |
| 4102 | + seq_printf(s, "\n"); |
| 4103 | + |
| 4104 | + return 0; |
| 4105 | +} |
| 4106 | + |
| 4107 | +struct txd_l { |
| 4108 | + u32 txd_0; |
| 4109 | + u32 txd_1; |
| 4110 | + u32 txd_2; |
| 4111 | + u32 txd_3; |
| 4112 | + u32 txd_4; |
| 4113 | + u32 txd_5; |
| 4114 | + u32 txd_6; |
| 4115 | + u32 txd_7; |
| 4116 | +} __packed; |
| 4117 | + |
| 4118 | +char *pkt_ft_str[] = {"cut_through", "store_forward", "cmd", "PDA_FW_Download"}; |
| 4119 | +char *hdr_fmt_str[] = { |
| 4120 | + "Non-80211-Frame", |
| 4121 | + "Command-Frame", |
| 4122 | + "Normal-80211-Frame", |
| 4123 | + "enhanced-80211-Frame", |
| 4124 | +}; |
| 4125 | +/* TMAC_TXD_1.hdr_format */ |
| 4126 | +#define TMI_HDR_FT_NON_80211 0x0 |
| 4127 | +#define TMI_HDR_FT_CMD 0x1 |
| 4128 | +#define TMI_HDR_FT_NOR_80211 0x2 |
| 4129 | +#define TMI_HDR_FT_ENH_80211 0x3 |
| 4130 | + |
| 4131 | +void mt7915_dump_tmac_info(u8 *tmac_info) |
| 4132 | +{ |
| 4133 | + struct txd_l *txd = (struct txd_l *)tmac_info; |
| 4134 | + |
| 4135 | + printk("txd raw data: size=%d\n", MT_TXD_SIZE); |
| 4136 | + print_hex_dump(KERN_ERR , "", DUMP_PREFIX_OFFSET, 16, 1, tmac_info, MT_TXD_SIZE, false); |
| 4137 | + |
| 4138 | + printk("TMAC_TXD Fields:\n"); |
| 4139 | + printk("\tTMAC_TXD_0:\n"); |
| 4140 | + |
| 4141 | + /* DW0 */ |
| 4142 | + /* TX Byte Count [15:0] */ |
| 4143 | + printk("\t\tTxByteCnt = %ld\n", FIELD_GET(MT_TXD0_TX_BYTES, txd->txd_0)); |
| 4144 | + |
| 4145 | + /* PKT_FT: Packet Format [24:23] */ |
| 4146 | + printk("\t\tpkt_ft = %ld(%s)\n", |
| 4147 | + FIELD_GET(MT_TXD0_PKT_FMT, txd->txd_0), |
| 4148 | + pkt_ft_str[FIELD_GET(MT_TXD0_PKT_FMT, txd->txd_0)]); |
| 4149 | + |
| 4150 | + /* Q_IDX [31:25] */ |
| 4151 | + printk("\t\tQueID =0x%lx\n", FIELD_GET(MT_TXD0_Q_IDX, txd->txd_0)); |
| 4152 | + |
| 4153 | + printk("\tTMAC_TXD_1:\n"); |
| 4154 | + |
| 4155 | + /* DW1 */ |
| 4156 | + /* WLAN Indec [9:0] */ |
| 4157 | + printk("\t\tWlan Index = %ld\n", FIELD_GET(MT_TXD1_WLAN_IDX, txd->txd_1)); |
| 4158 | + |
| 4159 | + /* VTA [10] */ |
| 4160 | + printk("\t\tVTA = %d\n", ((txd->txd_1 & MT_TXD1_VTA) ? 1 : 0)); |
| 4161 | + |
| 4162 | + /* HF: Header Format [17:16] */ |
| 4163 | + printk("\t\tHdrFmt = %ld(%s)\n", |
| 4164 | + FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1), |
| 4165 | + FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1) < 4 ? |
| 4166 | + hdr_fmt_str[FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1)] : "N/A"); |
| 4167 | + |
| 4168 | + switch (FIELD_GET(MT_TXD1_HDR_FORMAT, txd->txd_1)) { |
| 4169 | + case TMI_HDR_FT_NON_80211: |
| 4170 | + /* MRD [11], EOSP [12], RMVL [13], VLAN [14], ETYPE [15] */ |
| 4171 | + printk("\t\t\tMRD = %d, EOSP = %d,\ |
| 4172 | + RMVL = %d, VLAN = %d, ETYP = %d\n", |
| 4173 | + (txd->txd_1 & MT_TXD1_MRD) ? 1 : 0, |
| 4174 | + (txd->txd_1 & MT_TXD1_EOSP) ? 1 : 0, |
| 4175 | + (txd->txd_1 & MT_TXD1_RMVL) ? 1 : 0, |
| 4176 | + (txd->txd_1 & MT_TXD1_VLAN) ? 1 : 0, |
| 4177 | + (txd->txd_1 & MT_TXD1_ETYP) ? 1 : 0); |
| 4178 | + break; |
| 4179 | + case TMI_HDR_FT_NOR_80211: |
| 4180 | + /* HEADER_LENGTH [15:11] */ |
| 4181 | + printk("\t\t\tHeader Len = %ld(WORD)\n", FIELD_GET(MT_TXD1_HDR_INFO, txd->txd_1)); |
| 4182 | + break; |
| 4183 | + |
| 4184 | + case TMI_HDR_FT_ENH_80211: |
| 4185 | + /* EOSP [12], AMS [13] */ |
| 4186 | + printk("\t\t\tEOSP = %d, AMS = %d\n", |
| 4187 | + (txd->txd_1 & MT_TXD1_EOSP) ? 1 : 0, |
| 4188 | + (txd->txd_1 & MT_TXD1_AMS) ? 1 : 0); |
| 4189 | + break; |
| 4190 | + } |
| 4191 | + |
| 4192 | + /* Header Padding [19:18] */ |
| 4193 | + printk("\t\tHdrPad = %ld\n", FIELD_GET(MT_TXD1_HDR_PAD, txd->txd_1)); |
| 4194 | + |
| 4195 | + /* TID [22:20] */ |
| 4196 | + printk("\t\tTID = %ld\n", FIELD_GET(MT_TXD1_TID, txd->txd_1)); |
| 4197 | + |
| 4198 | + |
| 4199 | + /* UtxB/AMSDU_C/AMSDU [23] */ |
| 4200 | + printk("\t\tamsdu = %d\n", ((txd->txd_1 & MT_TXD1_AMSDU) ? 1 : 0)); |
| 4201 | + |
| 4202 | + /* OM [29:24] */ |
| 4203 | + printk("\t\town_mac = %ld\n", FIELD_GET(MT_TXD1_OWN_MAC, txd->txd_1)); |
| 4204 | + |
| 4205 | + |
| 4206 | + /* TGID [30] */ |
| 4207 | + printk("\t\tTGID = %d\n", ((txd->txd_1 & MT_TXD1_TGID) ? 1 : 0)); |
| 4208 | + |
| 4209 | + |
| 4210 | + /* FT [31] */ |
| 4211 | + printk("\t\tTxDFormatType = %d\n", (txd->txd_1 & MT_TXD1_LONG_FORMAT) ? 1 : 0); |
| 4212 | + |
| 4213 | + printk("\tTMAC_TXD_2:\n"); |
| 4214 | + /* DW2 */ |
| 4215 | + /* Subtype [3:0] */ |
| 4216 | + printk("\t\tsub_type = %ld\n", FIELD_GET(MT_TXD2_SUB_TYPE, txd->txd_2)); |
| 4217 | + |
| 4218 | + /* Type[5:4] */ |
| 4219 | + printk("\t\tfrm_type = %ld\n", FIELD_GET(MT_TXD2_FRAME_TYPE, txd->txd_2)); |
| 4220 | + |
| 4221 | + /* NDP [6] */ |
| 4222 | + printk("\t\tNDP = %d\n", ((txd->txd_2 & MT_TXD2_NDP) ? 1 : 0)); |
| 4223 | + |
| 4224 | + /* NDPA [7] */ |
| 4225 | + printk("\t\tNDPA = %d\n", ((txd->txd_2 & MT_TXD2_NDPA) ? 1 : 0)); |
| 4226 | + |
| 4227 | + /* SD [8] */ |
| 4228 | + printk("\t\tSounding = %d\n", ((txd->txd_2 & MT_TXD2_SOUNDING) ? 1 : 0)); |
| 4229 | + |
| 4230 | + /* RTS [9] */ |
| 4231 | + printk("\t\tRTS = %d\n", ((txd->txd_2 & MT_TXD2_RTS) ? 1 : 0)); |
| 4232 | + |
| 4233 | + /* BM [10] */ |
| 4234 | + printk("\t\tbc_mc_pkt = %d\n", ((txd->txd_2 & MT_TXD2_MULTICAST) ? 1 : 0)); |
| 4235 | + |
| 4236 | + /* B [11] */ |
| 4237 | + printk("\t\tBIP = %d\n", ((txd->txd_2 & MT_TXD2_BIP) ? 1 : 0)); |
| 4238 | + |
| 4239 | + /* DU [12] */ |
| 4240 | + printk("\t\tDuration = %d\n", ((txd->txd_2 & MT_TXD2_DURATION) ? 1 : 0)); |
| 4241 | + |
| 4242 | + /* HE [13] */ |
| 4243 | + printk("\t\tHE(HTC Exist) = %d\n", ((txd->txd_2 & MT_TXD2_HTC_VLD) ? 1 : 0)); |
| 4244 | + |
| 4245 | + /* FRAG [15:14] */ |
| 4246 | + printk("\t\tFRAG = %ld\n", FIELD_GET(MT_TXD2_FRAG, txd->txd_2)); |
| 4247 | + |
| 4248 | + |
| 4249 | + /* Remaining Life Time [23:16]*/ |
| 4250 | + printk("\t\tReamingLife/MaxTx time = %ld (unit: 64TU)\n", |
| 4251 | + FIELD_GET(MT_TXD2_MAX_TX_TIME, txd->txd_2)); |
| 4252 | + |
| 4253 | + /* Power Offset [29:24] */ |
| 4254 | + printk("\t\tpwr_offset = %ld\n", FIELD_GET(MT_TXD2_POWER_OFFSET, txd->txd_2)); |
| 4255 | + |
| 4256 | + /* FRM [30] */ |
| 4257 | + printk("\t\tfix rate mode = %d\n", (txd->txd_2 & MT_TXD2_FIXED_RATE) ? 1 : 0); |
| 4258 | + |
| 4259 | + /* FR[31] */ |
| 4260 | + printk("\t\tfix rate = %d\n", (txd->txd_2 & MT_TXD2_FIX_RATE) ? 1 : 0); |
| 4261 | + |
| 4262 | + |
| 4263 | + printk("\tTMAC_TXD_3:\n"); |
| 4264 | + |
| 4265 | + /* DW3 */ |
| 4266 | + /* NA [0] */ |
| 4267 | + printk("\t\tNoAck = %d\n", (txd->txd_3 & MT_TXD3_NO_ACK) ? 1 : 0); |
| 4268 | + |
| 4269 | + /* PF [1] */ |
| 4270 | + printk("\t\tPF = %d\n", (txd->txd_3 & MT_TXD3_PROTECT_FRAME) ? 1 : 0); |
| 4271 | + |
| 4272 | + /* EMRD [2] */ |
| 4273 | + printk("\t\tEMRD = %d\n", (txd->txd_3 & MT_TXD3_EMRD) ? 1 : 0); |
| 4274 | + |
| 4275 | + /* EEOSP [3] */ |
| 4276 | + printk("\t\tEEOSP = %d\n", (txd->txd_3 & MT_TXD3_EEOSP) ? 1 : 0); |
| 4277 | + |
| 4278 | + /* DAS [4] */ |
| 4279 | + printk("\t\tda_select = %d\n", (txd->txd_3 & MT_TXD3_DAS) ? 1 : 0); |
| 4280 | + |
| 4281 | + /* TM [5] */ |
| 4282 | + printk("\t\ttm = %d\n", (txd->txd_3 & MT_TXD3_TIMING_MEASURE) ? 1 : 0); |
| 4283 | + |
| 4284 | + /* TX Count [10:6] */ |
| 4285 | + printk("\t\ttx_cnt = %ld\n", FIELD_GET(MT_TXD3_TX_COUNT, txd->txd_3)); |
| 4286 | + |
| 4287 | + /* Remaining TX Count [15:11] */ |
| 4288 | + printk("\t\tremain_tx_cnt = %ld\n", FIELD_GET(MT_TXD3_REM_TX_COUNT, txd->txd_3)); |
| 4289 | + |
| 4290 | + /* SN [27:16] */ |
| 4291 | + printk("\t\tsn = %ld\n", FIELD_GET(MT_TXD3_SEQ, txd->txd_3)); |
| 4292 | + |
| 4293 | + /* BA_DIS [28] */ |
| 4294 | + printk("\t\tba dis = %d\n", (txd->txd_3 & MT_TXD3_BA_DISABLE) ? 1 : 0); |
| 4295 | + |
| 4296 | + /* Power Management [29] */ |
| 4297 | + printk("\t\tpwr_mgmt = 0x%x\n", (txd->txd_3 & MT_TXD3_SW_POWER_MGMT) ? 1 : 0); |
| 4298 | + |
| 4299 | + /* PN_VLD [30] */ |
| 4300 | + printk("\t\tpn_vld = %d\n", (txd->txd_3 & MT_TXD3_PN_VALID) ? 1 : 0); |
| 4301 | + |
| 4302 | + /* SN_VLD [31] */ |
| 4303 | + printk("\t\tsn_vld = %d\n", (txd->txd_3 & MT_TXD3_SN_VALID) ? 1 : 0); |
| 4304 | + |
| 4305 | + |
| 4306 | + /* DW4 */ |
| 4307 | + printk("\tTMAC_TXD_4:\n"); |
| 4308 | + |
| 4309 | + /* PN_LOW [31:0] */ |
| 4310 | + printk("\t\tpn_low = 0x%lx\n", FIELD_GET(MT_TXD4_PN_LOW, txd->txd_4)); |
| 4311 | + |
| 4312 | + |
| 4313 | + /* DW5 */ |
| 4314 | + printk("\tTMAC_TXD_5:\n"); |
| 4315 | + |
| 4316 | + /* PID [7:0] */ |
| 4317 | + printk("\t\tpid = %ld\n", FIELD_GET(MT_TXD5_PID, txd->txd_5)); |
| 4318 | + |
| 4319 | + /* TXSFM [8] */ |
| 4320 | + printk("\t\ttx_status_fmt = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_FMT) ? 1 : 0); |
| 4321 | + |
| 4322 | + /* TXS2M [9] */ |
| 4323 | + printk("\t\ttx_status_2_mcu = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_MCU) ? 1 : 0); |
| 4324 | + |
| 4325 | + /* TXS2H [10] */ |
| 4326 | + printk("\t\ttx_status_2_host = %d\n", (txd->txd_5 & MT_TXD5_TX_STATUS_HOST) ? 1 : 0); |
| 4327 | + |
| 4328 | + /* ADD_BA [14] */ |
| 4329 | + printk("\t\tADD_BA = %d\n", (txd->txd_5 & MT_TXD5_ADD_BA) ? 1 : 0); |
| 4330 | + |
| 4331 | + /* MD [15] */ |
| 4332 | + printk("\t\tMD = %d\n", (txd->txd_5 & MT_TXD5_MD) ? 1 : 0); |
| 4333 | + |
| 4334 | + /* PN_HIGH [31:16] */ |
| 4335 | + printk("\t\tpn_high = 0x%lx\n", FIELD_GET(MT_TXD5_PN_HIGH, txd->txd_5)); |
| 4336 | + |
| 4337 | + /* DW6 */ |
| 4338 | + printk("\tTMAC_TXD_6:\n"); |
| 4339 | + |
| 4340 | + if (txd->txd_2 & MT_TXD2_FIX_RATE) { |
| 4341 | + /* Fixed BandWidth mode [2:0] */ |
developer | c5ce750 | 2022-12-19 11:33:22 +0800 | [diff] [blame] | 4342 | + printk("\t\tbw = %ld\n", |
| 4343 | + FIELD_GET(MT_TXD6_BW, txd->txd_6) | (txd->txd_6 & MT_TXD6_FIXED_BW)); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 4344 | + |
| 4345 | + /* DYN_BW [3] */ |
| 4346 | + printk("\t\tdyn_bw = %d\n", (txd->txd_6 & MT_TXD6_DYN_BW) ? 1 : 0); |
| 4347 | + |
| 4348 | + /* ANT_ID [7:4] */ |
| 4349 | + printk("\t\tant_id = %ld\n", FIELD_GET(MT_TXD6_ANT_ID, txd->txd_6)); |
| 4350 | + |
| 4351 | + /* SPE_IDX_SEL [10] */ |
| 4352 | + printk("\t\tspe_idx_sel = %d\n", (txd->txd_6 & MT_TXD6_SPE_ID_IDX) ? 1 : 0); |
| 4353 | + |
| 4354 | + /* LDPC [11] */ |
| 4355 | + printk("\t\tldpc = %d\n", (txd->txd_6 & MT_TXD6_LDPC) ? 1 : 0); |
| 4356 | + |
| 4357 | + /* HELTF Type[13:12] */ |
| 4358 | + printk("\t\tHELTF Type = %ld\n", FIELD_GET(MT_TXD6_HELTF, txd->txd_6)); |
| 4359 | + |
| 4360 | + /* GI Type [15:14] */ |
| 4361 | + printk("\t\tGI = %ld\n", FIELD_GET(MT_TXD6_SGI, txd->txd_6)); |
| 4362 | + |
| 4363 | + /* Rate to be Fixed [29:16] */ |
| 4364 | + printk("\t\ttx_rate = 0x%lx\n", FIELD_GET(MT_TXD6_TX_RATE, txd->txd_6)); |
| 4365 | + } |
| 4366 | + |
| 4367 | + /* TXEBF [30] */ |
| 4368 | + printk("\t\ttxebf = %d\n", (txd->txd_6 & MT_TXD6_TX_EBF) ? 1 : 0); |
| 4369 | + |
| 4370 | + /* TXIBF [31] */ |
| 4371 | + printk("\t\ttxibf = %d\n", (txd->txd_6 & MT_TXD6_TX_IBF) ? 1 : 0); |
| 4372 | + |
| 4373 | + /* DW7 */ |
| 4374 | + printk("\tTMAC_TXD_7:\n"); |
| 4375 | + |
| 4376 | + if ((txd->txd_1 & MT_TXD1_VTA) == 0) { |
| 4377 | + /* SW Tx Time [9:0] */ |
| 4378 | + printk("\t\tsw_tx_time = %ld\n", FIELD_GET(MT_TXD7_TX_TIME, txd->txd_7)); |
| 4379 | + } else { |
| 4380 | + /* TXD Arrival Time [9:0] */ |
| 4381 | + printk("\t\tat = %ld\n", FIELD_GET(MT_TXD7_TAT, txd->txd_7)); |
| 4382 | + } |
| 4383 | + |
| 4384 | + /* HW_AMSDU_CAP [10] */ |
| 4385 | + printk("\t\thw amsdu cap = %d\n",(txd->txd_7 & MT_TXD7_HW_AMSDU) ? 1 : 0); |
| 4386 | + |
| 4387 | + /* SPE_IDX [15:11] */ |
| 4388 | + if (txd->txd_2 & MT_TXD2_FIX_RATE) { |
| 4389 | + printk("\t\tspe_idx = 0x%lx\n", FIELD_GET(MT_TXD7_SPE_IDX, txd->txd_7)); |
| 4390 | + } |
| 4391 | + |
| 4392 | + /* PSE_FID [27:16] */ |
| 4393 | + printk("\t\tpse_fid = 0x%lx\n", FIELD_GET(MT_TXD7_PSE_FID, txd->txd_7)); |
| 4394 | + |
| 4395 | + /* Subtype [19:16] */ |
| 4396 | + printk("\t\tpp_sub_type=%ld\n", FIELD_GET(MT_TXD7_SUB_TYPE, txd->txd_7)); |
| 4397 | + |
| 4398 | + /* Type [21:20] */ |
| 4399 | + printk("\t\tpp_type=%ld\n", FIELD_GET(MT_TXD7_TYPE, txd->txd_7)); |
| 4400 | + |
| 4401 | + /* CTXD_CNT [25:23] */ |
| 4402 | + printk("\t\tctxd cnt=0x%lx\n", FIELD_GET(MT_TXD7_CTXD_CNT, txd->txd_7)); |
| 4403 | + |
| 4404 | + /* CTXD [26] */ |
| 4405 | + printk("\t\tctxd = %d\n", (txd->txd_7 & MT_TXD7_CTXD) ? 1 : 0); |
| 4406 | + |
| 4407 | + /* I [28] */ |
| 4408 | + printk("\t\ti = %d\n", (txd->txd_7 & MT_TXD7_IP_SUM) ? 1 : 0); |
| 4409 | + |
| 4410 | + /* UT [29] */ |
| 4411 | + printk("\t\tUT = %d\n", (txd->txd_7 & MT_TXD7_UDP_TCP_SUM) ? 1 : 0); |
| 4412 | + |
| 4413 | + /* TXDLEN [31:30] */ |
| 4414 | + printk("\t\t txd len= %ld\n", FIELD_GET(MT_TXD7_TXD_LEN, txd->txd_7)); |
| 4415 | +} |
| 4416 | + |
| 4417 | + |
| 4418 | +static int mt7915_token_txd_read(struct seq_file *s, void *data) |
| 4419 | +{ |
| 4420 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4421 | + struct mt76_txwi_cache *t; |
| 4422 | + u8* txwi; |
| 4423 | + |
| 4424 | + seq_printf(s, "\n"); |
| 4425 | + spin_lock_bh(&dev->mt76.token_lock); |
| 4426 | + |
| 4427 | + t = idr_find(&dev->mt76.token, dev->dbg.token_idx); |
| 4428 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 4429 | + if (t != NULL) { |
| 4430 | + struct mt76_dev *mdev = &dev->mt76; |
| 4431 | + txwi = ((u8*)(t)) - (mdev->drv->txwi_size); |
| 4432 | + mt7915_dump_tmac_info((u8*) txwi); |
| 4433 | + seq_printf(s, "\n"); |
| 4434 | + printk("[SKB]\n"); |
| 4435 | + print_hex_dump(KERN_ERR , "", DUMP_PREFIX_OFFSET, 16, 1, (u8 *)t->skb->data, t->skb->len, false); |
| 4436 | + seq_printf(s, "\n"); |
| 4437 | + } |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 4438 | + spin_unlock_bh(&dev->mt76.token_lock); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 4439 | + return 0; |
| 4440 | +} |
| 4441 | + |
| 4442 | +static int mt7915_amsduinfo_read(struct seq_file *s, void *data) |
| 4443 | +{ |
| 4444 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4445 | + u32 ple_stat[8] = {0}, total_amsdu = 0; |
| 4446 | + u8 i; |
| 4447 | + |
| 4448 | + for (i = 0; i < 8; i++) |
| 4449 | + ple_stat[i] = mt76_rr(dev, MT_DBG_PLE_AMSDU_PACK_MSDU_CNT(i)); |
| 4450 | + |
| 4451 | + seq_printf(s, "TXD counter status of MSDU:\n"); |
| 4452 | + |
| 4453 | + for (i = 0; i < 8; i++) |
| 4454 | + total_amsdu += ple_stat[i]; |
| 4455 | + |
| 4456 | + for (i = 0; i < 8; i++) { |
| 4457 | + seq_printf(s, "AMSDU pack count of %d MSDU in TXD: 0x%x ", i + 1, ple_stat[i]); |
| 4458 | + if (total_amsdu != 0) |
| 4459 | + seq_printf(s, "(%d%%)\n", ple_stat[i] * 100 / total_amsdu); |
| 4460 | + else |
| 4461 | + seq_printf(s, "\n"); |
| 4462 | + } |
| 4463 | + |
| 4464 | + return 0; |
| 4465 | + |
| 4466 | +} |
| 4467 | + |
| 4468 | +static int mt7915_agginfo_read_per_band(struct seq_file *s, int band_idx) |
| 4469 | +{ |
| 4470 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4471 | + u32 value, idx, agg_rang_sel[15], ampdu_cnt[11], total_ampdu = 0; |
| 4472 | + |
| 4473 | + seq_printf(s, "Band %d AGG Status\n", band_idx); |
| 4474 | + seq_printf(s, "===============================\n"); |
| 4475 | + value = mt76_rr(dev, MT_DBG_AGG_AALCR0(band_idx)); |
| 4476 | + seq_printf(s, "AC00 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value)); |
| 4477 | + seq_printf(s, "AC01 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value)); |
| 4478 | + seq_printf(s, "AC02 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value)); |
| 4479 | + seq_printf(s, "AC03 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value)); |
| 4480 | + |
| 4481 | + value = mt76_rr(dev, MT_DBG_AGG_AALCR1(band_idx)); |
| 4482 | + seq_printf(s, "AC10 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value)); |
| 4483 | + seq_printf(s, "AC11 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value)); |
| 4484 | + seq_printf(s, "AC12 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value)); |
| 4485 | + seq_printf(s, "AC13 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value)); |
| 4486 | + |
| 4487 | + value = mt76_rr(dev, MT_DBG_AGG_AALCR2(band_idx)); |
| 4488 | + seq_printf(s, "AC20 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value)); |
| 4489 | + seq_printf(s, "AC21 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value)); |
| 4490 | + seq_printf(s, "AC22 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value)); |
| 4491 | + seq_printf(s, "AC23 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value)); |
| 4492 | + |
| 4493 | + value = mt76_rr(dev, MT_DBG_AGG_AALCR3(band_idx)); |
| 4494 | + seq_printf(s, "AC30 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx0_AGG_LIMIT_MASK, value)); |
| 4495 | + seq_printf(s, "AC31 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx1_AGG_LIMIT_MASK, value)); |
| 4496 | + seq_printf(s, "AC32 Agg limit = %ld\t", FIELD_GET(MT_DBG_AGG_AALCR_ACx2_AGG_LIMIT_MASK, value)); |
| 4497 | + seq_printf(s, "AC33 Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR_ACx3_AGG_LIMIT_MASK, value)); |
| 4498 | + |
| 4499 | + value = mt76_rr(dev, MT_DBG_AGG_AALCR4(band_idx)); |
| 4500 | + seq_printf(s, "ALTX Agg limit = %ld\n", FIELD_GET(MT_DBG_AGG_AALCR4_ALTX0_AGG_LIMIT_MASK, value)); |
| 4501 | + |
| 4502 | + value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 0)); |
| 4503 | + seq_printf(s, "Winsize0 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE0_MASK, value)); |
| 4504 | + seq_printf(s, "Winsize1 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE1_MASK, value)); |
| 4505 | + seq_printf(s, "Winsize2 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE2_MASK, value)); |
| 4506 | + seq_printf(s, "Winsize3 limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR0_WINSIZE3_MASK, value)); |
| 4507 | + |
| 4508 | + value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 1)); |
| 4509 | + seq_printf(s, "Winsize4 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE4_MASK, value)); |
| 4510 | + seq_printf(s, "Winsize5 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE5_MASK, value)); |
| 4511 | + seq_printf(s, "Winsize6 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE6_MASK, value)); |
| 4512 | + seq_printf(s, "Winsize7 limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR1_WINSIZE7_MASK, value)); |
| 4513 | + |
| 4514 | + value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 2)); |
| 4515 | + seq_printf(s, "Winsize8 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZE8_MASK, value)); |
| 4516 | + seq_printf(s, "Winsize9 limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZE9_MASK, value)); |
| 4517 | + seq_printf(s, "WinsizeA limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZEA_MASK, value)); |
| 4518 | + seq_printf(s, "WinsizeB limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR2_WINSIZEB_MASK, value)); |
| 4519 | + |
| 4520 | + |
| 4521 | + value = mt76_rr(dev, MT_DBG_AGG_AWSCR(band_idx, 3)); |
| 4522 | + seq_printf(s, "WinsizeC limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZEC_MASK, value)); |
| 4523 | + seq_printf(s, "WinsizeD limit = %ld\t", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZED_MASK, value)); |
| 4524 | + seq_printf(s, "WinsizeE limit = %ld\n", FIELD_GET(MT_DBG_AGG_AWSCR3_WINSIZEE_MASK, value)); |
| 4525 | + |
| 4526 | + seq_printf(s, "===AMPDU Related Counters===\n"); |
| 4527 | + |
| 4528 | + value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 0)); |
| 4529 | + agg_rang_sel[0] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL0_MASK, value); |
| 4530 | + agg_rang_sel[1] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL1_MASK, value); |
| 4531 | + agg_rang_sel[2] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL2_MASK, value); |
| 4532 | + agg_rang_sel[3] = FIELD_GET(MT_DBG_MIB_M0ARNG0_AGG_RANG_SEL3_MASK, value); |
| 4533 | + |
| 4534 | + value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 1)); |
| 4535 | + agg_rang_sel[4] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL4_MASK, value); |
| 4536 | + agg_rang_sel[5] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL5_MASK, value); |
| 4537 | + agg_rang_sel[6] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL6_MASK, value); |
| 4538 | + agg_rang_sel[7] = FIELD_GET(MT_DBG_MIB_M0ARNG1_AGG_RANG_SEL7_MASK, value); |
| 4539 | + |
| 4540 | + value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 2)); |
| 4541 | + agg_rang_sel[8] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL8_MASK, value); |
| 4542 | + agg_rang_sel[9] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL9_MASK, value); |
| 4543 | + agg_rang_sel[10] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL10_MASK, value); |
| 4544 | + agg_rang_sel[11] = FIELD_GET(MT_DBG_MIB_M0ARNG2_AGG_RANG_SEL11_MASK, value); |
| 4545 | + |
| 4546 | + value = mt76_rr(dev, MT_DBG_MIB_M0ARNG(band_idx, 3)); |
| 4547 | + agg_rang_sel[12] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL12_MASK, value); |
| 4548 | + agg_rang_sel[13] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL13_MASK, value); |
| 4549 | + agg_rang_sel[14] = FIELD_GET(MT_DBG_MIB_M0ARNG3_AGG_RANG_SEL14_MASK, value); |
| 4550 | + |
| 4551 | + /* Need to add 1 after read from AGG_RANG_SEL CR */ |
| 4552 | + for (idx = 0; idx < 15; idx++) |
| 4553 | + agg_rang_sel[idx]++; |
| 4554 | + |
| 4555 | + ampdu_cnt[3] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 0)); |
| 4556 | + ampdu_cnt[4] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 1)); |
| 4557 | + ampdu_cnt[5] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 2)); |
| 4558 | + ampdu_cnt[6] = mt76_rr(dev, MT_DBG_MIB_M0DR2(band_idx, 3)); |
| 4559 | + ampdu_cnt[7] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 0)); |
| 4560 | + ampdu_cnt[8] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 1)); |
| 4561 | + ampdu_cnt[9] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 2)); |
| 4562 | + ampdu_cnt[10] = mt76_rr(dev, MT_DBG_MIB_M0DR13(band_idx, 3)); |
| 4563 | + |
| 4564 | + seq_printf(s, "\tTx Agg Range: \t%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d \t%d~%d\n", |
| 4565 | + agg_rang_sel[0], |
| 4566 | + agg_rang_sel[0] + 1, agg_rang_sel[1], |
| 4567 | + agg_rang_sel[1] + 1, agg_rang_sel[2], |
| 4568 | + agg_rang_sel[2] + 1, agg_rang_sel[3], |
| 4569 | + agg_rang_sel[3] + 1, agg_rang_sel[4], |
| 4570 | + agg_rang_sel[4] + 1, agg_rang_sel[5], |
| 4571 | + agg_rang_sel[5] + 1, agg_rang_sel[6], |
| 4572 | + agg_rang_sel[6] + 1, agg_rang_sel[7]); |
| 4573 | + |
| 4574 | +#define BIT_0_to_15_MASK 0x0000FFFF |
| 4575 | +#define BIT_15_to_31_MASK 0xFFFF0000 |
| 4576 | +#define SHFIT_16_BIT 16 |
| 4577 | + |
| 4578 | + for (idx = 3; idx < 11; idx++) |
| 4579 | + total_ampdu = total_ampdu + (ampdu_cnt[idx] & BIT_0_to_15_MASK) + ((ampdu_cnt[idx] & BIT_15_to_31_MASK) >> SHFIT_16_BIT); |
| 4580 | + |
| 4581 | + seq_printf(s, "\t\t\t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx\n", |
| 4582 | + (ampdu_cnt[3]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK, |
| 4583 | + FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[3]), |
| 4584 | + (ampdu_cnt[4]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK, |
| 4585 | + FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[4]), |
| 4586 | + (ampdu_cnt[5]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK, |
| 4587 | + FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[5]), |
| 4588 | + (ampdu_cnt[6]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK, |
| 4589 | + FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[6])); |
| 4590 | + |
| 4591 | + if (total_ampdu != 0) { |
| 4592 | + seq_printf(s, "\t\t\t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%)\n", |
| 4593 | + ((ampdu_cnt[3]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK) * 100 / total_ampdu, |
| 4594 | + FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[3]) * 100 / total_ampdu, |
| 4595 | + ((ampdu_cnt[4]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK) * 100 / total_ampdu, |
| 4596 | + FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[4]) * 100 / total_ampdu, |
| 4597 | + ((ampdu_cnt[5]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK) * 100 / total_ampdu, |
| 4598 | + FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[5]) * 100 / total_ampdu, |
| 4599 | + ((ampdu_cnt[6]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK) * 100 / total_ampdu, |
| 4600 | + FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[6]) * 100 / total_ampdu); |
| 4601 | + } |
| 4602 | + |
| 4603 | + seq_printf(s, "\t\t\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~%d\t%d~256\n", |
| 4604 | + agg_rang_sel[7] + 1, agg_rang_sel[8], |
| 4605 | + agg_rang_sel[8] + 1, agg_rang_sel[9], |
| 4606 | + agg_rang_sel[9] + 1, agg_rang_sel[10], |
| 4607 | + agg_rang_sel[10] + 1, agg_rang_sel[11], |
| 4608 | + agg_rang_sel[11] + 1, agg_rang_sel[12], |
| 4609 | + agg_rang_sel[12] + 1, agg_rang_sel[13], |
| 4610 | + agg_rang_sel[13] + 1, agg_rang_sel[14], |
| 4611 | + agg_rang_sel[14] + 1); |
| 4612 | + |
| 4613 | + seq_printf(s, "\t\t\t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx \t0x%lx\n", |
| 4614 | + (ampdu_cnt[7]) & MT_DBG_MIB_M0DR13_TRX_AGG_RANGE8_CNT_MASK, |
| 4615 | + FIELD_GET(MT_DBG_MIB_M0DR13_TRX_AGG_RANGE9_CNT_MASK, ampdu_cnt[7]), |
| 4616 | + (ampdu_cnt[8]) & MT_DBG_MIB_M0DR14_TRX_AGG_RANGE10_CNT_MASK, |
| 4617 | + FIELD_GET(MT_DBG_MIB_M0DR14_TRX_AGG_RANGE11_CNT_MASK, ampdu_cnt[8]), |
| 4618 | + (ampdu_cnt[9]) & MT_DBG_MIB_M0DR15_TRX_AGG_RANGE12_CNT_MASK, |
| 4619 | + FIELD_GET(MT_DBG_MIB_M0DR15_TRX_AGG_RANGE13_CNT_MASK, ampdu_cnt[9]), |
| 4620 | + (ampdu_cnt[10]) & MT_DBG_MIB_M0DR16_TRX_AGG_RANGE14_CNT_MASK, |
| 4621 | + FIELD_GET(MT_DBG_MIB_M0DR16_TRX_AGG_RANGE15_CNT_MASK, ampdu_cnt[10])); |
| 4622 | + |
| 4623 | + if (total_ampdu != 0) { |
| 4624 | + seq_printf(s, "\t\t\t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%) \t(%ld%%)\n", |
| 4625 | + ((ampdu_cnt[7]) & MT_DBG_MIB_M0DR2_TRX_AGG_RANGE0_CNT_MASK) * 100 / total_ampdu, |
| 4626 | + FIELD_GET(MT_DBG_MIB_M0DR2_TRX_AGG_RANGE1_CNT_MASK, ampdu_cnt[7]) * 100 / total_ampdu, |
| 4627 | + ((ampdu_cnt[8]) & MT_DBG_MIB_M0DR3_TRX_AGG_RANGE2_CNT_MASK) * 100 / total_ampdu, |
| 4628 | + FIELD_GET(MT_DBG_MIB_M0DR3_TRX_AGG_RANGE3_CNT_MASK, ampdu_cnt[8]) * 100 / total_ampdu, |
| 4629 | + ((ampdu_cnt[9]) & MT_DBG_MIB_M0DR4_TRX_AGG_RANGE4_CNT_MASK) * 100 / total_ampdu, |
| 4630 | + FIELD_GET(MT_DBG_MIB_M0DR4_TRX_AGG_RANGE5_CNT_MASK, ampdu_cnt[9]) * 100 / total_ampdu, |
| 4631 | + ((ampdu_cnt[10]) & MT_DBG_MIB_M0DR5_TRX_AGG_RANGE6_CNT_MASK) * 100 / total_ampdu, |
| 4632 | + FIELD_GET(MT_DBG_MIB_M0DR5_TRX_AGG_RANGE7_CNT_MASK, ampdu_cnt[10]) * 100 / total_ampdu); |
| 4633 | + } |
| 4634 | + |
| 4635 | + return 0; |
| 4636 | +} |
| 4637 | + |
| 4638 | +static int mt7915_agginfo_read_band0(struct seq_file *s, void *data) |
| 4639 | +{ |
| 4640 | + mt7915_agginfo_read_per_band(s, 0); |
| 4641 | + return 0; |
| 4642 | +} |
| 4643 | + |
| 4644 | +static int mt7915_agginfo_read_band1(struct seq_file *s, void *data) |
| 4645 | +{ |
| 4646 | + mt7915_agginfo_read_per_band(s, 1); |
| 4647 | + return 0; |
| 4648 | +} |
| 4649 | + |
| 4650 | +/*usage: <en> <num> <len> |
| 4651 | + en: BIT(16) 0: sw amsdu 1: hw amsdu |
| 4652 | + num: GENMASK(15, 8) range 1-8 |
| 4653 | + len: GENMASK(7, 0) unit: 256 bytes */ |
| 4654 | +static int mt7915_sta_tx_amsdu_set(void *data, u64 tx_amsdu) |
| 4655 | +{ |
| 4656 | +/* UWTBL DW 6 */ |
| 4657 | +#define WTBL_AMSDU_LEN_MASK GENMASK(5, 0) |
| 4658 | +#define WTBL_AMSDU_NUM_MASK GENMASK(8, 6) |
| 4659 | +#define WTBL_AMSDU_EN_MASK BIT(9) |
| 4660 | +#define UWTBL_HW_AMSDU_DW 6 |
| 4661 | + |
| 4662 | + struct mt7915_dev *dev = data; |
| 4663 | + u32 len = FIELD_GET(GENMASK(7, 0), tx_amsdu); |
| 4664 | + u32 num = FIELD_GET(GENMASK(15, 8), tx_amsdu); |
| 4665 | + u32 uwtbl; |
| 4666 | + |
developer | b1654ad | 2022-09-27 10:30:15 +0800 | [diff] [blame] | 4667 | + mt7915_mcu_set_amsdu_algo(dev, dev->wlan_idx, 0); |
| 4668 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 4669 | + mt7915_wtbl_read_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC, |
| 4670 | + UWTBL_HW_AMSDU_DW, 1, &uwtbl); |
| 4671 | + |
| 4672 | + if (len) { |
| 4673 | + uwtbl &= ~WTBL_AMSDU_LEN_MASK; |
| 4674 | + uwtbl |= FIELD_PREP(WTBL_AMSDU_LEN_MASK, len); |
| 4675 | + } |
| 4676 | + |
| 4677 | + uwtbl &= ~WTBL_AMSDU_NUM_MASK; |
| 4678 | + uwtbl |= FIELD_PREP(WTBL_AMSDU_NUM_MASK, num); |
| 4679 | + |
| 4680 | + if (tx_amsdu & BIT(16)) |
| 4681 | + uwtbl |= WTBL_AMSDU_EN_MASK; |
| 4682 | + |
| 4683 | + mt7915_wtbl_write_raw(dev, dev->wlan_idx, WTBL_TYPE_UMAC, |
| 4684 | + UWTBL_HW_AMSDU_DW, uwtbl); |
| 4685 | + |
| 4686 | + return 0; |
| 4687 | +} |
| 4688 | + |
| 4689 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_tx_amsdu, NULL, |
| 4690 | + mt7915_sta_tx_amsdu_set, "%llx\n"); |
| 4691 | + |
| 4692 | +static int mt7915_red_enable_set(void *data, u64 en) |
| 4693 | +{ |
| 4694 | + struct mt7915_dev *dev = data; |
| 4695 | + |
| 4696 | + return mt7915_mcu_set_red(dev, en); |
| 4697 | +} |
| 4698 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_red_en, NULL, |
| 4699 | + mt7915_red_enable_set, "%llx\n"); |
| 4700 | + |
| 4701 | +static int mt7915_red_show_sta_set(void *data, u64 wlan_idx) |
| 4702 | +{ |
| 4703 | + struct mt7915_dev *dev = data; |
| 4704 | + |
| 4705 | + mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 4706 | + MCU_WA_PARAM_RED_SHOW_STA, |
| 4707 | + wlan_idx, 0, true); |
| 4708 | + |
| 4709 | + return 0; |
| 4710 | +} |
| 4711 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_red_show_sta, NULL, |
| 4712 | + mt7915_red_show_sta_set, "%llx\n"); |
| 4713 | + |
| 4714 | +static int mt7915_red_target_dly_set(void *data, u64 delay) |
| 4715 | +{ |
| 4716 | + struct mt7915_dev *dev = data; |
| 4717 | + |
| 4718 | + if (delay > 0 && delay <= 32767) |
| 4719 | + mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), |
| 4720 | + MCU_WA_PARAM_RED_TARGET_DELAY, |
| 4721 | + delay, 0, true); |
| 4722 | + |
| 4723 | + return 0; |
| 4724 | +} |
| 4725 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_red_target_dly, NULL, |
| 4726 | + mt7915_red_target_dly_set, "%llx\n"); |
| 4727 | + |
| 4728 | +static int |
| 4729 | +mt7915_txpower_level_set(void *data, u64 val) |
| 4730 | +{ |
| 4731 | + struct mt7915_dev *dev = data; |
| 4732 | + struct mt7915_phy *ext_phy = mt7915_ext_phy(dev); |
| 4733 | + mt7915_mcu_set_txpower_level(&dev->phy, val); |
| 4734 | + if (ext_phy) |
| 4735 | + mt7915_mcu_set_txpower_level(ext_phy, val); |
| 4736 | + |
| 4737 | + return 0; |
| 4738 | +} |
| 4739 | + |
| 4740 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_txpower_level, NULL, |
| 4741 | + mt7915_txpower_level_set, "%lld\n"); |
| 4742 | + |
| 4743 | +/* usage: echo 0x[arg3][arg2][arg1] > fw_wa_set */ |
| 4744 | +static int |
| 4745 | +mt7915_wa_set(void *data, u64 val) |
| 4746 | +{ |
| 4747 | + struct mt7915_dev *dev = data; |
| 4748 | + u32 arg1, arg2, arg3; |
| 4749 | + |
| 4750 | + arg1 = FIELD_GET(GENMASK_ULL(7, 0), val); |
| 4751 | + arg2 = FIELD_GET(GENMASK_ULL(15, 8), val); |
| 4752 | + arg3 = FIELD_GET(GENMASK_ULL(23, 16), val); |
| 4753 | + |
| 4754 | + mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(SET), arg1, arg2, arg3, false); |
| 4755 | + |
| 4756 | + return 0; |
| 4757 | +} |
| 4758 | + |
| 4759 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_set, NULL, mt7915_wa_set, |
| 4760 | + "0x%llx\n"); |
| 4761 | +/* usage: echo 0x[arg3][arg2][arg1] > fw_wa_query */ |
| 4762 | +static int |
| 4763 | +mt7915_wa_query(void *data, u64 val) |
| 4764 | +{ |
| 4765 | + struct mt7915_dev *dev = data; |
| 4766 | + u32 arg1, arg2, arg3; |
| 4767 | + |
| 4768 | + arg1 = FIELD_GET(GENMASK_ULL(7, 0), val); |
| 4769 | + arg2 = FIELD_GET(GENMASK_ULL(15, 8), val); |
| 4770 | + arg3 = FIELD_GET(GENMASK_ULL(23, 16), val); |
| 4771 | + |
| 4772 | + mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(QUERY), arg1, arg2, arg3, false); |
| 4773 | + |
| 4774 | + return 0; |
| 4775 | +} |
| 4776 | + |
| 4777 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_query, NULL, mt7915_wa_query, |
| 4778 | + "0x%llx\n"); |
| 4779 | +/* set wa debug level |
| 4780 | + usage: |
| 4781 | + echo 0x[arg] > fw_wa_debug |
| 4782 | + bit0 : DEBUG_WIFI_TX |
| 4783 | + bit1 : DEBUG_CMD_EVENT |
| 4784 | + bit2 : DEBUG_RED |
| 4785 | + bit3 : DEBUG_WARN |
| 4786 | + bit4 : DEBUG_WIFI_RX |
| 4787 | + bit5 : DEBUG_TIME_STAMP |
| 4788 | + bit6 : DEBUG_TX_FREE_DONE_EVENT |
| 4789 | + bit12 : DEBUG_WIFI_TXD */ |
| 4790 | +static int |
| 4791 | +mt7915_wa_debug(void *data, u64 val) |
| 4792 | +{ |
| 4793 | + struct mt7915_dev *dev = data; |
| 4794 | + u32 arg; |
| 4795 | + |
| 4796 | + arg = FIELD_GET(GENMASK_ULL(15, 0), val); |
| 4797 | + |
| 4798 | + mt7915_dbg_mcu_wa_cmd(dev, MCU_WA_PARAM_CMD(DEBUG), arg, 0, 0, false); |
| 4799 | + |
| 4800 | + return 0; |
| 4801 | +} |
| 4802 | + |
| 4803 | +DEFINE_DEBUGFS_ATTRIBUTE(fops_wa_debug, NULL, mt7915_wa_debug, |
| 4804 | + "0x%llx\n"); |
| 4805 | + |
developer | 6770571 | 2023-05-30 11:58:00 +0800 | [diff] [blame] | 4806 | +static int mt7915_dump_version(struct seq_file *s, void *data) |
| 4807 | +{ |
| 4808 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4809 | + struct mt76_dev *mdev = NULL; |
developer | c879603 | 2023-08-09 10:28:15 +0800 | [diff] [blame] | 4810 | + seq_printf(s, "Version: 2.2.13.0\n"); |
developer | 6770571 | 2023-05-30 11:58:00 +0800 | [diff] [blame] | 4811 | + |
| 4812 | + if (!test_bit(MT76_STATE_MCU_RUNNING, &dev->mphy.state)) |
| 4813 | + return 0; |
| 4814 | + |
| 4815 | + mdev = &dev->mt76; |
| 4816 | + seq_printf(s, "Rom Patch Build Time: %.16s\n", mdev->patch_hdr->build_date); |
| 4817 | + seq_printf(s, "WM Patch Build Time: %.16s\n", mdev->wm_hdr->build_date); |
| 4818 | + seq_printf(s, "WA Patch Build Time: %.16s\n", mdev->wa_hdr->build_date); |
| 4819 | + return 0; |
| 4820 | +} |
| 4821 | + |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 4822 | +static inline int mt7915_snprintf_error(size_t size, int res) |
| 4823 | +{ |
| 4824 | + return res < 0 || (unsigned int) res >= size; |
| 4825 | +} |
| 4826 | + |
| 4827 | +static void mt7915_show_lp_history(struct seq_file *s, bool fgIsExp) |
| 4828 | +{ |
| 4829 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4830 | + u32 macVal = 0, gpr_log_idx = 0, oldest_idx = 0; |
| 4831 | + u32 idx = 0, i = 0; |
| 4832 | + |
| 4833 | + if (!fgIsExp) { |
| 4834 | + /* disable LP recored */ |
| 4835 | + macVal = mt76_rr(dev, 0x89050200); |
| 4836 | + macVal &= (~0x1); |
| 4837 | + mt76_wr(dev, 0x89050200, macVal); |
| 4838 | + udelay(100); |
| 4839 | + } |
| 4840 | + |
| 4841 | + macVal = 0; |
| 4842 | + macVal = mt76_rr(dev, 0x89050200); |
| 4843 | + gpr_log_idx = ((macVal >> 16) & 0x1f); |
| 4844 | + oldest_idx = gpr_log_idx + 2; |
| 4845 | + |
| 4846 | + seq_printf(s, " lp history (from old to new):\n"); |
| 4847 | + for (i = 0; i < 16; i++) { |
| 4848 | + idx = ((oldest_idx + 2*i + 1)%32); |
| 4849 | + macVal = mt76_rr(dev, (0x89050204 + idx*4)); |
| 4850 | + seq_printf(s, " %d: 0x%x\n", i, macVal); |
| 4851 | + } |
| 4852 | + |
| 4853 | + if (!fgIsExp) { |
| 4854 | + /* enable LP recored */ |
| 4855 | + macVal = mt76_rr(dev, 0x89050200); |
| 4856 | + macVal |= 0x1; |
| 4857 | + mt76_wr(dev, 0x89050200, macVal); |
| 4858 | + } |
| 4859 | +} |
| 4860 | + |
| 4861 | +static void mt7915_show_irq_history(struct seq_file *s) |
| 4862 | +{ |
| 4863 | +#define SYSIRQ_INTERRUPT_HISTORY_NUM 10 |
| 4864 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4865 | + u32 macVal = 0; |
| 4866 | + u32 i = 0; |
| 4867 | + u32 start = 0; |
| 4868 | + u32 idx = 0; |
| 4869 | + u8 ucIrqDisIdx = 0; |
| 4870 | + u8 ucIrqResIdx = 0; |
| 4871 | + u32 irq_dis_time[10]; |
| 4872 | + u32 irq_dis_lp[10]; |
| 4873 | + u32 irq_res_time[10]; |
| 4874 | + u32 irq_res_lp[10]; |
| 4875 | + |
| 4876 | + macVal = 0; |
| 4877 | + macVal = mt76_rr(dev, 0x022051C0); |
| 4878 | + ucIrqResIdx = (macVal & 0xff); |
| 4879 | + ucIrqDisIdx = ((macVal >> 8) & 0xff); |
| 4880 | + |
| 4881 | + seq_printf(s, "\n\n\n Irq Idx (Dis=%d Res=%d):\n", |
| 4882 | + ucIrqDisIdx, ucIrqResIdx); |
| 4883 | + |
| 4884 | + start = mt76_rr(dev, 0x022051C8); |
| 4885 | + for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) { |
| 4886 | + macVal = mt76_rr(dev, (start + (i * 8))); |
| 4887 | + irq_dis_time[i] = macVal; |
| 4888 | + macVal = mt76_rr(dev, (start + (i * 8) + 4)); |
| 4889 | + irq_dis_lp[i] = macVal; |
| 4890 | + } |
| 4891 | + |
| 4892 | + start = mt76_rr(dev, 0x022051C4); |
| 4893 | + |
| 4894 | + for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) { |
| 4895 | + macVal = mt76_rr(dev, (start + (i * 8))); |
| 4896 | + irq_res_time[i] = macVal; |
| 4897 | + macVal = mt76_rr(dev, (start + (i * 8) + 4)); |
| 4898 | + irq_res_lp[i] = macVal; |
| 4899 | + } |
| 4900 | + |
| 4901 | + seq_printf(s, "\n Dis Irq history (from old to new):\n"); |
| 4902 | + for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) { |
| 4903 | + idx = (i + ucIrqDisIdx) % SYSIRQ_INTERRUPT_HISTORY_NUM; |
| 4904 | + seq_printf(s, " [%d].LP = 0x%x time=%u\n", |
| 4905 | + idx, irq_dis_lp[idx], irq_dis_time[idx]); |
| 4906 | + } |
| 4907 | + |
| 4908 | + seq_printf(s, "\n Restore Irq history (from old to new):\n"); |
| 4909 | + for (i = 0; i < SYSIRQ_INTERRUPT_HISTORY_NUM; i++) { |
| 4910 | + idx = (i + ucIrqResIdx) % SYSIRQ_INTERRUPT_HISTORY_NUM; |
| 4911 | + seq_printf(s, " [%d].LP = 0x%x time=%u\n", |
| 4912 | + idx, irq_res_lp[idx], irq_res_time[idx]); |
| 4913 | + } |
| 4914 | +} |
| 4915 | + |
| 4916 | +static void MemSectionRead(struct mt7915_dev *dev, char *buf, u32 length, u32 addr) |
| 4917 | +{ |
| 4918 | + int idx = 0; |
| 4919 | + u32 *ptr =(u32 *)buf; |
| 4920 | + |
| 4921 | + while (idx < length) { |
| 4922 | + *ptr = mt76_rr(dev, (addr + idx)); |
| 4923 | + idx += 4; |
| 4924 | + ptr++; |
| 4925 | + } |
| 4926 | +} |
| 4927 | + |
| 4928 | +static void mt7915_show_msg_trace(struct seq_file *s) |
| 4929 | +{ |
| 4930 | +#define MSG_HISTORY_NUM 64 |
| 4931 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4932 | + struct cos_msg_trace_t *msg_trace = NULL; |
| 4933 | + u32 ptr_addr = 0; |
| 4934 | + u32 length = 0; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 4935 | + u32 idx = 0; |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 4936 | + u32 cnt = 0; |
| 4937 | + u32 msg_history_num = 0; |
| 4938 | + |
| 4939 | + msg_trace = kmalloc(MSG_HISTORY_NUM * sizeof(struct cos_msg_trace_t), GFP_KERNEL); |
| 4940 | + if (!msg_trace) { |
| 4941 | + seq_printf(s, "can not allocate cmd msg_trace\n"); |
| 4942 | + return; |
| 4943 | + } |
| 4944 | + |
| 4945 | + memset(msg_trace, 0, MSG_HISTORY_NUM * sizeof(struct cos_msg_trace_t)); |
| 4946 | + |
| 4947 | + ptr_addr = mt76_rr(dev, 0x02205188); |
| 4948 | + msg_history_num = mt76_rr(dev, 0x0220518C); |
| 4949 | + |
| 4950 | + idx = (msg_history_num >> 8) & 0xff; |
| 4951 | + msg_history_num = msg_history_num & 0xff; |
| 4952 | + |
| 4953 | + if (idx >= msg_history_num) { |
| 4954 | + kfree(msg_trace); |
| 4955 | + return; |
| 4956 | + } |
| 4957 | + |
| 4958 | + length = msg_history_num * sizeof(struct cos_msg_trace_t); |
| 4959 | + MemSectionRead(dev, (char *)&(msg_trace[0]), length, ptr_addr); |
| 4960 | + seq_printf(s,"\n"); |
| 4961 | + seq_printf(s, " msg trace:\n"); |
| 4962 | + seq_printf(s, " format: t_id=task_id/task_prempt_cnt/msg_read_idx\n"); |
| 4963 | + |
| 4964 | + while (1) { |
| 4965 | + seq_printf(s, " (m_%d)t_id=%x/%d/%d, m_id=%d, ts_en=%u, ts_de = %u, ts_fin=%u, wait=%d, exe=%d\n", |
| 4966 | + idx, |
| 4967 | + msg_trace[idx].dest_id, |
| 4968 | + msg_trace[idx].pcount, |
| 4969 | + msg_trace[idx].qread, |
| 4970 | + msg_trace[idx].msg_id, |
| 4971 | + msg_trace[idx].ts_enq, |
| 4972 | + msg_trace[idx].ts_deq, |
| 4973 | + msg_trace[idx].ts_finshq, |
| 4974 | + (msg_trace[idx].ts_deq - msg_trace[idx].ts_enq), |
| 4975 | + (msg_trace[idx].ts_finshq - msg_trace[idx].ts_deq)); |
| 4976 | + |
| 4977 | + if (++idx >= msg_history_num) |
| 4978 | + idx = 0; |
| 4979 | + |
| 4980 | + if (++cnt >= msg_history_num) |
| 4981 | + break; |
| 4982 | + } |
| 4983 | + if (msg_trace) |
| 4984 | + kfree(msg_trace); |
| 4985 | +} |
| 4986 | + |
| 4987 | +static int mt7915_show_assert_line(struct seq_file *s) |
| 4988 | +{ |
| 4989 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 4990 | + char *msg; |
| 4991 | + u32 addr; |
| 4992 | + u32 macVal = 0; |
| 4993 | + char *ptr; |
| 4994 | + char idx; |
| 4995 | + |
| 4996 | + msg = kmalloc(256, GFP_KERNEL); |
| 4997 | + if (!msg) |
| 4998 | + return 0; |
| 4999 | + |
| 5000 | + memset(msg, 0, 256); |
| 5001 | + addr = 0x00400000; |
| 5002 | + ptr = msg; |
| 5003 | + for (idx = 0 ; idx < 32; idx++) { |
| 5004 | + macVal = 0; |
| 5005 | + macVal = mt76_rr(dev, addr); |
| 5006 | + memcpy(ptr, &macVal, 4); |
| 5007 | + addr += 4; |
| 5008 | + ptr += 4; |
| 5009 | + } |
| 5010 | + |
| 5011 | + *ptr = 0; |
| 5012 | + seq_printf(s,"\n\n"); |
| 5013 | + seq_printf(s," Assert line\n"); |
| 5014 | + seq_printf(s," %s\n", msg); |
| 5015 | + if (msg) |
| 5016 | + kfree(msg); |
| 5017 | + |
| 5018 | + return 0; |
| 5019 | +} |
| 5020 | + |
| 5021 | + |
| 5022 | +static void mt7915_show_sech_trace(struct seq_file *s) |
| 5023 | +{ |
| 5024 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 5025 | + struct cos_task_info_struct task_info_g[2]; |
| 5026 | + u32 length = 0, i = 0; |
| 5027 | + u32 idx = 0; |
| 5028 | + u32 km_total_time = 0; |
| 5029 | + u32 addr = 0; |
| 5030 | + struct cos_task_type tcb; |
| 5031 | + struct cos_task_type *tcb_ptr; |
| 5032 | + char name[2][15] = { |
| 5033 | + "WIFI ", "WIFI2 " |
| 5034 | + }; |
| 5035 | + |
| 5036 | + length = 2 * sizeof(struct cos_task_info_struct); |
| 5037 | + MemSectionRead(dev, (char *)&(task_info_g[0]), length, 0x02202A18); |
| 5038 | + |
| 5039 | + /*while(i < length) { |
| 5040 | + task_info_g[i] = mt76_rr(dev, 0x02202A18 + i * 0x4); |
| 5041 | + i++; |
| 5042 | + }*/ |
| 5043 | + km_total_time = mt76_rr(dev, 0x022051B4); |
| 5044 | + if (km_total_time == 0) { |
| 5045 | + seq_printf(s, "km_total_time zero!\n"); |
| 5046 | + return; |
| 5047 | + } |
| 5048 | + |
| 5049 | + seq_printf(s,"\n\n\n TASK XTIME RATIO PREMPT CNT\n"); |
| 5050 | + for (idx = 0 ; idx < 2 ; idx++) { |
| 5051 | + addr = task_info_g[idx].task_id; |
| 5052 | + i = 0; |
| 5053 | + MemSectionRead(dev, (char *)&(tcb), sizeof(struct cos_task_type), addr); |
| 5054 | + |
| 5055 | + length = sizeof(struct cos_task_type); |
| 5056 | + |
| 5057 | + tcb_ptr = &(tcb); |
| 5058 | + |
| 5059 | + if (tcb_ptr) { |
| 5060 | + seq_printf(s, " %s %d %d %d\n", |
| 5061 | + name[idx], |
| 5062 | + tcb_ptr->tc_exe_time, |
| 5063 | + (tcb_ptr->tc_exe_time*100/km_total_time), |
| 5064 | + tcb_ptr->tc_pcount); |
| 5065 | + } |
| 5066 | + } |
| 5067 | + |
| 5068 | +} |
| 5069 | + |
| 5070 | +static void mt7915_show_prog_trace(struct seq_file *s) |
| 5071 | +{ |
| 5072 | +#define PROGRAM_TRACE_HISTORY_NUM 32 |
| 5073 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 5074 | + struct cos_program_trace_t *cos_program_trace_ptr = NULL; |
| 5075 | + u32 trace_ptr = 0; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 5076 | + u32 idx = 0; |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 5077 | + u32 old_idx = 0; |
| 5078 | + u32 old_idx_addr = 0; |
| 5079 | + u32 prev_idx = 0; |
| 5080 | + u32 prev_time = 0; |
| 5081 | + u32 curr_time = 0; |
| 5082 | + u32 diff = 0; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 5083 | + //u32 length = 0, i = 0; |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 5084 | + |
| 5085 | + cos_program_trace_ptr = kmalloc(PROGRAM_TRACE_HISTORY_NUM * sizeof(struct cos_program_trace_t), GFP_KERNEL); |
| 5086 | + if (!cos_program_trace_ptr) { |
| 5087 | + seq_printf(s, "can not allocate cos_program_trace_ptr memory\n"); |
| 5088 | + return; |
| 5089 | + } |
| 5090 | + memset(cos_program_trace_ptr, 0, PROGRAM_TRACE_HISTORY_NUM * sizeof(struct cos_program_trace_t)); |
| 5091 | + |
| 5092 | + trace_ptr = mt76_rr(dev, 0x0220514C); |
| 5093 | + old_idx_addr = mt76_rr(dev, 0x02205148); |
| 5094 | + |
| 5095 | + old_idx = (old_idx_addr >> 8) & 0xff; |
| 5096 | + |
| 5097 | + MemSectionRead(dev, (char *)&cos_program_trace_ptr[0], PROGRAM_TRACE_HISTORY_NUM * sizeof(struct cos_program_trace_t), trace_ptr); |
| 5098 | + |
| 5099 | + /*length = PROGRAM_TRACE_HISTORY_NUM * sizeof(struct cos_program_trace_t); |
| 5100 | + while(i < length) { |
| 5101 | + cos_program_trace_ptr[i] = mt76_rr(dev, trace_ptr + i * 0x4); |
| 5102 | + i++; |
| 5103 | + }*/ |
| 5104 | + seq_printf(s, "\n"); |
| 5105 | + seq_printf(s, " program trace:\n"); |
| 5106 | + for (idx = 0 ; idx < PROGRAM_TRACE_HISTORY_NUM ; idx++) { |
| 5107 | + prev_idx = ((old_idx + 32 - 1) % 32); |
| 5108 | + |
| 5109 | + seq_printf(s, " (p_%d)t_id=%x/%d, m_id=%d, LP=0x%x, name=%s, ts2=%d, ", |
| 5110 | + old_idx, |
| 5111 | + cos_program_trace_ptr[old_idx].dest_id, |
| 5112 | + cos_program_trace_ptr[old_idx].msg_sn, |
| 5113 | + cos_program_trace_ptr[old_idx].msg_id, |
| 5114 | + cos_program_trace_ptr[old_idx].LP, |
| 5115 | + cos_program_trace_ptr[old_idx].name, |
| 5116 | + cos_program_trace_ptr[old_idx].ts_gpt2); |
| 5117 | + |
| 5118 | + /* diff for gpt2 */ |
| 5119 | + prev_time = cos_program_trace_ptr[prev_idx].ts_gpt2; |
| 5120 | + curr_time = cos_program_trace_ptr[old_idx].ts_gpt2; |
| 5121 | + |
| 5122 | + if (prev_time) { |
| 5123 | + if ((cos_program_trace_ptr[prev_idx].dest_id == cos_program_trace_ptr[old_idx].dest_id) && |
| 5124 | + (cos_program_trace_ptr[prev_idx].msg_sn == cos_program_trace_ptr[old_idx].msg_sn)) { |
| 5125 | + if (curr_time > prev_time) |
| 5126 | + diff = curr_time - prev_time; |
| 5127 | + else |
| 5128 | + diff = 0xFFFFFFFF - prev_time + curr_time + 1; |
| 5129 | + } else |
| 5130 | + diff = 0xFFFFFFFF; |
| 5131 | + } else |
| 5132 | + diff = 0xFFFFFFFF; |
| 5133 | + |
| 5134 | + if (diff == 0xFFFFFFFF) |
| 5135 | + seq_printf(s, "diff2=NA, \n"); |
| 5136 | + else |
| 5137 | + seq_printf(s, "diff2=%8d\n", diff); |
| 5138 | + |
| 5139 | + old_idx++; |
| 5140 | + if (old_idx >= 32) |
| 5141 | + old_idx = 0; |
| 5142 | + } |
| 5143 | + if (cos_program_trace_ptr) |
| 5144 | + kfree(cos_program_trace_ptr); |
| 5145 | +} |
| 5146 | + |
| 5147 | +static int mt7915_fw_wm_info_read(struct seq_file *s, void *data) |
| 5148 | +{ |
| 5149 | + struct mt7915_dev *dev = dev_get_drvdata(s->private); |
| 5150 | + u32 macVal = 0, g_exp_type = 0, COS_Interrupt_Count = 0; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 5151 | + u8 exp_assert_proc_entry_cnt = 0, exp_assert_state = 0, g_irq_history_num = 0; |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 5152 | + u16 processing_irqx = 0; |
| 5153 | + u32 processing_lisr = 0, Current_Task_Id = 0, Current_Task_Indx = 0; |
| 5154 | + u8 km_irq_info_idx = 0, km_eint_info_idx = 0, km_sched_info_idx = 0, g_sched_history_num = 0; |
| 5155 | + u32 km_sched_trace_ptr = 0,km_irq_trace_ptr = 0, km_total_time = 0, TaskStart[3] = {0}; |
| 5156 | + bool fgIsExp = false, fgIsAssert = false; |
| 5157 | + u32 TaskEnd[3] = {0}, exp_assert_state_addr = 0, g1_exp_counter_addr = 0; |
| 5158 | + u32 g_exp_type_addr = 0, cos_interrupt_count_addr = 0; |
| 5159 | + u32 processing_irqx_addr = 0, processing_lisr_addr = 0; |
| 5160 | + u32 Current_Task_Id_addr = 0, Current_Task_Indx_addr = 0, last_dequeued_msg_id_addr = 0; |
| 5161 | + u32 km_irq_info_idx_addr = 0, km_eint_info_idx_addr = 0, km_sched_info_idx_addr = 0; |
| 5162 | + u32 g_sched_history_num_addr = 0, km_sched_trace_ptr_addr = 0; |
| 5163 | + u32 km_irq_trace_ptr_addr = 0, km_total_time_addr = 0, last_dequeued_msg_id = 0; |
| 5164 | + u32 i = 0 ,t1 = 0, t2 = 0, t3 = 0; |
developer | 47efbdb | 2023-06-29 20:33:22 +0800 | [diff] [blame] | 5165 | + u8 idx = 0, str[32], exp_type[64]; |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 5166 | + int ret; |
| 5167 | + |
| 5168 | + g_exp_type_addr = 0x022050DC; |
| 5169 | + exp_assert_state_addr = 0x02204B54; |
| 5170 | + g1_exp_counter_addr = 0x02204FFC; |
| 5171 | + cos_interrupt_count_addr = 0x022001AC; |
| 5172 | + processing_irqx_addr = 0x02204EC4; |
| 5173 | + processing_lisr_addr = 0x02205010; |
| 5174 | + Current_Task_Id_addr = 0x02204FAC; |
| 5175 | + Current_Task_Indx_addr = 0x02204F4C; |
| 5176 | + last_dequeued_msg_id_addr = 0x02204F28; |
| 5177 | + km_irq_info_idx_addr = 0x0220519C; |
| 5178 | + km_eint_info_idx_addr = 0x02205194; |
| 5179 | + km_sched_info_idx_addr = 0x022051A4; |
| 5180 | + g_sched_history_num_addr = 0x022051A4; |
| 5181 | + km_sched_trace_ptr_addr = 0x022051A0; |
| 5182 | + km_irq_trace_ptr_addr = 0x02205198; |
| 5183 | + km_total_time_addr = 0x022051B4; |
| 5184 | + |
| 5185 | + macVal = 0; |
| 5186 | + macVal = mt76_rr(dev, exp_assert_state_addr); |
| 5187 | + exp_assert_state = (macVal & 0xff); |
| 5188 | + |
| 5189 | + macVal = 0; |
| 5190 | + macVal = mt76_rr(dev, g1_exp_counter_addr); |
| 5191 | + exp_assert_proc_entry_cnt = (macVal & 0xff); |
| 5192 | + |
| 5193 | + macVal = 0; |
| 5194 | + macVal = mt76_rr(dev, g_exp_type_addr); |
| 5195 | + g_exp_type = macVal; |
| 5196 | + |
| 5197 | + macVal = 0; |
| 5198 | + macVal = mt76_rr(dev, cos_interrupt_count_addr); |
| 5199 | + COS_Interrupt_Count = macVal; |
| 5200 | + |
| 5201 | + macVal = 0; |
| 5202 | + macVal = mt76_rr(dev, processing_irqx_addr); |
| 5203 | + processing_irqx = (macVal & 0xffff); |
| 5204 | + |
| 5205 | + macVal = 0; |
| 5206 | + macVal = mt76_rr(dev, processing_lisr_addr); |
| 5207 | + processing_lisr = macVal; |
| 5208 | + |
| 5209 | + macVal = 0; |
| 5210 | + macVal = mt76_rr(dev, Current_Task_Id_addr); |
| 5211 | + Current_Task_Id = macVal; |
| 5212 | + |
| 5213 | + macVal = 0; |
| 5214 | + macVal = mt76_rr(dev, Current_Task_Indx_addr); |
| 5215 | + Current_Task_Indx = macVal; |
| 5216 | + |
| 5217 | + macVal = 0; |
| 5218 | + macVal = mt76_rr(dev, last_dequeued_msg_id_addr); |
| 5219 | + last_dequeued_msg_id = macVal; |
| 5220 | + |
| 5221 | + macVal = 0; |
| 5222 | + macVal = mt76_rr(dev, km_eint_info_idx_addr); |
| 5223 | + km_eint_info_idx = ((macVal >> 8) & 0xff); |
| 5224 | + |
| 5225 | + macVal = 0; |
| 5226 | + macVal = mt76_rr(dev, g_sched_history_num_addr); |
| 5227 | + g_sched_history_num = (macVal & 0xff); |
| 5228 | + km_sched_info_idx = ((macVal >> 8) & 0xff); |
| 5229 | + |
| 5230 | + macVal = 0; |
| 5231 | + macVal = mt76_rr(dev, km_sched_trace_ptr_addr); |
| 5232 | + km_sched_trace_ptr = macVal; |
| 5233 | + |
| 5234 | + macVal = 0; |
| 5235 | + macVal = mt76_rr(dev, km_irq_info_idx_addr); |
| 5236 | + g_irq_history_num = (macVal & 0xff); |
| 5237 | + km_irq_info_idx = ((macVal >> 16) & 0xff); |
| 5238 | + |
| 5239 | + macVal = 0; |
| 5240 | + macVal = mt76_rr(dev, km_irq_trace_ptr_addr); |
| 5241 | + km_irq_trace_ptr = macVal; |
| 5242 | + |
| 5243 | + macVal = 0; |
| 5244 | + macVal = mt76_rr(dev, km_total_time_addr); |
| 5245 | + km_total_time = macVal; |
| 5246 | + |
| 5247 | + TaskStart[0] = mt76_rr(dev, 0x02202814); |
| 5248 | + TaskEnd[0] = mt76_rr(dev, 0x02202810); |
| 5249 | + TaskStart[1] = mt76_rr(dev, 0x02202984); |
| 5250 | + TaskEnd[1] = mt76_rr(dev, 0x02202980); |
| 5251 | + |
| 5252 | + seq_printf(s, "================FW DBG INFO===================\n"); |
| 5253 | + seq_printf(s, " exp_assert_proc_entry_cnt = 0x%x\n", |
| 5254 | + exp_assert_proc_entry_cnt); |
| 5255 | + seq_printf(s, " exp_assert_state = 0x%x\n", |
| 5256 | + exp_assert_state); |
| 5257 | + |
| 5258 | + if (exp_assert_proc_entry_cnt == 0) { |
| 5259 | + ret = snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Normal"); |
| 5260 | + if (mt7915_snprintf_error(sizeof(exp_type), ret)) { |
| 5261 | + seq_printf(s, " exp_type Snprintf failed!\n"); |
| 5262 | + return 0; |
| 5263 | + } |
| 5264 | + } else if (exp_assert_proc_entry_cnt == 1 && |
| 5265 | + exp_assert_state > 1 && g_exp_type == 5) { |
| 5266 | + ret = snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Assert"); |
| 5267 | + if (mt7915_snprintf_error(sizeof(exp_type), ret)) { |
| 5268 | + seq_printf(s, " exp_type Snprintf failed!\n"); |
| 5269 | + return 0; |
| 5270 | + } |
| 5271 | + fgIsExp = true; |
| 5272 | + fgIsAssert = true; |
| 5273 | + } else if (exp_assert_proc_entry_cnt == 1 && exp_assert_state > 1) { |
| 5274 | + ret = snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Exception"); |
| 5275 | + if (mt7915_snprintf_error(sizeof(exp_type), ret)) { |
| 5276 | + seq_printf(s, " exp_type Snprintf failed!\n"); |
| 5277 | + return 0; |
| 5278 | + } |
| 5279 | + fgIsExp = true; |
| 5280 | + } else if (exp_assert_proc_entry_cnt > 1) { |
| 5281 | + ret = snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Exception re-entry"); |
| 5282 | + if (mt7915_snprintf_error(sizeof(exp_type), ret)) { |
| 5283 | + seq_printf(s, " exp_type Snprintf failed!\n"); |
| 5284 | + return 0; |
| 5285 | + } |
| 5286 | + fgIsExp = true; |
| 5287 | + } else { |
| 5288 | + ret = snprintf(exp_type, sizeof(exp_type), "%s", "exp_type : Unknown'?"); |
| 5289 | + if (mt7915_snprintf_error(sizeof(exp_type), ret)) { |
| 5290 | + seq_printf(s, " exp_type Snprintf failed!\n"); |
| 5291 | + return 0; |
| 5292 | + } |
| 5293 | + } |
| 5294 | + |
| 5295 | + seq_printf(s, " COS_Interrupt_Count = 0x%x\n", COS_Interrupt_Count); |
| 5296 | + seq_printf(s, " processing_irqx = 0x%x\n", processing_irqx); |
| 5297 | + seq_printf(s, " processing_lisr = 0x%x\n", processing_lisr); |
| 5298 | + seq_printf(s, " Current_Task_Id = 0x%x\n", Current_Task_Id); |
| 5299 | + seq_printf(s, " Current_Task_Indx = 0x%x\n", Current_Task_Indx); |
| 5300 | + seq_printf(s, " last_dequeued_msg_id = %d\n", last_dequeued_msg_id); |
| 5301 | + |
| 5302 | + seq_printf(s, " km_irq_info_idx = 0x%x\n", km_irq_info_idx); |
| 5303 | + seq_printf(s, " km_eint_info_idx = 0x%x\n", km_eint_info_idx); |
| 5304 | + seq_printf(s, " km_sched_info_idx = 0x%x\n", km_sched_info_idx); |
| 5305 | + seq_printf(s, " g_sched_history_num = %d\n", g_sched_history_num); |
| 5306 | + seq_printf(s, " km_sched_trace_ptr = 0x%x\n", km_sched_trace_ptr); |
| 5307 | + |
| 5308 | + if (fgIsExp) { |
| 5309 | + seq_printf(s, "\n <1>print sched trace\n"); |
| 5310 | + if (g_sched_history_num > 60) |
| 5311 | + g_sched_history_num = 60; |
| 5312 | + |
| 5313 | + idx = km_sched_info_idx; |
| 5314 | + for (i = 0 ; i < g_sched_history_num ; i++) { |
| 5315 | + t1 = mt76_rr(dev, (km_sched_trace_ptr+(idx*12))); |
| 5316 | + t2 = mt76_rr(dev, (km_sched_trace_ptr+(idx*12)+4)); |
| 5317 | + t3 = mt76_rr(dev, (km_sched_trace_ptr+(idx*12)+8)); |
| 5318 | + seq_printf(s, " (sched_info_%d)sched_t=0x%x, sched_start=%d, PC=0x%x\n", |
| 5319 | + idx, t1, t2, t3); |
| 5320 | + idx++; |
| 5321 | + if (idx >= g_sched_history_num) |
| 5322 | + idx = 0; |
| 5323 | + } |
| 5324 | + |
| 5325 | + seq_printf(s, "\n <2>print irq trace\n"); |
| 5326 | + if (g_irq_history_num > 60) |
| 5327 | + g_irq_history_num = 60; |
| 5328 | + |
| 5329 | + idx = km_irq_info_idx; |
| 5330 | + for (i = 0 ; i < g_irq_history_num ; i++) { |
| 5331 | + t1 = mt76_rr(dev, (km_irq_trace_ptr+(idx*16))); |
| 5332 | + t2 = mt76_rr(dev, (km_irq_trace_ptr+(idx*16) + 4)); |
| 5333 | + seq_printf(s, " (irq_info_%d)irq_t=%x, sched_start=%d\n", |
| 5334 | + idx, t1, t2); |
| 5335 | + idx++; |
| 5336 | + if (idx >= g_irq_history_num) |
| 5337 | + idx = 0; |
| 5338 | + } |
| 5339 | + } |
| 5340 | + |
| 5341 | + seq_printf(s, "\n <3>task q_id.read q_id.write\n"); |
| 5342 | + seq_printf(s, " (WIFI )1 0x%x 0x%x\n", TaskStart[0], TaskEnd[0]); |
| 5343 | + seq_printf(s, " (WIFI2 )2 0x%x 0x%x\n", TaskStart[1], TaskEnd[1]); |
| 5344 | + seq_printf(s, "\n <4>TASK STACK INFO (size in byte)\n"); |
| 5345 | + seq_printf(s, " TASK START END SIZE PEAK INTEGRITY\n"); |
| 5346 | + |
| 5347 | + for (i = 0 ; i < 2 ; i++) { |
| 5348 | + t1 = mt76_rr(dev, 0x022027B8+(i*368)); |
| 5349 | + t2 = mt76_rr(dev, 0x022027BC+(i*368)); |
| 5350 | + t3 = mt76_rr(dev, 0x022027C4+(i*368)); |
| 5351 | + |
| 5352 | + if (i == 0) { |
| 5353 | + ret = snprintf(str, sizeof(str), "%s", "WIFI"); |
| 5354 | + if (mt7915_snprintf_error(sizeof(str), ret)) { |
| 5355 | + seq_printf(s, " str Snprintf failed!\n"); |
| 5356 | + return 0; |
| 5357 | + } |
| 5358 | + } else if (i == 1) { |
| 5359 | + ret = snprintf(str, sizeof(str), "%s", "WIFI2"); |
| 5360 | + if (mt7915_snprintf_error(sizeof(str), ret)) { |
| 5361 | + seq_printf(s, " str Snprintf failed!\n"); |
| 5362 | + return 0; |
| 5363 | + } |
| 5364 | + } |
| 5365 | + |
| 5366 | + seq_printf(s, " %s 0x%x 0x%x %d\n", |
| 5367 | + str, t1, t2, t3); |
| 5368 | + } |
| 5369 | + |
| 5370 | + seq_printf(s, "\n <5>fw state\n"); |
| 5371 | + seq_printf(s, " %s\n", exp_type); |
| 5372 | + if (COS_Interrupt_Count > 0) |
| 5373 | + seq_printf(s, " FW in Interrupt CIRQ index (0x%x) CIRQ handler(0x%x)\n" |
| 5374 | + , processing_irqx, processing_lisr); |
| 5375 | + else { |
| 5376 | + if (Current_Task_Id == 0 && Current_Task_Indx == 3) |
| 5377 | + seq_printf(s, " FW in IDLE\n"); |
| 5378 | + |
| 5379 | + if (Current_Task_Id != 0 && Current_Task_Indx != 3) |
| 5380 | + seq_printf(s, " FW in Task , Task id(0x%x) Task index(0x%x)\n", |
| 5381 | + Current_Task_Id, Current_Task_Indx); |
| 5382 | + } |
| 5383 | + |
| 5384 | + macVal = 0; |
| 5385 | + macVal= mt76_rr(dev, g1_exp_counter_addr); |
| 5386 | + seq_printf(s, " EXCP_CNT = 0x%x\n", macVal); |
| 5387 | + |
| 5388 | + seq_printf(s, " EXCP_TYPE = 0x%x\n", g_exp_type); |
| 5389 | + |
| 5390 | + macVal = 0; |
| 5391 | + macVal = mt76_rr(dev, 0x022050E0); |
| 5392 | + seq_printf(s, " CPU_ITYPE = 0x%x\n", macVal); |
| 5393 | + |
| 5394 | + macVal = 0; |
| 5395 | + macVal = mt76_rr(dev, 0x022050E8); |
| 5396 | + seq_printf(s, " CPU_EVA = 0x%x\n", macVal); |
| 5397 | + |
| 5398 | + macVal = 0; |
| 5399 | + macVal = mt76_rr(dev, 0x022050E4); |
| 5400 | + seq_printf(s, " CPU_IPC = 0x%x\n", macVal); |
| 5401 | + |
| 5402 | + macVal = 0; |
| 5403 | + macVal = mt76_rr(dev, 0x7C060204); |
| 5404 | + seq_printf(s, " PC = 0x%x\n\n\n", macVal); |
| 5405 | + |
| 5406 | + mt7915_show_lp_history(s, fgIsExp); |
| 5407 | + mt7915_show_irq_history(s); |
| 5408 | + |
| 5409 | + seq_printf(s, "\n\n cpu ultility\n"); |
| 5410 | + seq_printf(s, " Busy:%d%% Peak:%d%%\n\n", |
| 5411 | + mt76_rr(dev, 0x7C053B20), mt76_rr(dev, 0x7C053B24)); |
| 5412 | + |
| 5413 | + mt7915_show_msg_trace(s); |
| 5414 | + mt7915_show_sech_trace(s); |
| 5415 | + mt7915_show_prog_trace(s); |
| 5416 | + if (fgIsAssert) |
| 5417 | + mt7915_show_assert_line(s); |
| 5418 | + |
| 5419 | + seq_printf(s, "============================================\n"); |
| 5420 | + return 0; |
| 5421 | +} |
| 5422 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5423 | +int mt7915_mtk_init_debugfs(struct mt7915_phy *phy, struct dentry *dir) |
| 5424 | +{ |
| 5425 | + struct mt7915_dev *dev = phy->dev; |
| 5426 | + u32 device_id = (dev->mt76.rev) >> 16; |
| 5427 | + int i = 0; |
| 5428 | + |
| 5429 | + for (i = 0; i < ARRAY_SIZE(dbg_reg_s); i++) { |
| 5430 | + if (device_id == dbg_reg_s[i].id) { |
| 5431 | + dev->dbg_reg = &dbg_reg_s[i]; |
| 5432 | + break; |
| 5433 | + } |
| 5434 | + } |
| 5435 | + |
| 5436 | + mt7915_mcu_fw_log_2_host(dev, MCU_FW_LOG_WM, 0); |
| 5437 | + |
| 5438 | + debugfs_create_file("fw_debug_module", 0600, dir, dev, |
| 5439 | + &fops_fw_debug_module); |
| 5440 | + debugfs_create_file("fw_debug_level", 0600, dir, dev, |
| 5441 | + &fops_fw_debug_level); |
| 5442 | + |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5443 | + debugfs_create_devm_seqfile(dev->mt76.dev, "sta_info", dir, |
| 5444 | + mt7915_sta_info); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5445 | + debugfs_create_devm_seqfile(dev->mt76.dev, "wtbl_info", dir, |
| 5446 | + mt7915_wtbl_read); |
| 5447 | + debugfs_create_devm_seqfile(dev->mt76.dev, "uwtbl_info", dir, |
| 5448 | + mt7915_uwtbl_read); |
| 5449 | + |
| 5450 | + debugfs_create_devm_seqfile(dev->mt76.dev, "tr_info", dir, |
| 5451 | + mt7915_trinfo_read); |
| 5452 | + |
| 5453 | + debugfs_create_devm_seqfile(dev->mt76.dev, "drr_info", dir, |
| 5454 | + mt7915_drr_info); |
| 5455 | + |
| 5456 | + debugfs_create_devm_seqfile(dev->mt76.dev, "ple_info", dir, |
| 5457 | + mt7915_pleinfo_read); |
| 5458 | + |
| 5459 | + debugfs_create_devm_seqfile(dev->mt76.dev, "pse_info", dir, |
| 5460 | + mt7915_pseinfo_read); |
| 5461 | + |
| 5462 | + debugfs_create_devm_seqfile(dev->mt76.dev, "mib_info0", dir, |
| 5463 | + mt7915_mibinfo_band0); |
| 5464 | + debugfs_create_devm_seqfile(dev->mt76.dev, "mib_info1", dir, |
| 5465 | + mt7915_mibinfo_band1); |
| 5466 | + |
| 5467 | + debugfs_create_u32("token_idx", 0600, dir, &dev->dbg.token_idx); |
| 5468 | + debugfs_create_devm_seqfile(dev->mt76.dev, "token", dir, |
| 5469 | + mt7915_token_read); |
| 5470 | + debugfs_create_devm_seqfile(dev->mt76.dev, "token_txd", dir, |
| 5471 | + mt7915_token_txd_read); |
| 5472 | + |
| 5473 | + debugfs_create_devm_seqfile(dev->mt76.dev, "amsdu_info", dir, |
| 5474 | + mt7915_amsduinfo_read); |
| 5475 | + |
| 5476 | + debugfs_create_devm_seqfile(dev->mt76.dev, "agg_info0", dir, |
| 5477 | + mt7915_agginfo_read_band0); |
| 5478 | + debugfs_create_devm_seqfile(dev->mt76.dev, "agg_info1", dir, |
| 5479 | + mt7915_agginfo_read_band1); |
| 5480 | + |
| 5481 | + debugfs_create_file("tx_amsdu", 0600, dir, dev, &fops_tx_amsdu); |
| 5482 | + |
| 5483 | + debugfs_create_file("fw_wa_query", 0600, dir, dev, &fops_wa_query); |
| 5484 | + debugfs_create_file("fw_wa_set", 0600, dir, dev, &fops_wa_set); |
developer | 6770571 | 2023-05-30 11:58:00 +0800 | [diff] [blame] | 5485 | + debugfs_create_devm_seqfile(dev->mt76.dev, "fw_version", dir, |
| 5486 | + mt7915_dump_version); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5487 | + debugfs_create_file("fw_wa_debug", 0600, dir, dev, &fops_wa_debug); |
developer | 8effbd3 | 2023-04-17 15:57:28 +0800 | [diff] [blame] | 5488 | + debugfs_create_devm_seqfile(dev->mt76.dev, "fw_wm_info", dir, |
| 5489 | + mt7915_fw_wm_info_read); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5490 | + |
| 5491 | + debugfs_create_file("red_en", 0600, dir, dev, |
| 5492 | + &fops_red_en); |
| 5493 | + debugfs_create_file("red_show_sta", 0600, dir, dev, |
| 5494 | + &fops_red_show_sta); |
| 5495 | + debugfs_create_file("red_target_dly", 0600, dir, dev, |
| 5496 | + &fops_red_target_dly); |
| 5497 | + |
| 5498 | + debugfs_create_file("txpower_level", 0400, dir, dev, |
| 5499 | + &fops_txpower_level); |
| 5500 | + |
developer | 7c3a508 | 2022-06-24 13:40:42 +0800 | [diff] [blame] | 5501 | + debugfs_create_u8("sku_disable", 0600, dir, &dev->dbg.sku_disable); |
| 5502 | + |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5503 | + return 0; |
| 5504 | +} |
| 5505 | +#endif |
| 5506 | diff --git a/mt7915/mtk_mcu.c b/mt7915/mtk_mcu.c |
| 5507 | new file mode 100644 |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 5508 | index 0000000..143dae2 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5509 | --- /dev/null |
| 5510 | +++ b/mt7915/mtk_mcu.c |
| 5511 | @@ -0,0 +1,51 @@ |
| 5512 | +#include <linux/firmware.h> |
| 5513 | +#include <linux/fs.h> |
| 5514 | +#include<linux/inet.h> |
| 5515 | +#include "mt7915.h" |
| 5516 | +#include "mcu.h" |
| 5517 | +#include "mac.h" |
| 5518 | + |
| 5519 | +int mt7915_mcu_set_txpower_level(struct mt7915_phy *phy, u8 drop_level) |
| 5520 | +{ |
| 5521 | + struct mt7915_dev *dev = phy->dev; |
| 5522 | + struct mt7915_sku_val { |
| 5523 | + u8 format_id; |
| 5524 | + u8 val; |
| 5525 | + u8 band; |
| 5526 | + u8 _rsv; |
| 5527 | + } __packed req = { |
| 5528 | + .format_id = 1, |
developer | 17bb0a8 | 2022-12-13 15:52:04 +0800 | [diff] [blame] | 5529 | + .band = phy->mt76->band_idx, |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5530 | + .val = !!drop_level, |
| 5531 | + }; |
| 5532 | + int ret; |
| 5533 | + |
| 5534 | + ret = mt76_mcu_send_msg(&dev->mt76, |
| 5535 | + MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 5536 | + sizeof(req), true); |
| 5537 | + if (ret) |
| 5538 | + return ret; |
| 5539 | + |
| 5540 | + req.format_id = 2; |
| 5541 | + if ((drop_level > 90 && drop_level < 100) || !drop_level) |
| 5542 | + req.val = 0; |
| 5543 | + else if (drop_level > 60 && drop_level <= 90) |
| 5544 | + /* reduce Pwr for 1 dB. */ |
| 5545 | + req.val = 2; |
| 5546 | + else if (drop_level > 30 && drop_level <= 60) |
| 5547 | + /* reduce Pwr for 3 dB. */ |
| 5548 | + req.val = 6; |
| 5549 | + else if (drop_level > 15 && drop_level <= 30) |
| 5550 | + /* reduce Pwr for 6 dB. */ |
| 5551 | + req.val = 12; |
| 5552 | + else if (drop_level > 9 && drop_level <= 15) |
| 5553 | + /* reduce Pwr for 9 dB. */ |
| 5554 | + req.val = 18; |
| 5555 | + else if (drop_level > 0 && drop_level <= 9) |
| 5556 | + /* reduce Pwr for 12 dB. */ |
| 5557 | + req.val = 24; |
| 5558 | + |
| 5559 | + return mt76_mcu_send_msg(&dev->mt76, |
| 5560 | + MCU_EXT_CMD(TX_POWER_FEATURE_CTRL), &req, |
| 5561 | + sizeof(req), true); |
| 5562 | +} |
| 5563 | diff --git a/tools/fwlog.c b/tools/fwlog.c |
developer | b85e875 | 2023-09-25 14:16:05 +0800 | [diff] [blame^] | 5564 | index e5d4a10..3d51d9e 100644 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5565 | --- a/tools/fwlog.c |
| 5566 | +++ b/tools/fwlog.c |
| 5567 | @@ -26,7 +26,7 @@ static const char *debugfs_path(const char *phyname, const char *file) |
| 5568 | return path; |
| 5569 | } |
| 5570 | |
| 5571 | -static int mt76_set_fwlog_en(const char *phyname, bool en) |
| 5572 | +static int mt76_set_fwlog_en(const char *phyname, bool en, char *val) |
| 5573 | { |
| 5574 | FILE *f = fopen(debugfs_path(phyname, "fw_debug_bin"), "w"); |
| 5575 | |
| 5576 | @@ -35,7 +35,13 @@ static int mt76_set_fwlog_en(const char *phyname, bool en) |
| 5577 | return 1; |
| 5578 | } |
| 5579 | |
| 5580 | - fprintf(f, "7"); |
| 5581 | + if (en && val) |
| 5582 | + fprintf(f, "%s", val); |
| 5583 | + else if (en) |
| 5584 | + fprintf(f, "7"); |
| 5585 | + else |
| 5586 | + fprintf(f, "0"); |
| 5587 | + |
| 5588 | fclose(f); |
| 5589 | |
| 5590 | return 0; |
| 5591 | @@ -76,6 +82,7 @@ static void handle_signal(int sig) |
| 5592 | |
| 5593 | int mt76_fwlog(const char *phyname, int argc, char **argv) |
| 5594 | { |
| 5595 | +#define BUF_SIZE 1504 |
| 5596 | struct sockaddr_in local = { |
| 5597 | .sin_family = AF_INET, |
| 5598 | .sin_addr.s_addr = INADDR_ANY, |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5599 | @@ -84,9 +91,10 @@ int mt76_fwlog(const char *phyname, int argc, char **argv) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5600 | .sin_family = AF_INET, |
| 5601 | .sin_port = htons(55688), |
| 5602 | }; |
| 5603 | - char buf[1504]; |
| 5604 | + char *buf = calloc(BUF_SIZE, sizeof(char)); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5605 | + FILE *logfile = NULL; |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5606 | int ret = 0; |
| 5607 | - int yes = 1; |
| 5608 | + /* int yes = 1; */ |
| 5609 | int s, fd; |
| 5610 | |
| 5611 | if (argc < 1) { |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5612 | @@ -99,19 +107,28 @@ int mt76_fwlog(const char *phyname, int argc, char **argv) |
| 5613 | return 1; |
| 5614 | } |
| 5615 | |
| 5616 | + if (argc == 3) { |
| 5617 | + fprintf(stdout, "start logging to file %s\n", argv[2]); |
| 5618 | + logfile = fopen(argv[2], "wb"); |
| 5619 | + if (!logfile) { |
| 5620 | + perror("fopen"); |
| 5621 | + return 1; |
| 5622 | + } |
| 5623 | + } |
| 5624 | + |
| 5625 | s = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); |
| 5626 | if (s < 0) { |
| 5627 | perror("socket"); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5628 | return 1; |
| 5629 | } |
| 5630 | |
| 5631 | - setsockopt(s, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(yes)); |
| 5632 | + /* setsockopt(s, SOL_SOCKET, SO_BROADCAST, &yes, sizeof(yes)); */ |
| 5633 | if (bind(s, (struct sockaddr *)&local, sizeof(local)) < 0) { |
| 5634 | perror("bind"); |
| 5635 | return 1; |
| 5636 | } |
| 5637 | |
| 5638 | - if (mt76_set_fwlog_en(phyname, true)) |
| 5639 | + if (mt76_set_fwlog_en(phyname, true, argv[1])) |
| 5640 | return 1; |
| 5641 | |
| 5642 | fd = open(debugfs_path(phyname, "fwlog_data"), O_RDONLY); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5643 | @@ -145,8 +162,8 @@ int mt76_fwlog(const char *phyname, int argc, char **argv) |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5644 | if (!r) |
| 5645 | continue; |
| 5646 | |
| 5647 | - if (len > sizeof(buf)) { |
| 5648 | - fprintf(stderr, "Length error: %d > %d\n", len, (int)sizeof(buf)); |
| 5649 | + if (len > BUF_SIZE) { |
| 5650 | + fprintf(stderr, "Length error: %d > %d\n", len, BUF_SIZE); |
| 5651 | ret = 1; |
| 5652 | break; |
| 5653 | } |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5654 | @@ -164,14 +181,19 @@ int mt76_fwlog(const char *phyname, int argc, char **argv) |
| 5655 | break; |
| 5656 | } |
| 5657 | |
| 5658 | - /* send buf */ |
| 5659 | - sendto(s, buf, len, 0, (struct sockaddr *)&remote, sizeof(remote)); |
| 5660 | + if (logfile) |
| 5661 | + fwrite(buf, 1, len, logfile); |
| 5662 | + else |
| 5663 | + /* send buf */ |
| 5664 | + sendto(s, buf, len, 0, (struct sockaddr *)&remote, sizeof(remote)); |
| 5665 | } |
| 5666 | |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5667 | close(fd); |
| 5668 | |
| 5669 | out: |
| 5670 | - mt76_set_fwlog_en(phyname, false); |
| 5671 | + mt76_set_fwlog_en(phyname, false, NULL); |
| 5672 | + free(buf); |
developer | d68e00e | 2022-06-01 10:59:24 +0800 | [diff] [blame] | 5673 | + fclose(logfile); |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5674 | |
| 5675 | return ret; |
| 5676 | } |
| 5677 | -- |
developer | bddc9db | 2023-09-11 13:34:36 +0800 | [diff] [blame] | 5678 | 2.18.0 |
developer | 73e5a57 | 2022-04-19 10:21:20 +0800 | [diff] [blame] | 5679 | |