developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2018 MediaTek Inc. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; version 2 of the License |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * Copyright (C) 2009-2016 John Crispin <blogic@openwrt.org> |
| 14 | * Copyright (C) 2009-2016 Felix Fietkau <nbd@openwrt.org> |
| 15 | * Copyright (C) 2013-2016 Michael Lee <igvtee@gmail.com> |
| 16 | */ |
| 17 | |
| 18 | #include <linux/trace_seq.h> |
| 19 | #include <linux/seq_file.h> |
| 20 | #include <linux/proc_fs.h> |
| 21 | #include <linux/u64_stats_sync.h> |
| 22 | #include <linux/dma-mapping.h> |
| 23 | #include <linux/netdevice.h> |
| 24 | #include <linux/ctype.h> |
| 25 | #include <linux/debugfs.h> |
| 26 | #include <linux/of_mdio.h> |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 27 | #include <linux/of_address.h> |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 28 | |
| 29 | #include "mtk_eth_soc.h" |
| 30 | #include "mtk_eth_dbg.h" |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 31 | #include "mtk_eth_reset.h" |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 32 | |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 33 | u32 hw_lro_agg_num_cnt[MTK_HW_LRO_RING_NUM][MTK_HW_LRO_MAX_AGG_CNT + 1]; |
| 34 | u32 hw_lro_agg_size_cnt[MTK_HW_LRO_RING_NUM][16]; |
| 35 | u32 hw_lro_tot_agg_cnt[MTK_HW_LRO_RING_NUM]; |
| 36 | u32 hw_lro_tot_flush_cnt[MTK_HW_LRO_RING_NUM]; |
| 37 | u32 hw_lro_agg_flush_cnt[MTK_HW_LRO_RING_NUM]; |
| 38 | u32 hw_lro_age_flush_cnt[MTK_HW_LRO_RING_NUM]; |
| 39 | u32 hw_lro_seq_flush_cnt[MTK_HW_LRO_RING_NUM]; |
| 40 | u32 hw_lro_timestamp_flush_cnt[MTK_HW_LRO_RING_NUM]; |
| 41 | u32 hw_lro_norule_flush_cnt[MTK_HW_LRO_RING_NUM]; |
| 42 | u32 mtk_hwlro_stats_ebl; |
| 43 | static struct proc_dir_entry *proc_hw_lro_stats, *proc_hw_lro_auto_tlb; |
| 44 | typedef int (*mtk_lro_dbg_func) (int par); |
| 45 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 46 | struct mtk_eth_debug { |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 47 | struct dentry *root; |
| 48 | void __iomem *base; |
| 49 | int direct_access; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | struct mtk_eth *g_eth; |
| 53 | |
| 54 | struct mtk_eth_debug eth_debug; |
| 55 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 56 | int mt798x_iomap(void) |
| 57 | { |
| 58 | struct device_node *np = NULL; |
| 59 | |
| 60 | np = of_find_node_by_name(NULL, "switch0"); |
| 61 | if (np) { |
| 62 | eth_debug.base = of_iomap(np, 0); |
| 63 | if (!eth_debug.base) { |
| 64 | pr_err("of_iomap failed\n"); |
| 65 | of_node_put(np); |
| 66 | return -ENOMEM; |
| 67 | } |
| 68 | |
| 69 | of_node_put(np); |
| 70 | eth_debug.direct_access = 1; |
| 71 | } |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | int mt798x_iounmap(void) |
| 77 | { |
| 78 | eth_debug.direct_access = 0; |
| 79 | if (eth_debug.base) |
| 80 | iounmap(eth_debug.base); |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
developer | 3957a91 | 2021-05-13 16:44:31 +0800 | [diff] [blame] | 85 | void mt7530_mdio_w32(struct mtk_eth *eth, u16 reg, u32 val) |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 86 | { |
| 87 | mutex_lock(ð->mii_bus->mdio_lock); |
| 88 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 89 | if (eth_debug.direct_access) |
| 90 | __raw_writel(val, eth_debug.base + reg); |
| 91 | else { |
| 92 | _mtk_mdio_write(eth, 0x1f, 0x1f, (reg >> 6) & 0x3ff); |
| 93 | _mtk_mdio_write(eth, 0x1f, (reg >> 2) & 0xf, val & 0xffff); |
| 94 | _mtk_mdio_write(eth, 0x1f, 0x10, val >> 16); |
| 95 | } |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 96 | |
| 97 | mutex_unlock(ð->mii_bus->mdio_lock); |
| 98 | } |
| 99 | |
| 100 | u32 mt7530_mdio_r32(struct mtk_eth *eth, u32 reg) |
| 101 | { |
| 102 | u16 high, low; |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 103 | u32 ret; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 104 | |
| 105 | mutex_lock(ð->mii_bus->mdio_lock); |
| 106 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 107 | if (eth_debug.direct_access) { |
| 108 | ret = __raw_readl(eth_debug.base + reg); |
| 109 | mutex_unlock(ð->mii_bus->mdio_lock); |
| 110 | return ret; |
| 111 | } |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 112 | _mtk_mdio_write(eth, 0x1f, 0x1f, (reg >> 6) & 0x3ff); |
| 113 | low = _mtk_mdio_read(eth, 0x1f, (reg >> 2) & 0xf); |
| 114 | high = _mtk_mdio_read(eth, 0x1f, 0x10); |
| 115 | |
| 116 | mutex_unlock(ð->mii_bus->mdio_lock); |
| 117 | |
| 118 | return (high << 16) | (low & 0xffff); |
| 119 | } |
| 120 | |
| 121 | void mtk_switch_w32(struct mtk_eth *eth, u32 val, unsigned reg) |
| 122 | { |
| 123 | mtk_w32(eth, val, reg + 0x10000); |
| 124 | } |
| 125 | EXPORT_SYMBOL(mtk_switch_w32); |
| 126 | |
| 127 | u32 mtk_switch_r32(struct mtk_eth *eth, unsigned reg) |
| 128 | { |
| 129 | return mtk_r32(eth, reg + 0x10000); |
| 130 | } |
| 131 | EXPORT_SYMBOL(mtk_switch_r32); |
| 132 | |
| 133 | static int mtketh_debug_show(struct seq_file *m, void *private) |
| 134 | { |
| 135 | struct mtk_eth *eth = m->private; |
| 136 | struct mtk_mac *mac = 0; |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 137 | int i = 0; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 138 | |
| 139 | for (i = 0 ; i < MTK_MAX_DEVS ; i++) { |
| 140 | if (!eth->mac[i] || |
| 141 | of_phy_is_fixed_link(eth->mac[i]->of_node)) |
| 142 | continue; |
| 143 | mac = eth->mac[i]; |
| 144 | #if 0 //FIXME |
| 145 | while (j < 30) { |
| 146 | d = _mtk_mdio_read(eth, mac->phy_dev->addr, j); |
| 147 | |
| 148 | seq_printf(m, "phy=%d, reg=0x%08x, data=0x%08x\n", |
| 149 | mac->phy_dev->addr, j, d); |
| 150 | j++; |
| 151 | } |
| 152 | #endif |
| 153 | } |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | static int mtketh_debug_open(struct inode *inode, struct file *file) |
| 158 | { |
| 159 | return single_open(file, mtketh_debug_show, inode->i_private); |
| 160 | } |
| 161 | |
| 162 | static const struct file_operations mtketh_debug_fops = { |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 163 | .owner = THIS_MODULE, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 164 | .open = mtketh_debug_open, |
| 165 | .read = seq_read, |
| 166 | .llseek = seq_lseek, |
| 167 | .release = single_release, |
| 168 | }; |
| 169 | |
| 170 | static int mtketh_mt7530sw_debug_show(struct seq_file *m, void *private) |
| 171 | { |
| 172 | struct mtk_eth *eth = m->private; |
| 173 | u32 offset, data; |
| 174 | int i; |
| 175 | struct mt7530_ranges { |
| 176 | u32 start; |
| 177 | u32 end; |
| 178 | } ranges[] = { |
| 179 | {0x0, 0xac}, |
| 180 | {0x1000, 0x10e0}, |
| 181 | {0x1100, 0x1140}, |
| 182 | {0x1200, 0x1240}, |
| 183 | {0x1300, 0x1340}, |
| 184 | {0x1400, 0x1440}, |
| 185 | {0x1500, 0x1540}, |
| 186 | {0x1600, 0x1640}, |
| 187 | {0x1800, 0x1848}, |
| 188 | {0x1900, 0x1948}, |
| 189 | {0x1a00, 0x1a48}, |
| 190 | {0x1b00, 0x1b48}, |
| 191 | {0x1c00, 0x1c48}, |
| 192 | {0x1d00, 0x1d48}, |
| 193 | {0x1e00, 0x1e48}, |
| 194 | {0x1f60, 0x1ffc}, |
| 195 | {0x2000, 0x212c}, |
| 196 | {0x2200, 0x222c}, |
| 197 | {0x2300, 0x232c}, |
| 198 | {0x2400, 0x242c}, |
| 199 | {0x2500, 0x252c}, |
| 200 | {0x2600, 0x262c}, |
| 201 | {0x3000, 0x3014}, |
| 202 | {0x30c0, 0x30f8}, |
| 203 | {0x3100, 0x3114}, |
| 204 | {0x3200, 0x3214}, |
| 205 | {0x3300, 0x3314}, |
| 206 | {0x3400, 0x3414}, |
| 207 | {0x3500, 0x3514}, |
| 208 | {0x3600, 0x3614}, |
| 209 | {0x4000, 0x40d4}, |
| 210 | {0x4100, 0x41d4}, |
| 211 | {0x4200, 0x42d4}, |
| 212 | {0x4300, 0x43d4}, |
| 213 | {0x4400, 0x44d4}, |
| 214 | {0x4500, 0x45d4}, |
| 215 | {0x4600, 0x46d4}, |
| 216 | {0x4f00, 0x461c}, |
| 217 | {0x7000, 0x7038}, |
| 218 | {0x7120, 0x7124}, |
| 219 | {0x7800, 0x7804}, |
| 220 | {0x7810, 0x7810}, |
| 221 | {0x7830, 0x7830}, |
| 222 | {0x7a00, 0x7a7c}, |
| 223 | {0x7b00, 0x7b04}, |
| 224 | {0x7e00, 0x7e04}, |
| 225 | {0x7ffc, 0x7ffc}, |
| 226 | }; |
| 227 | |
| 228 | if (!mt7530_exist(eth)) |
| 229 | return -EOPNOTSUPP; |
| 230 | |
| 231 | if ((!eth->mac[0] || !of_phy_is_fixed_link(eth->mac[0]->of_node)) && |
| 232 | (!eth->mac[1] || !of_phy_is_fixed_link(eth->mac[1]->of_node))) { |
| 233 | seq_puts(m, "no switch found\n"); |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | for (i = 0 ; i < ARRAY_SIZE(ranges) ; i++) { |
| 238 | for (offset = ranges[i].start; |
| 239 | offset <= ranges[i].end; offset += 4) { |
| 240 | data = mt7530_mdio_r32(eth, offset); |
| 241 | seq_printf(m, "mt7530 switch reg=0x%08x, data=0x%08x\n", |
| 242 | offset, data); |
| 243 | } |
| 244 | } |
| 245 | |
| 246 | return 0; |
| 247 | } |
| 248 | |
| 249 | static int mtketh_debug_mt7530sw_open(struct inode *inode, struct file *file) |
| 250 | { |
| 251 | return single_open(file, mtketh_mt7530sw_debug_show, inode->i_private); |
| 252 | } |
| 253 | |
| 254 | static const struct file_operations mtketh_debug_mt7530sw_fops = { |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 255 | .owner = THIS_MODULE, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 256 | .open = mtketh_debug_mt7530sw_open, |
| 257 | .read = seq_read, |
| 258 | .llseek = seq_lseek, |
| 259 | .release = single_release, |
| 260 | }; |
| 261 | |
| 262 | static ssize_t mtketh_mt7530sw_debugfs_write(struct file *file, |
| 263 | const char __user *ptr, |
| 264 | size_t len, loff_t *off) |
| 265 | { |
| 266 | struct mtk_eth *eth = file->private_data; |
| 267 | char buf[32], *token, *p = buf; |
developer | 8b6f240 | 2022-11-28 13:42:34 +0800 | [diff] [blame^] | 268 | unsigned long reg, value, phy; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 269 | int ret; |
| 270 | |
| 271 | if (!mt7530_exist(eth)) |
| 272 | return -EOPNOTSUPP; |
| 273 | |
| 274 | if (*off != 0) |
| 275 | return 0; |
| 276 | |
| 277 | if (len > sizeof(buf) - 1) |
| 278 | len = sizeof(buf) - 1; |
| 279 | |
| 280 | ret = strncpy_from_user(buf, ptr, len); |
| 281 | if (ret < 0) |
| 282 | return ret; |
| 283 | buf[len] = '\0'; |
| 284 | |
| 285 | token = strsep(&p, " "); |
| 286 | if (!token) |
| 287 | return -EINVAL; |
| 288 | if (kstrtoul(token, 16, (unsigned long *)&phy)) |
| 289 | return -EINVAL; |
| 290 | |
| 291 | token = strsep(&p, " "); |
| 292 | if (!token) |
| 293 | return -EINVAL; |
| 294 | if (kstrtoul(token, 16, (unsigned long *)®)) |
| 295 | return -EINVAL; |
| 296 | |
| 297 | token = strsep(&p, " "); |
| 298 | if (!token) |
| 299 | return -EINVAL; |
| 300 | if (kstrtoul(token, 16, (unsigned long *)&value)) |
| 301 | return -EINVAL; |
| 302 | |
| 303 | pr_info("%s:phy=%d, reg=0x%x, val=0x%x\n", __func__, |
| 304 | 0x1f, reg, value); |
| 305 | mt7530_mdio_w32(eth, reg, value); |
| 306 | pr_info("%s:phy=%d, reg=0x%x, val=0x%x confirm..\n", __func__, |
| 307 | 0x1f, reg, mt7530_mdio_r32(eth, reg)); |
| 308 | |
| 309 | return len; |
| 310 | } |
| 311 | |
| 312 | static ssize_t mtketh_debugfs_write(struct file *file, const char __user *ptr, |
| 313 | size_t len, loff_t *off) |
| 314 | { |
| 315 | struct mtk_eth *eth = file->private_data; |
| 316 | char buf[32], *token, *p = buf; |
developer | 8b6f240 | 2022-11-28 13:42:34 +0800 | [diff] [blame^] | 317 | unsigned long reg, value, phy; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 318 | int ret; |
| 319 | |
| 320 | if (*off != 0) |
| 321 | return 0; |
| 322 | |
| 323 | if (len > sizeof(buf) - 1) |
| 324 | len = sizeof(buf) - 1; |
| 325 | |
| 326 | ret = strncpy_from_user(buf, ptr, len); |
| 327 | if (ret < 0) |
| 328 | return ret; |
| 329 | buf[len] = '\0'; |
| 330 | |
| 331 | token = strsep(&p, " "); |
| 332 | if (!token) |
| 333 | return -EINVAL; |
| 334 | if (kstrtoul(token, 16, (unsigned long *)&phy)) |
| 335 | return -EINVAL; |
| 336 | |
| 337 | token = strsep(&p, " "); |
| 338 | |
| 339 | if (!token) |
| 340 | return -EINVAL; |
| 341 | if (kstrtoul(token, 16, (unsigned long *)®)) |
| 342 | return -EINVAL; |
| 343 | |
| 344 | token = strsep(&p, " "); |
| 345 | |
| 346 | if (!token) |
| 347 | return -EINVAL; |
| 348 | if (kstrtoul(token, 16, (unsigned long *)&value)) |
| 349 | return -EINVAL; |
| 350 | |
| 351 | pr_info("%s:phy=%d, reg=0x%x, val=0x%x\n", __func__, |
| 352 | phy, reg, value); |
| 353 | |
| 354 | _mtk_mdio_write(eth, phy, reg, value); |
| 355 | |
| 356 | pr_info("%s:phy=%d, reg=0x%x, val=0x%x confirm..\n", __func__, |
| 357 | phy, reg, _mtk_mdio_read(eth, phy, reg)); |
| 358 | |
| 359 | return len; |
| 360 | } |
| 361 | |
| 362 | static ssize_t mtketh_debugfs_reset(struct file *file, const char __user *ptr, |
| 363 | size_t len, loff_t *off) |
| 364 | { |
| 365 | struct mtk_eth *eth = file->private_data; |
developer | bd42c17 | 2022-07-18 17:51:30 +0800 | [diff] [blame] | 366 | char buf[8] = ""; |
| 367 | int count = len; |
| 368 | unsigned long dbg_level = 0; |
| 369 | |
| 370 | len = min(count, sizeof(buf) - 1); |
| 371 | if (copy_from_user(buf, ptr, len)) |
| 372 | return -EFAULT; |
| 373 | |
| 374 | buf[len] = '\0'; |
| 375 | if (kstrtoul(buf, 0, &dbg_level)) |
| 376 | return -EINVAL; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 377 | |
developer | bd42c17 | 2022-07-18 17:51:30 +0800 | [diff] [blame] | 378 | switch(dbg_level) |
| 379 | { |
| 380 | case 0: |
| 381 | if (atomic_read(&reset_lock) == 0) |
| 382 | atomic_inc(&reset_lock); |
| 383 | break; |
| 384 | case 1: |
| 385 | if (atomic_read(&force) == 0) |
| 386 | atomic_inc(&force); |
| 387 | schedule_work(ð->pending_work); |
| 388 | break; |
| 389 | case 2: |
| 390 | if (atomic_read(&reset_lock) == 1) |
| 391 | atomic_dec(&reset_lock); |
| 392 | break; |
| 393 | default: |
| 394 | pr_info("Usage: echo [level] > /sys/kernel/debug/mtketh/reset\n"); |
| 395 | pr_info("Commands: [level] \n"); |
| 396 | pr_info(" 0 disable reset \n"); |
| 397 | pr_info(" 1 force reset \n"); |
| 398 | pr_info(" 2 enable reset\n"); |
| 399 | break; |
| 400 | } |
| 401 | return count; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | static const struct file_operations fops_reg_w = { |
| 405 | .owner = THIS_MODULE, |
| 406 | .open = simple_open, |
| 407 | .write = mtketh_debugfs_write, |
| 408 | .llseek = noop_llseek, |
| 409 | }; |
| 410 | |
| 411 | static const struct file_operations fops_eth_reset = { |
| 412 | .owner = THIS_MODULE, |
| 413 | .open = simple_open, |
| 414 | .write = mtketh_debugfs_reset, |
| 415 | .llseek = noop_llseek, |
| 416 | }; |
| 417 | |
| 418 | static const struct file_operations fops_mt7530sw_reg_w = { |
| 419 | .owner = THIS_MODULE, |
| 420 | .open = simple_open, |
| 421 | .write = mtketh_mt7530sw_debugfs_write, |
| 422 | .llseek = noop_llseek, |
| 423 | }; |
| 424 | |
| 425 | void mtketh_debugfs_exit(struct mtk_eth *eth) |
| 426 | { |
| 427 | debugfs_remove_recursive(eth_debug.root); |
| 428 | } |
| 429 | |
| 430 | int mtketh_debugfs_init(struct mtk_eth *eth) |
| 431 | { |
| 432 | int ret = 0; |
| 433 | |
| 434 | eth_debug.root = debugfs_create_dir("mtketh", NULL); |
| 435 | if (!eth_debug.root) { |
| 436 | dev_notice(eth->dev, "%s:err at %d\n", __func__, __LINE__); |
| 437 | ret = -ENOMEM; |
| 438 | } |
| 439 | |
| 440 | debugfs_create_file("phy_regs", S_IRUGO, |
| 441 | eth_debug.root, eth, &mtketh_debug_fops); |
| 442 | debugfs_create_file("phy_reg_w", S_IFREG | S_IWUSR, |
| 443 | eth_debug.root, eth, &fops_reg_w); |
| 444 | debugfs_create_file("reset", S_IFREG | S_IWUSR, |
| 445 | eth_debug.root, eth, &fops_eth_reset); |
| 446 | if (mt7530_exist(eth)) { |
| 447 | debugfs_create_file("mt7530sw_regs", S_IRUGO, |
| 448 | eth_debug.root, eth, |
| 449 | &mtketh_debug_mt7530sw_fops); |
| 450 | debugfs_create_file("mt7530sw_reg_w", S_IFREG | S_IWUSR, |
| 451 | eth_debug.root, eth, |
| 452 | &fops_mt7530sw_reg_w); |
| 453 | } |
| 454 | return ret; |
| 455 | } |
| 456 | |
| 457 | void mii_mgr_read_combine(struct mtk_eth *eth, u32 phy_addr, u32 phy_register, |
| 458 | u32 *read_data) |
| 459 | { |
| 460 | if (mt7530_exist(eth) && phy_addr == 31) |
| 461 | *read_data = mt7530_mdio_r32(eth, phy_register); |
| 462 | |
| 463 | else |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 464 | *read_data = mdiobus_read(eth->mii_bus, phy_addr, phy_register); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 465 | } |
| 466 | |
developer | 3957a91 | 2021-05-13 16:44:31 +0800 | [diff] [blame] | 467 | void mii_mgr_write_combine(struct mtk_eth *eth, u16 phy_addr, u16 phy_register, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 468 | u32 write_data) |
| 469 | { |
| 470 | if (mt7530_exist(eth) && phy_addr == 31) |
| 471 | mt7530_mdio_w32(eth, phy_register, write_data); |
| 472 | |
| 473 | else |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 474 | mdiobus_write(eth->mii_bus, phy_addr, phy_register, write_data); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 475 | } |
| 476 | |
developer | 3957a91 | 2021-05-13 16:44:31 +0800 | [diff] [blame] | 477 | static void mii_mgr_read_cl45(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 *data) |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 478 | { |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 479 | *data = mdiobus_read(eth->mii_bus, port, mdiobus_c45_addr(devad, reg)); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 480 | } |
| 481 | |
developer | 3957a91 | 2021-05-13 16:44:31 +0800 | [diff] [blame] | 482 | static void mii_mgr_write_cl45(struct mtk_eth *eth, u16 port, u16 devad, u16 reg, u16 data) |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 483 | { |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 484 | mdiobus_write(eth->mii_bus, port, mdiobus_c45_addr(devad, reg), data); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | int mtk_do_priv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) |
| 488 | { |
| 489 | struct mtk_mac *mac = netdev_priv(dev); |
| 490 | struct mtk_eth *eth = mac->hw; |
| 491 | struct mtk_mii_ioctl_data mii; |
| 492 | struct mtk_esw_reg reg; |
developer | ba2d1eb | 2021-05-25 19:26:45 +0800 | [diff] [blame] | 493 | u16 val; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 494 | |
| 495 | switch (cmd) { |
| 496 | case MTKETH_MII_READ: |
| 497 | if (copy_from_user(&mii, ifr->ifr_data, sizeof(mii))) |
| 498 | goto err_copy; |
| 499 | mii_mgr_read_combine(eth, mii.phy_id, mii.reg_num, |
| 500 | &mii.val_out); |
| 501 | if (copy_to_user(ifr->ifr_data, &mii, sizeof(mii))) |
| 502 | goto err_copy; |
| 503 | |
| 504 | return 0; |
| 505 | case MTKETH_MII_WRITE: |
| 506 | if (copy_from_user(&mii, ifr->ifr_data, sizeof(mii))) |
| 507 | goto err_copy; |
| 508 | mii_mgr_write_combine(eth, mii.phy_id, mii.reg_num, |
| 509 | mii.val_in); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 510 | return 0; |
| 511 | case MTKETH_MII_READ_CL45: |
| 512 | if (copy_from_user(&mii, ifr->ifr_data, sizeof(mii))) |
| 513 | goto err_copy; |
developer | 3957a91 | 2021-05-13 16:44:31 +0800 | [diff] [blame] | 514 | mii_mgr_read_cl45(eth, |
| 515 | mdio_phy_id_prtad(mii.phy_id), |
| 516 | mdio_phy_id_devad(mii.phy_id), |
| 517 | mii.reg_num, |
developer | ba2d1eb | 2021-05-25 19:26:45 +0800 | [diff] [blame] | 518 | &val); |
| 519 | mii.val_out = val; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 520 | if (copy_to_user(ifr->ifr_data, &mii, sizeof(mii))) |
| 521 | goto err_copy; |
| 522 | |
| 523 | return 0; |
| 524 | case MTKETH_MII_WRITE_CL45: |
| 525 | if (copy_from_user(&mii, ifr->ifr_data, sizeof(mii))) |
| 526 | goto err_copy; |
developer | ba2d1eb | 2021-05-25 19:26:45 +0800 | [diff] [blame] | 527 | val = mii.val_in; |
developer | 3957a91 | 2021-05-13 16:44:31 +0800 | [diff] [blame] | 528 | mii_mgr_write_cl45(eth, |
| 529 | mdio_phy_id_prtad(mii.phy_id), |
| 530 | mdio_phy_id_devad(mii.phy_id), |
| 531 | mii.reg_num, |
developer | ba2d1eb | 2021-05-25 19:26:45 +0800 | [diff] [blame] | 532 | val); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 533 | return 0; |
| 534 | case MTKETH_ESW_REG_READ: |
| 535 | if (!mt7530_exist(eth)) |
| 536 | return -EOPNOTSUPP; |
| 537 | if (copy_from_user(®, ifr->ifr_data, sizeof(reg))) |
| 538 | goto err_copy; |
| 539 | if (reg.off > REG_ESW_MAX) |
| 540 | return -EINVAL; |
| 541 | reg.val = mtk_switch_r32(eth, reg.off); |
| 542 | |
| 543 | if (copy_to_user(ifr->ifr_data, ®, sizeof(reg))) |
| 544 | goto err_copy; |
| 545 | |
| 546 | return 0; |
| 547 | case MTKETH_ESW_REG_WRITE: |
| 548 | if (!mt7530_exist(eth)) |
| 549 | return -EOPNOTSUPP; |
| 550 | if (copy_from_user(®, ifr->ifr_data, sizeof(reg))) |
| 551 | goto err_copy; |
| 552 | if (reg.off > REG_ESW_MAX) |
| 553 | return -EINVAL; |
| 554 | mtk_switch_w32(eth, reg.val, reg.off); |
| 555 | |
| 556 | return 0; |
| 557 | default: |
| 558 | break; |
| 559 | } |
| 560 | |
| 561 | return -EOPNOTSUPP; |
| 562 | err_copy: |
| 563 | return -EFAULT; |
| 564 | } |
| 565 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 566 | static void gdm_reg_dump_v3(struct mtk_eth *eth, u32 gdm_id, u32 mib_base) |
| 567 | { |
| 568 | pr_info("| GDMA%d_RX_GBCNT : %010u (Rx Good Bytes) |\n", |
| 569 | gdm_id, mtk_r32(eth, mib_base)); |
| 570 | pr_info("| GDMA%d_RX_GPCNT : %010u (Rx Good Pkts) |\n", |
| 571 | gdm_id, mtk_r32(eth, mib_base + 0x08)); |
| 572 | pr_info("| GDMA%d_RX_OERCNT : %010u (overflow error) |\n", |
| 573 | gdm_id, mtk_r32(eth, mib_base + 0x10)); |
| 574 | pr_info("| GDMA%d_RX_FERCNT : %010u (FCS error) |\n", |
| 575 | gdm_id, mtk_r32(eth, mib_base + 0x14)); |
| 576 | pr_info("| GDMA%d_RX_SERCNT : %010u (too short) |\n", |
| 577 | gdm_id, mtk_r32(eth, mib_base + 0x18)); |
| 578 | pr_info("| GDMA%d_RX_LERCNT : %010u (too long) |\n", |
| 579 | gdm_id, mtk_r32(eth, mib_base + 0x1C)); |
| 580 | pr_info("| GDMA%d_RX_CERCNT : %010u (checksum error) |\n", |
| 581 | gdm_id, mtk_r32(eth, mib_base + 0x20)); |
| 582 | pr_info("| GDMA%d_RX_FCCNT : %010u (flow control) |\n", |
| 583 | gdm_id, mtk_r32(eth, mib_base + 0x24)); |
| 584 | pr_info("| GDMA%d_RX_VDPCNT : %010u (VID drop) |\n", |
| 585 | gdm_id, mtk_r32(eth, mib_base + 0x28)); |
| 586 | pr_info("| GDMA%d_RX_PFCCNT : %010u (priority flow control)\n", |
| 587 | gdm_id, mtk_r32(eth, mib_base + 0x2C)); |
| 588 | pr_info("| GDMA%d_TX_GBCNT : %010u (Tx Good Bytes) |\n", |
| 589 | gdm_id, mtk_r32(eth, mib_base + 0x40)); |
| 590 | pr_info("| GDMA%d_TX_GPCNT : %010u (Tx Good Pkts) |\n", |
| 591 | gdm_id, mtk_r32(eth, mib_base + 0x48)); |
| 592 | pr_info("| GDMA%d_TX_SKIPCNT: %010u (abort count) |\n", |
| 593 | gdm_id, mtk_r32(eth, mib_base + 0x50)); |
| 594 | pr_info("| GDMA%d_TX_COLCNT : %010u (collision count)|\n", |
| 595 | gdm_id, mtk_r32(eth, mib_base + 0x54)); |
| 596 | pr_info("| GDMA%d_TX_OERCNT : %010u (overflow error) |\n", |
| 597 | gdm_id, mtk_r32(eth, mib_base + 0x58)); |
| 598 | pr_info("| GDMA%d_TX_FCCNT : %010u (flow control) |\n", |
| 599 | gdm_id, mtk_r32(eth, mib_base + 0x60)); |
| 600 | pr_info("| GDMA%d_TX_PFCCNT : %010u (priority flow control)\n", |
| 601 | gdm_id, mtk_r32(eth, mib_base + 0x64)); |
| 602 | pr_info("| |\n"); |
| 603 | } |
| 604 | |
| 605 | static void gdm_reg_dump_v2(struct mtk_eth *eth, u32 gdm_id, u32 mib_base) |
| 606 | { |
| 607 | pr_info("| GDMA%d_RX_GBCNT : %010u (Rx Good Bytes) |\n", |
| 608 | gdm_id, mtk_r32(eth, mib_base)); |
| 609 | pr_info("| GDMA%d_RX_GPCNT : %010u (Rx Good Pkts) |\n", |
| 610 | gdm_id, mtk_r32(eth, mib_base + 0x08)); |
| 611 | pr_info("| GDMA%d_RX_OERCNT : %010u (overflow error) |\n", |
| 612 | gdm_id, mtk_r32(eth, mib_base + 0x10)); |
| 613 | pr_info("| GDMA%d_RX_FERCNT : %010u (FCS error) |\n", |
| 614 | gdm_id, mtk_r32(eth, mib_base + 0x14)); |
| 615 | pr_info("| GDMA%d_RX_SERCNT : %010u (too short) |\n", |
| 616 | gdm_id, mtk_r32(eth, mib_base + 0x18)); |
| 617 | pr_info("| GDMA%d_RX_LERCNT : %010u (too long) |\n", |
| 618 | gdm_id, mtk_r32(eth, mib_base + 0x1C)); |
| 619 | pr_info("| GDMA%d_RX_CERCNT : %010u (checksum error) |\n", |
| 620 | gdm_id, mtk_r32(eth, mib_base + 0x20)); |
| 621 | pr_info("| GDMA%d_RX_FCCNT : %010u (flow control) |\n", |
| 622 | gdm_id, mtk_r32(eth, mib_base + 0x24)); |
| 623 | pr_info("| GDMA%d_TX_SKIPCNT: %010u (abort count) |\n", |
| 624 | gdm_id, mtk_r32(eth, mib_base + 0x28)); |
| 625 | pr_info("| GDMA%d_TX_COLCNT : %010u (collision count) |\n", |
| 626 | gdm_id, mtk_r32(eth, mib_base + 0x2C)); |
| 627 | pr_info("| GDMA%d_TX_GBCNT : %010u (Tx Good Bytes) |\n", |
| 628 | gdm_id, mtk_r32(eth, mib_base + 0x30)); |
| 629 | pr_info("| GDMA%d_TX_GPCNT : %010u (Tx Good Pkts) |\n", |
| 630 | gdm_id, mtk_r32(eth, mib_base + 0x38)); |
| 631 | pr_info("| |\n"); |
| 632 | } |
| 633 | |
| 634 | static void gdm_cnt_read(struct mtk_eth *eth) |
| 635 | { |
| 636 | u32 i, mib_base; |
| 637 | |
| 638 | pr_info("\n <<CPU>>\n"); |
| 639 | pr_info(" |\n"); |
| 640 | pr_info("+-----------------------------------------------+\n"); |
| 641 | pr_info("| <<PSE>> |\n"); |
| 642 | pr_info("+-----------------------------------------------+\n"); |
| 643 | pr_info(" |\n"); |
| 644 | pr_info("+-----------------------------------------------+\n"); |
| 645 | pr_info("| <<GDMA>> |\n"); |
| 646 | |
| 647 | for (i = 0; i < MTK_MAC_COUNT; i++) { |
| 648 | mib_base = MTK_GDM1_TX_GBCNT + MTK_STAT_OFFSET * i; |
| 649 | |
| 650 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) |
| 651 | gdm_reg_dump_v3(eth, i + 1, mib_base); |
| 652 | else |
| 653 | gdm_reg_dump_v2(eth, i + 1, mib_base); |
| 654 | } |
| 655 | |
| 656 | pr_info("+-----------------------------------------------+\n"); |
| 657 | } |
| 658 | |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 659 | void dump_each_port(struct seq_file *seq, struct mtk_eth *eth, u32 base) |
| 660 | { |
| 661 | u32 pkt_cnt = 0; |
| 662 | int i = 0; |
| 663 | |
| 664 | for (i = 0; i < 7; i++) { |
| 665 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
| 666 | if ((base == 0x402C) && (i == 6)) |
| 667 | base = 0x408C; |
| 668 | else if ((base == 0x408C) && (i == 6)) |
| 669 | base = 0x402C; |
| 670 | else |
| 671 | ; |
| 672 | } |
| 673 | pkt_cnt = mt7530_mdio_r32(eth, (base) + (i * 0x100)); |
| 674 | seq_printf(seq, "%8u ", pkt_cnt); |
| 675 | } |
| 676 | seq_puts(seq, "\n"); |
| 677 | } |
| 678 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 679 | int esw_cnt_read(struct seq_file *seq, void *v) |
| 680 | { |
| 681 | unsigned int pkt_cnt = 0; |
| 682 | int i = 0; |
| 683 | struct mtk_eth *eth = g_eth; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 684 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 685 | gdm_cnt_read(eth); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 686 | |
| 687 | if (!mt7530_exist(eth)) |
| 688 | return 0; |
| 689 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 690 | mt798x_iomap(); |
| 691 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 692 | seq_printf(seq, "===================== %8s %8s %8s %8s %8s %8s %8s\n", |
| 693 | "Port0", "Port1", "Port2", "Port3", "Port4", "Port5", |
| 694 | "Port6"); |
| 695 | seq_puts(seq, "Tx Drop Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 696 | dump_each_port(seq, eth, 0x4000); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 697 | seq_puts(seq, "Tx CRC Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 698 | dump_each_port(seq, eth, 0x4004); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 699 | seq_puts(seq, "Tx Unicast Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 700 | dump_each_port(seq, eth, 0x4008); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 701 | seq_puts(seq, "Tx Multicast Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 702 | dump_each_port(seq, eth, 0x400C); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 703 | seq_puts(seq, "Tx Broadcast Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 704 | dump_each_port(seq, eth, 0x4010); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 705 | seq_puts(seq, "Tx Collision Event :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 706 | dump_each_port(seq, eth, 0x4014); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 707 | seq_puts(seq, "Tx Pause Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 708 | dump_each_port(seq, eth, 0x402C); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 709 | seq_puts(seq, "Rx Drop Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 710 | dump_each_port(seq, eth, 0x4060); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 711 | seq_puts(seq, "Rx Filtering Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 712 | dump_each_port(seq, eth, 0x4064); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 713 | seq_puts(seq, "Rx Unicast Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 714 | dump_each_port(seq, eth, 0x4068); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 715 | seq_puts(seq, "Rx Multicast Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 716 | dump_each_port(seq, eth, 0x406C); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 717 | seq_puts(seq, "Rx Broadcast Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 718 | dump_each_port(seq, eth, 0x4070); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 719 | seq_puts(seq, "Rx Alignment Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 720 | dump_each_port(seq, eth, 0x4074); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 721 | seq_puts(seq, "Rx CRC Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 722 | dump_each_port(seq, eth, 0x4078); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 723 | seq_puts(seq, "Rx Undersize Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 724 | dump_each_port(seq, eth, 0x407C); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 725 | seq_puts(seq, "Rx Fragment Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 726 | dump_each_port(seq, eth, 0x4080); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 727 | seq_puts(seq, "Rx Oversize Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 728 | dump_each_port(seq, eth, 0x4084); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 729 | seq_puts(seq, "Rx Jabber Error :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 730 | dump_each_port(seq, eth, 0x4088); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 731 | seq_puts(seq, "Rx Pause Packet :"); |
developer | 9ccff34 | 2022-10-13 18:28:54 +0800 | [diff] [blame] | 732 | dump_each_port(seq, eth, 0x408C); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 733 | mt7530_mdio_w32(eth, 0x4fe0, 0xf0); |
| 734 | mt7530_mdio_w32(eth, 0x4fe0, 0x800000f0); |
| 735 | |
| 736 | seq_puts(seq, "\n"); |
| 737 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 738 | mt798x_iounmap(); |
| 739 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 740 | return 0; |
| 741 | } |
| 742 | |
| 743 | static int switch_count_open(struct inode *inode, struct file *file) |
| 744 | { |
| 745 | return single_open(file, esw_cnt_read, 0); |
| 746 | } |
| 747 | |
| 748 | static const struct file_operations switch_count_fops = { |
| 749 | .owner = THIS_MODULE, |
| 750 | .open = switch_count_open, |
| 751 | .read = seq_read, |
| 752 | .llseek = seq_lseek, |
| 753 | .release = single_release |
| 754 | }; |
| 755 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 756 | static struct proc_dir_entry *proc_tx_ring, *proc_hwtx_ring, *proc_rx_ring; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 757 | |
| 758 | int tx_ring_read(struct seq_file *seq, void *v) |
| 759 | { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 760 | struct mtk_eth *eth = g_eth; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 761 | struct mtk_tx_ring *ring = &g_eth->tx_ring; |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 762 | struct mtk_tx_dma_v2 *tx_ring; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 763 | int i = 0; |
| 764 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 765 | seq_printf(seq, "free count = %d\n", (int)atomic_read(&ring->free_count)); |
| 766 | seq_printf(seq, "cpu next free: %d\n", (int)(ring->next_free - ring->dma)); |
| 767 | seq_printf(seq, "cpu last free: %d\n", (int)(ring->last_free - ring->dma)); |
| 768 | for (i = 0; i < MTK_DMA_SIZE; i++) { |
developer | 8b6f240 | 2022-11-28 13:42:34 +0800 | [diff] [blame^] | 769 | dma_addr_t tmp = ring->phys + |
| 770 | i * (dma_addr_t)eth->soc->txrx.txd_size; |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 771 | |
| 772 | tx_ring = ring->dma + i * eth->soc->txrx.txd_size; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 773 | |
| 774 | seq_printf(seq, "%d (%pad): %08x %08x %08x %08x", i, &tmp, |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 775 | tx_ring->txd1, tx_ring->txd2, |
| 776 | tx_ring->txd3, tx_ring->txd4); |
| 777 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 778 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 779 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 780 | seq_printf(seq, " %08x %08x %08x %08x", |
| 781 | tx_ring->txd5, tx_ring->txd6, |
| 782 | tx_ring->txd7, tx_ring->txd8); |
| 783 | } |
| 784 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 785 | seq_printf(seq, "\n"); |
| 786 | } |
| 787 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | static int tx_ring_open(struct inode *inode, struct file *file) |
| 792 | { |
| 793 | return single_open(file, tx_ring_read, NULL); |
| 794 | } |
| 795 | |
| 796 | static const struct file_operations tx_ring_fops = { |
| 797 | .owner = THIS_MODULE, |
| 798 | .open = tx_ring_open, |
| 799 | .read = seq_read, |
| 800 | .llseek = seq_lseek, |
| 801 | .release = single_release |
| 802 | }; |
| 803 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 804 | int hwtx_ring_read(struct seq_file *seq, void *v) |
| 805 | { |
| 806 | struct mtk_eth *eth = g_eth; |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 807 | struct mtk_tx_dma_v2 *hwtx_ring; |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 808 | int i = 0; |
| 809 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 810 | for (i = 0; i < MTK_DMA_SIZE; i++) { |
developer | 8b6f240 | 2022-11-28 13:42:34 +0800 | [diff] [blame^] | 811 | dma_addr_t addr = eth->phy_scratch_ring + |
| 812 | i * (dma_addr_t)eth->soc->txrx.txd_size; |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 813 | |
| 814 | hwtx_ring = eth->scratch_ring + i * eth->soc->txrx.txd_size; |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 815 | |
| 816 | seq_printf(seq, "%d (%pad): %08x %08x %08x %08x", i, &addr, |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 817 | hwtx_ring->txd1, hwtx_ring->txd2, |
| 818 | hwtx_ring->txd3, hwtx_ring->txd4); |
| 819 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 820 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 821 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 822 | seq_printf(seq, " %08x %08x %08x %08x", |
| 823 | hwtx_ring->txd5, hwtx_ring->txd6, |
| 824 | hwtx_ring->txd7, hwtx_ring->txd8); |
| 825 | } |
| 826 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 827 | seq_printf(seq, "\n"); |
| 828 | } |
| 829 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 830 | return 0; |
| 831 | } |
| 832 | |
| 833 | static int hwtx_ring_open(struct inode *inode, struct file *file) |
| 834 | { |
| 835 | return single_open(file, hwtx_ring_read, NULL); |
| 836 | } |
| 837 | |
| 838 | static const struct file_operations hwtx_ring_fops = { |
| 839 | .owner = THIS_MODULE, |
| 840 | .open = hwtx_ring_open, |
| 841 | .read = seq_read, |
| 842 | .llseek = seq_lseek, |
| 843 | .release = single_release |
| 844 | }; |
| 845 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 846 | int rx_ring_read(struct seq_file *seq, void *v) |
| 847 | { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 848 | struct mtk_eth *eth = g_eth; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 849 | struct mtk_rx_ring *ring = &g_eth->rx_ring[0]; |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 850 | struct mtk_rx_dma_v2 *rx_ring; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 851 | int i = 0; |
| 852 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 853 | seq_printf(seq, "next to read: %d\n", |
| 854 | NEXT_DESP_IDX(ring->calc_idx, MTK_DMA_SIZE)); |
| 855 | for (i = 0; i < MTK_DMA_SIZE; i++) { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 856 | rx_ring = ring->dma + i * eth->soc->txrx.rxd_size; |
| 857 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 858 | seq_printf(seq, "%d: %08x %08x %08x %08x", i, |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 859 | rx_ring->rxd1, rx_ring->rxd2, |
| 860 | rx_ring->rxd3, rx_ring->rxd4); |
| 861 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 862 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 863 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 864 | seq_printf(seq, " %08x %08x %08x %08x", |
| 865 | rx_ring->rxd5, rx_ring->rxd6, |
| 866 | rx_ring->rxd7, rx_ring->rxd8); |
| 867 | } |
| 868 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 869 | seq_printf(seq, "\n"); |
| 870 | } |
| 871 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 872 | return 0; |
| 873 | } |
| 874 | |
| 875 | static int rx_ring_open(struct inode *inode, struct file *file) |
| 876 | { |
| 877 | return single_open(file, rx_ring_read, NULL); |
| 878 | } |
| 879 | |
| 880 | static const struct file_operations rx_ring_fops = { |
| 881 | .owner = THIS_MODULE, |
| 882 | .open = rx_ring_open, |
| 883 | .read = seq_read, |
| 884 | .llseek = seq_lseek, |
| 885 | .release = single_release |
| 886 | }; |
| 887 | |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 888 | static inline u32 mtk_dbg_r32(u32 reg) |
| 889 | { |
| 890 | void __iomem *virt_reg; |
| 891 | u32 val; |
| 892 | |
| 893 | virt_reg = ioremap(reg, 32); |
| 894 | val = __raw_readl(virt_reg); |
| 895 | iounmap(virt_reg); |
| 896 | |
| 897 | return val; |
| 898 | } |
| 899 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 900 | int dbg_regs_read(struct seq_file *seq, void *v) |
| 901 | { |
| 902 | struct mtk_eth *eth = g_eth; |
| 903 | |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 904 | seq_puts(seq, " <<DEBUG REG DUMP>>\n"); |
| 905 | |
| 906 | seq_printf(seq, "| FE_INT_STA : %08x |\n", |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 907 | mtk_r32(eth, MTK_FE_INT_STATUS)); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 908 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 909 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 910 | seq_printf(seq, "| FE_INT_STA2 : %08x |\n", |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 911 | mtk_r32(eth, MTK_FE_INT_STATUS2)); |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 912 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 913 | seq_printf(seq, "| PSE_FQFC_CFG : %08x |\n", |
| 914 | mtk_r32(eth, MTK_PSE_FQFC_CFG)); |
| 915 | seq_printf(seq, "| PSE_IQ_STA1 : %08x |\n", |
| 916 | mtk_r32(eth, MTK_PSE_IQ_STA(0))); |
| 917 | seq_printf(seq, "| PSE_IQ_STA2 : %08x |\n", |
| 918 | mtk_r32(eth, MTK_PSE_IQ_STA(1))); |
| 919 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 920 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 921 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 922 | seq_printf(seq, "| PSE_IQ_STA3 : %08x |\n", |
| 923 | mtk_r32(eth, MTK_PSE_IQ_STA(2))); |
| 924 | seq_printf(seq, "| PSE_IQ_STA4 : %08x |\n", |
| 925 | mtk_r32(eth, MTK_PSE_IQ_STA(3))); |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 926 | seq_printf(seq, "| PSE_IQ_STA5 : %08x |\n", |
| 927 | mtk_r32(eth, MTK_PSE_IQ_STA(4))); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 928 | seq_printf(seq, "| PSE_IQ_STA6 : %08x |\n", |
| 929 | mtk_r32(eth, MTK_PSE_IQ_STA(5))); |
| 930 | seq_printf(seq, "| PSE_IQ_STA7 : %08x |\n", |
| 931 | mtk_r32(eth, MTK_PSE_IQ_STA(6))); |
| 932 | seq_printf(seq, "| PSE_IQ_STA8 : %08x |\n", |
| 933 | mtk_r32(eth, MTK_PSE_IQ_STA(7))); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | seq_printf(seq, "| PSE_OQ_STA1 : %08x |\n", |
| 937 | mtk_r32(eth, MTK_PSE_OQ_STA(0))); |
| 938 | seq_printf(seq, "| PSE_OQ_STA2 : %08x |\n", |
| 939 | mtk_r32(eth, MTK_PSE_OQ_STA(1))); |
| 940 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 941 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 942 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 943 | seq_printf(seq, "| PSE_OQ_STA3 : %08x |\n", |
| 944 | mtk_r32(eth, MTK_PSE_OQ_STA(2))); |
| 945 | seq_printf(seq, "| PSE_OQ_STA4 : %08x |\n", |
| 946 | mtk_r32(eth, MTK_PSE_OQ_STA(3))); |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 947 | seq_printf(seq, "| PSE_OQ_STA5 : %08x |\n", |
| 948 | mtk_r32(eth, MTK_PSE_OQ_STA(4))); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 949 | seq_printf(seq, "| PSE_OQ_STA6 : %08x |\n", |
| 950 | mtk_r32(eth, MTK_PSE_OQ_STA(5))); |
| 951 | seq_printf(seq, "| PSE_OQ_STA7 : %08x |\n", |
| 952 | mtk_r32(eth, MTK_PSE_OQ_STA(6))); |
| 953 | seq_printf(seq, "| PSE_OQ_STA8 : %08x |\n", |
| 954 | mtk_r32(eth, MTK_PSE_OQ_STA(7))); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 955 | } |
| 956 | |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 957 | seq_printf(seq, "| PDMA_CRX_IDX : %08x |\n", |
| 958 | mtk_r32(eth, MTK_PRX_CRX_IDX0)); |
| 959 | seq_printf(seq, "| PDMA_DRX_IDX : %08x |\n", |
| 960 | mtk_r32(eth, MTK_PRX_DRX_IDX0)); |
| 961 | seq_printf(seq, "| QDMA_CTX_IDX : %08x |\n", |
| 962 | mtk_r32(eth, MTK_QTX_CTX_PTR)); |
| 963 | seq_printf(seq, "| QDMA_DTX_IDX : %08x |\n", |
| 964 | mtk_r32(eth, MTK_QTX_DTX_PTR)); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 965 | seq_printf(seq, "| QDMA_FQ_CNT : %08x |\n", |
| 966 | mtk_r32(eth, MTK_QDMA_FQ_CNT)); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 967 | seq_printf(seq, "| QDMA_FWD_CNT : %08x |\n", |
| 968 | mtk_r32(eth, MTK_QDMA_FWD_CNT)); |
| 969 | seq_printf(seq, "| QDMA_FSM : %08x |\n", |
| 970 | mtk_r32(eth, MTK_QDMA_FSM)); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 971 | seq_printf(seq, "| FE_PSE_FREE : %08x |\n", |
| 972 | mtk_r32(eth, MTK_FE_PSE_FREE)); |
| 973 | seq_printf(seq, "| FE_DROP_FQ : %08x |\n", |
| 974 | mtk_r32(eth, MTK_FE_DROP_FQ)); |
| 975 | seq_printf(seq, "| FE_DROP_FC : %08x |\n", |
| 976 | mtk_r32(eth, MTK_FE_DROP_FC)); |
| 977 | seq_printf(seq, "| FE_DROP_PPE : %08x |\n", |
| 978 | mtk_r32(eth, MTK_FE_DROP_PPE)); |
| 979 | seq_printf(seq, "| GDM1_IG_CTRL : %08x |\n", |
| 980 | mtk_r32(eth, MTK_GDMA_FWD_CFG(0))); |
| 981 | seq_printf(seq, "| GDM2_IG_CTRL : %08x |\n", |
| 982 | mtk_r32(eth, MTK_GDMA_FWD_CFG(1))); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 983 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
| 984 | seq_printf(seq, "| GDM3_IG_CTRL : %08x |\n", |
| 985 | mtk_r32(eth, MTK_GDMA_FWD_CFG(2))); |
| 986 | } |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 987 | seq_printf(seq, "| MAC_P1_MCR : %08x |\n", |
| 988 | mtk_r32(eth, MTK_MAC_MCR(0))); |
| 989 | seq_printf(seq, "| MAC_P2_MCR : %08x |\n", |
| 990 | mtk_r32(eth, MTK_MAC_MCR(1))); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 991 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
| 992 | seq_printf(seq, "| MAC_P3_MCR : %08x |\n", |
| 993 | mtk_r32(eth, MTK_MAC_MCR(2))); |
| 994 | } |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 995 | seq_printf(seq, "| MAC_P1_FSM : %08x |\n", |
| 996 | mtk_r32(eth, MTK_MAC_FSM(0))); |
| 997 | seq_printf(seq, "| MAC_P2_FSM : %08x |\n", |
| 998 | mtk_r32(eth, MTK_MAC_FSM(1))); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 999 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
| 1000 | seq_printf(seq, "| MAC_P3_FSM : %08x |\n", |
| 1001 | mtk_r32(eth, MTK_MAC_FSM(2))); |
| 1002 | } |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1003 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1004 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 1005 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1006 | seq_printf(seq, "| FE_CDM1_FSM : %08x |\n", |
| 1007 | mtk_r32(eth, MTK_FE_CDM1_FSM)); |
| 1008 | seq_printf(seq, "| FE_CDM2_FSM : %08x |\n", |
| 1009 | mtk_r32(eth, MTK_FE_CDM2_FSM)); |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 1010 | seq_printf(seq, "| FE_CDM3_FSM : %08x |\n", |
| 1011 | mtk_r32(eth, MTK_FE_CDM3_FSM)); |
| 1012 | seq_printf(seq, "| FE_CDM4_FSM : %08x |\n", |
| 1013 | mtk_r32(eth, MTK_FE_CDM4_FSM)); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1014 | seq_printf(seq, "| FE_CDM5_FSM : %08x |\n", |
| 1015 | mtk_r32(eth, MTK_FE_CDM5_FSM)); |
| 1016 | seq_printf(seq, "| FE_CDM6_FSM : %08x |\n", |
| 1017 | mtk_r32(eth, MTK_FE_CDM6_FSM)); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1018 | seq_printf(seq, "| FE_GDM1_FSM : %08x |\n", |
| 1019 | mtk_r32(eth, MTK_FE_GDM1_FSM)); |
| 1020 | seq_printf(seq, "| FE_GDM2_FSM : %08x |\n", |
| 1021 | mtk_r32(eth, MTK_FE_GDM2_FSM)); |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 1022 | seq_printf(seq, "| SGMII_EFUSE : %08x |\n", |
| 1023 | mtk_dbg_r32(MTK_SGMII_EFUSE)); |
| 1024 | seq_printf(seq, "| SGMII0_RX_CNT : %08x |\n", |
| 1025 | mtk_dbg_r32(MTK_SGMII_FALSE_CARRIER_CNT(0))); |
| 1026 | seq_printf(seq, "| SGMII1_RX_CNT : %08x |\n", |
| 1027 | mtk_dbg_r32(MTK_SGMII_FALSE_CARRIER_CNT(1))); |
| 1028 | seq_printf(seq, "| WED_RTQM_GLO : %08x |\n", |
| 1029 | mtk_dbg_r32(MTK_WED_RTQM_GLO_CFG)); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1030 | } |
| 1031 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1032 | mtk_w32(eth, 0xffffffff, MTK_FE_INT_STATUS); |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1033 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 1034 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1035 | mtk_w32(eth, 0xffffffff, MTK_FE_INT_STATUS2); |
developer | 77f3fd4 | 2021-10-05 15:16:05 +0800 | [diff] [blame] | 1036 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1037 | return 0; |
| 1038 | } |
| 1039 | |
| 1040 | static int dbg_regs_open(struct inode *inode, struct file *file) |
| 1041 | { |
| 1042 | return single_open(file, dbg_regs_read, 0); |
| 1043 | } |
| 1044 | |
| 1045 | static const struct file_operations dbg_regs_fops = { |
| 1046 | .owner = THIS_MODULE, |
| 1047 | .open = dbg_regs_open, |
| 1048 | .read = seq_read, |
| 1049 | .llseek = seq_lseek, |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1050 | .release = single_release |
| 1051 | }; |
| 1052 | |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 1053 | void hw_lro_stats_update(u32 ring_no, struct mtk_rx_dma_v2 *rxd) |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1054 | { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 1055 | struct mtk_eth *eth = g_eth; |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1056 | u32 idx, agg_cnt, agg_size; |
| 1057 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1058 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 1059 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 1060 | idx = ring_no - 4; |
| 1061 | agg_cnt = RX_DMA_GET_AGG_CNT_V2(rxd->rxd6); |
| 1062 | } else { |
| 1063 | idx = ring_no - 1; |
| 1064 | agg_cnt = RX_DMA_GET_AGG_CNT(rxd->rxd2); |
| 1065 | } |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1066 | |
developer | 8b6f240 | 2022-11-28 13:42:34 +0800 | [diff] [blame^] | 1067 | if (idx >= MTK_HW_LRO_RING_NUM) |
| 1068 | return; |
| 1069 | |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1070 | agg_size = RX_DMA_GET_PLEN0(rxd->rxd2); |
| 1071 | |
| 1072 | hw_lro_agg_size_cnt[idx][agg_size / 5000]++; |
| 1073 | hw_lro_agg_num_cnt[idx][agg_cnt]++; |
| 1074 | hw_lro_tot_flush_cnt[idx]++; |
| 1075 | hw_lro_tot_agg_cnt[idx] += agg_cnt; |
| 1076 | } |
| 1077 | |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 1078 | void hw_lro_flush_stats_update(u32 ring_no, struct mtk_rx_dma_v2 *rxd) |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1079 | { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 1080 | struct mtk_eth *eth = g_eth; |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1081 | u32 idx, flush_reason; |
| 1082 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1083 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 1084 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) { |
developer | e935698 | 2022-07-04 09:03:20 +0800 | [diff] [blame] | 1085 | idx = ring_no - 4; |
| 1086 | flush_reason = RX_DMA_GET_FLUSH_RSN_V2(rxd->rxd6); |
| 1087 | } else { |
| 1088 | idx = ring_no - 1; |
| 1089 | flush_reason = RX_DMA_GET_REV(rxd->rxd2); |
| 1090 | } |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1091 | |
developer | 8b6f240 | 2022-11-28 13:42:34 +0800 | [diff] [blame^] | 1092 | if (idx >= MTK_HW_LRO_RING_NUM) |
| 1093 | return; |
| 1094 | |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1095 | if ((flush_reason & 0x7) == MTK_HW_LRO_AGG_FLUSH) |
| 1096 | hw_lro_agg_flush_cnt[idx]++; |
| 1097 | else if ((flush_reason & 0x7) == MTK_HW_LRO_AGE_FLUSH) |
| 1098 | hw_lro_age_flush_cnt[idx]++; |
| 1099 | else if ((flush_reason & 0x7) == MTK_HW_LRO_NOT_IN_SEQ_FLUSH) |
| 1100 | hw_lro_seq_flush_cnt[idx]++; |
| 1101 | else if ((flush_reason & 0x7) == MTK_HW_LRO_TIMESTAMP_FLUSH) |
| 1102 | hw_lro_timestamp_flush_cnt[idx]++; |
| 1103 | else if ((flush_reason & 0x7) == MTK_HW_LRO_NON_RULE_FLUSH) |
| 1104 | hw_lro_norule_flush_cnt[idx]++; |
| 1105 | } |
| 1106 | |
| 1107 | ssize_t hw_lro_stats_write(struct file *file, const char __user *buffer, |
| 1108 | size_t count, loff_t *data) |
| 1109 | { |
| 1110 | memset(hw_lro_agg_num_cnt, 0, sizeof(hw_lro_agg_num_cnt)); |
| 1111 | memset(hw_lro_agg_size_cnt, 0, sizeof(hw_lro_agg_size_cnt)); |
| 1112 | memset(hw_lro_tot_agg_cnt, 0, sizeof(hw_lro_tot_agg_cnt)); |
| 1113 | memset(hw_lro_tot_flush_cnt, 0, sizeof(hw_lro_tot_flush_cnt)); |
| 1114 | memset(hw_lro_agg_flush_cnt, 0, sizeof(hw_lro_agg_flush_cnt)); |
| 1115 | memset(hw_lro_age_flush_cnt, 0, sizeof(hw_lro_age_flush_cnt)); |
| 1116 | memset(hw_lro_seq_flush_cnt, 0, sizeof(hw_lro_seq_flush_cnt)); |
| 1117 | memset(hw_lro_timestamp_flush_cnt, 0, |
| 1118 | sizeof(hw_lro_timestamp_flush_cnt)); |
| 1119 | memset(hw_lro_norule_flush_cnt, 0, sizeof(hw_lro_norule_flush_cnt)); |
| 1120 | |
| 1121 | pr_info("clear hw lro cnt table\n"); |
| 1122 | |
| 1123 | return count; |
| 1124 | } |
| 1125 | |
| 1126 | int hw_lro_stats_read_v1(struct seq_file *seq, void *v) |
| 1127 | { |
| 1128 | int i; |
| 1129 | |
| 1130 | seq_puts(seq, "HW LRO statistic dump:\n"); |
| 1131 | |
| 1132 | /* Agg number count */ |
| 1133 | seq_puts(seq, "Cnt: RING1 | RING2 | RING3 | Total\n"); |
| 1134 | for (i = 0; i <= MTK_HW_LRO_MAX_AGG_CNT; i++) { |
| 1135 | seq_printf(seq, " %d : %d %d %d %d\n", |
| 1136 | i, hw_lro_agg_num_cnt[0][i], |
| 1137 | hw_lro_agg_num_cnt[1][i], hw_lro_agg_num_cnt[2][i], |
| 1138 | hw_lro_agg_num_cnt[0][i] + hw_lro_agg_num_cnt[1][i] + |
| 1139 | hw_lro_agg_num_cnt[2][i]); |
| 1140 | } |
| 1141 | |
| 1142 | /* Total agg count */ |
| 1143 | seq_puts(seq, "Total agg: RING1 | RING2 | RING3 | Total\n"); |
| 1144 | seq_printf(seq, " %d %d %d %d\n", |
| 1145 | hw_lro_tot_agg_cnt[0], hw_lro_tot_agg_cnt[1], |
| 1146 | hw_lro_tot_agg_cnt[2], |
| 1147 | hw_lro_tot_agg_cnt[0] + hw_lro_tot_agg_cnt[1] + |
| 1148 | hw_lro_tot_agg_cnt[2]); |
| 1149 | |
| 1150 | /* Total flush count */ |
| 1151 | seq_puts(seq, "Total flush: RING1 | RING2 | RING3 | Total\n"); |
| 1152 | seq_printf(seq, " %d %d %d %d\n", |
| 1153 | hw_lro_tot_flush_cnt[0], hw_lro_tot_flush_cnt[1], |
| 1154 | hw_lro_tot_flush_cnt[2], |
| 1155 | hw_lro_tot_flush_cnt[0] + hw_lro_tot_flush_cnt[1] + |
| 1156 | hw_lro_tot_flush_cnt[2]); |
| 1157 | |
| 1158 | /* Avg agg count */ |
| 1159 | seq_puts(seq, "Avg agg: RING1 | RING2 | RING3 | Total\n"); |
| 1160 | seq_printf(seq, " %d %d %d %d\n", |
| 1161 | (hw_lro_tot_flush_cnt[0]) ? |
| 1162 | hw_lro_tot_agg_cnt[0] / hw_lro_tot_flush_cnt[0] : 0, |
| 1163 | (hw_lro_tot_flush_cnt[1]) ? |
| 1164 | hw_lro_tot_agg_cnt[1] / hw_lro_tot_flush_cnt[1] : 0, |
| 1165 | (hw_lro_tot_flush_cnt[2]) ? |
| 1166 | hw_lro_tot_agg_cnt[2] / hw_lro_tot_flush_cnt[2] : 0, |
| 1167 | (hw_lro_tot_flush_cnt[0] + hw_lro_tot_flush_cnt[1] + |
| 1168 | hw_lro_tot_flush_cnt[2]) ? |
| 1169 | ((hw_lro_tot_agg_cnt[0] + hw_lro_tot_agg_cnt[1] + |
| 1170 | hw_lro_tot_agg_cnt[2]) / (hw_lro_tot_flush_cnt[0] + |
| 1171 | hw_lro_tot_flush_cnt[1] + hw_lro_tot_flush_cnt[2])) : 0); |
| 1172 | |
| 1173 | /* Statistics of aggregation size counts */ |
| 1174 | seq_puts(seq, "HW LRO flush pkt len:\n"); |
| 1175 | seq_puts(seq, " Length | RING1 | RING2 | RING3 | Total\n"); |
| 1176 | for (i = 0; i < 15; i++) { |
| 1177 | seq_printf(seq, "%d~%d: %d %d %d %d\n", i * 5000, |
| 1178 | (i + 1) * 5000, hw_lro_agg_size_cnt[0][i], |
| 1179 | hw_lro_agg_size_cnt[1][i], hw_lro_agg_size_cnt[2][i], |
| 1180 | hw_lro_agg_size_cnt[0][i] + |
| 1181 | hw_lro_agg_size_cnt[1][i] + |
| 1182 | hw_lro_agg_size_cnt[2][i]); |
| 1183 | } |
| 1184 | |
| 1185 | seq_puts(seq, "Flush reason: RING1 | RING2 | RING3 | Total\n"); |
| 1186 | seq_printf(seq, "AGG timeout: %d %d %d %d\n", |
| 1187 | hw_lro_agg_flush_cnt[0], hw_lro_agg_flush_cnt[1], |
| 1188 | hw_lro_agg_flush_cnt[2], |
| 1189 | (hw_lro_agg_flush_cnt[0] + hw_lro_agg_flush_cnt[1] + |
| 1190 | hw_lro_agg_flush_cnt[2])); |
| 1191 | |
| 1192 | seq_printf(seq, "AGE timeout: %d %d %d %d\n", |
| 1193 | hw_lro_age_flush_cnt[0], hw_lro_age_flush_cnt[1], |
| 1194 | hw_lro_age_flush_cnt[2], |
| 1195 | (hw_lro_age_flush_cnt[0] + hw_lro_age_flush_cnt[1] + |
| 1196 | hw_lro_age_flush_cnt[2])); |
| 1197 | |
| 1198 | seq_printf(seq, "Not in-sequence: %d %d %d %d\n", |
| 1199 | hw_lro_seq_flush_cnt[0], hw_lro_seq_flush_cnt[1], |
| 1200 | hw_lro_seq_flush_cnt[2], |
| 1201 | (hw_lro_seq_flush_cnt[0] + hw_lro_seq_flush_cnt[1] + |
| 1202 | hw_lro_seq_flush_cnt[2])); |
| 1203 | |
| 1204 | seq_printf(seq, "Timestamp: %d %d %d %d\n", |
| 1205 | hw_lro_timestamp_flush_cnt[0], |
| 1206 | hw_lro_timestamp_flush_cnt[1], |
| 1207 | hw_lro_timestamp_flush_cnt[2], |
| 1208 | (hw_lro_timestamp_flush_cnt[0] + |
| 1209 | hw_lro_timestamp_flush_cnt[1] + |
| 1210 | hw_lro_timestamp_flush_cnt[2])); |
| 1211 | |
| 1212 | seq_printf(seq, "No LRO rule: %d %d %d %d\n", |
| 1213 | hw_lro_norule_flush_cnt[0], |
| 1214 | hw_lro_norule_flush_cnt[1], |
| 1215 | hw_lro_norule_flush_cnt[2], |
| 1216 | (hw_lro_norule_flush_cnt[0] + |
| 1217 | hw_lro_norule_flush_cnt[1] + |
| 1218 | hw_lro_norule_flush_cnt[2])); |
| 1219 | |
| 1220 | return 0; |
| 1221 | } |
| 1222 | |
| 1223 | int hw_lro_stats_read_v2(struct seq_file *seq, void *v) |
| 1224 | { |
| 1225 | int i; |
| 1226 | |
| 1227 | seq_puts(seq, "HW LRO statistic dump:\n"); |
| 1228 | |
| 1229 | /* Agg number count */ |
| 1230 | seq_puts(seq, "Cnt: RING4 | RING5 | RING6 | RING7 Total\n"); |
| 1231 | for (i = 0; i <= MTK_HW_LRO_MAX_AGG_CNT; i++) { |
| 1232 | seq_printf(seq, |
| 1233 | " %d : %d %d %d %d %d\n", |
| 1234 | i, hw_lro_agg_num_cnt[0][i], hw_lro_agg_num_cnt[1][i], |
| 1235 | hw_lro_agg_num_cnt[2][i], hw_lro_agg_num_cnt[3][i], |
| 1236 | hw_lro_agg_num_cnt[0][i] + hw_lro_agg_num_cnt[1][i] + |
| 1237 | hw_lro_agg_num_cnt[2][i] + hw_lro_agg_num_cnt[3][i]); |
| 1238 | } |
| 1239 | |
| 1240 | /* Total agg count */ |
| 1241 | seq_puts(seq, "Total agg: RING4 | RING5 | RING6 | RING7 Total\n"); |
| 1242 | seq_printf(seq, " %d %d %d %d %d\n", |
| 1243 | hw_lro_tot_agg_cnt[0], hw_lro_tot_agg_cnt[1], |
| 1244 | hw_lro_tot_agg_cnt[2], hw_lro_tot_agg_cnt[3], |
| 1245 | hw_lro_tot_agg_cnt[0] + hw_lro_tot_agg_cnt[1] + |
| 1246 | hw_lro_tot_agg_cnt[2] + hw_lro_tot_agg_cnt[3]); |
| 1247 | |
| 1248 | /* Total flush count */ |
| 1249 | seq_puts(seq, "Total flush: RING4 | RING5 | RING6 | RING7 Total\n"); |
| 1250 | seq_printf(seq, " %d %d %d %d %d\n", |
| 1251 | hw_lro_tot_flush_cnt[0], hw_lro_tot_flush_cnt[1], |
| 1252 | hw_lro_tot_flush_cnt[2], hw_lro_tot_flush_cnt[3], |
| 1253 | hw_lro_tot_flush_cnt[0] + hw_lro_tot_flush_cnt[1] + |
| 1254 | hw_lro_tot_flush_cnt[2] + hw_lro_tot_flush_cnt[3]); |
| 1255 | |
| 1256 | /* Avg agg count */ |
| 1257 | seq_puts(seq, "Avg agg: RING4 | RING5 | RING6 | RING7 Total\n"); |
| 1258 | seq_printf(seq, " %d %d %d %d %d\n", |
| 1259 | (hw_lro_tot_flush_cnt[0]) ? |
| 1260 | hw_lro_tot_agg_cnt[0] / hw_lro_tot_flush_cnt[0] : 0, |
| 1261 | (hw_lro_tot_flush_cnt[1]) ? |
| 1262 | hw_lro_tot_agg_cnt[1] / hw_lro_tot_flush_cnt[1] : 0, |
| 1263 | (hw_lro_tot_flush_cnt[2]) ? |
| 1264 | hw_lro_tot_agg_cnt[2] / hw_lro_tot_flush_cnt[2] : 0, |
| 1265 | (hw_lro_tot_flush_cnt[3]) ? |
| 1266 | hw_lro_tot_agg_cnt[3] / hw_lro_tot_flush_cnt[3] : 0, |
| 1267 | (hw_lro_tot_flush_cnt[0] + hw_lro_tot_flush_cnt[1] + |
| 1268 | hw_lro_tot_flush_cnt[2] + hw_lro_tot_flush_cnt[3]) ? |
| 1269 | ((hw_lro_tot_agg_cnt[0] + hw_lro_tot_agg_cnt[1] + |
| 1270 | hw_lro_tot_agg_cnt[2] + hw_lro_tot_agg_cnt[3]) / |
| 1271 | (hw_lro_tot_flush_cnt[0] + hw_lro_tot_flush_cnt[1] + |
| 1272 | hw_lro_tot_flush_cnt[2] + hw_lro_tot_flush_cnt[3])) : 0); |
| 1273 | |
| 1274 | /* Statistics of aggregation size counts */ |
| 1275 | seq_puts(seq, "HW LRO flush pkt len:\n"); |
| 1276 | seq_puts(seq, " Length | RING4 | RING5 | RING6 | RING7 Total\n"); |
| 1277 | for (i = 0; i < 15; i++) { |
| 1278 | seq_printf(seq, "%d~%d: %d %d %d %d %d\n", |
| 1279 | i * 5000, (i + 1) * 5000, |
| 1280 | hw_lro_agg_size_cnt[0][i], hw_lro_agg_size_cnt[1][i], |
| 1281 | hw_lro_agg_size_cnt[2][i], hw_lro_agg_size_cnt[3][i], |
| 1282 | hw_lro_agg_size_cnt[0][i] + |
| 1283 | hw_lro_agg_size_cnt[1][i] + |
| 1284 | hw_lro_agg_size_cnt[2][i] + |
| 1285 | hw_lro_agg_size_cnt[3][i]); |
| 1286 | } |
| 1287 | |
| 1288 | seq_puts(seq, "Flush reason: RING4 | RING5 | RING6 | RING7 Total\n"); |
| 1289 | seq_printf(seq, "AGG timeout: %d %d %d %d %d\n", |
| 1290 | hw_lro_agg_flush_cnt[0], hw_lro_agg_flush_cnt[1], |
| 1291 | hw_lro_agg_flush_cnt[2], hw_lro_agg_flush_cnt[3], |
| 1292 | (hw_lro_agg_flush_cnt[0] + hw_lro_agg_flush_cnt[1] + |
| 1293 | hw_lro_agg_flush_cnt[2] + hw_lro_agg_flush_cnt[3])); |
| 1294 | |
| 1295 | seq_printf(seq, "AGE timeout: %d %d %d %d %d\n", |
| 1296 | hw_lro_age_flush_cnt[0], hw_lro_age_flush_cnt[1], |
| 1297 | hw_lro_age_flush_cnt[2], hw_lro_age_flush_cnt[3], |
| 1298 | (hw_lro_age_flush_cnt[0] + hw_lro_age_flush_cnt[1] + |
| 1299 | hw_lro_age_flush_cnt[2] + hw_lro_age_flush_cnt[3])); |
| 1300 | |
| 1301 | seq_printf(seq, "Not in-sequence: %d %d %d %d %d\n", |
| 1302 | hw_lro_seq_flush_cnt[0], hw_lro_seq_flush_cnt[1], |
| 1303 | hw_lro_seq_flush_cnt[2], hw_lro_seq_flush_cnt[3], |
| 1304 | (hw_lro_seq_flush_cnt[0] + hw_lro_seq_flush_cnt[1] + |
| 1305 | hw_lro_seq_flush_cnt[2] + hw_lro_seq_flush_cnt[3])); |
| 1306 | |
| 1307 | seq_printf(seq, "Timestamp: %d %d %d %d %d\n", |
| 1308 | hw_lro_timestamp_flush_cnt[0], |
| 1309 | hw_lro_timestamp_flush_cnt[1], |
| 1310 | hw_lro_timestamp_flush_cnt[2], |
| 1311 | hw_lro_timestamp_flush_cnt[3], |
| 1312 | (hw_lro_timestamp_flush_cnt[0] + |
| 1313 | hw_lro_timestamp_flush_cnt[1] + |
| 1314 | hw_lro_timestamp_flush_cnt[2] + |
| 1315 | hw_lro_timestamp_flush_cnt[3])); |
| 1316 | |
| 1317 | seq_printf(seq, "No LRO rule: %d %d %d %d %d\n", |
| 1318 | hw_lro_norule_flush_cnt[0], |
| 1319 | hw_lro_norule_flush_cnt[1], |
| 1320 | hw_lro_norule_flush_cnt[2], |
| 1321 | hw_lro_norule_flush_cnt[3], |
| 1322 | (hw_lro_norule_flush_cnt[0] + |
| 1323 | hw_lro_norule_flush_cnt[1] + |
| 1324 | hw_lro_norule_flush_cnt[2] + |
| 1325 | hw_lro_norule_flush_cnt[3])); |
| 1326 | |
| 1327 | return 0; |
| 1328 | } |
| 1329 | |
| 1330 | int hw_lro_stats_read_wrapper(struct seq_file *seq, void *v) |
| 1331 | { |
| 1332 | struct mtk_eth *eth = g_eth; |
| 1333 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1334 | if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2) || |
| 1335 | MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V3)) |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1336 | hw_lro_stats_read_v2(seq, v); |
| 1337 | else |
| 1338 | hw_lro_stats_read_v1(seq, v); |
| 1339 | |
| 1340 | return 0; |
| 1341 | } |
| 1342 | |
| 1343 | static int hw_lro_stats_open(struct inode *inode, struct file *file) |
| 1344 | { |
| 1345 | return single_open(file, hw_lro_stats_read_wrapper, NULL); |
| 1346 | } |
| 1347 | |
| 1348 | static const struct file_operations hw_lro_stats_fops = { |
| 1349 | .owner = THIS_MODULE, |
| 1350 | .open = hw_lro_stats_open, |
| 1351 | .read = seq_read, |
| 1352 | .llseek = seq_lseek, |
| 1353 | .write = hw_lro_stats_write, |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1354 | .release = single_release |
| 1355 | }; |
| 1356 | |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1357 | int hwlro_agg_cnt_ctrl(int cnt) |
| 1358 | { |
| 1359 | int i; |
| 1360 | |
| 1361 | for (i = 1; i <= MTK_HW_LRO_RING_NUM; i++) |
| 1362 | SET_PDMA_RXRING_MAX_AGG_CNT(g_eth, i, cnt); |
| 1363 | |
| 1364 | return 0; |
| 1365 | } |
| 1366 | |
| 1367 | int hwlro_agg_time_ctrl(int time) |
| 1368 | { |
| 1369 | int i; |
| 1370 | |
| 1371 | for (i = 1; i <= MTK_HW_LRO_RING_NUM; i++) |
| 1372 | SET_PDMA_RXRING_AGG_TIME(g_eth, i, time); |
| 1373 | |
| 1374 | return 0; |
| 1375 | } |
| 1376 | |
| 1377 | int hwlro_age_time_ctrl(int time) |
| 1378 | { |
| 1379 | int i; |
| 1380 | |
| 1381 | for (i = 1; i <= MTK_HW_LRO_RING_NUM; i++) |
| 1382 | SET_PDMA_RXRING_AGE_TIME(g_eth, i, time); |
| 1383 | |
| 1384 | return 0; |
| 1385 | } |
| 1386 | |
| 1387 | int hwlro_threshold_ctrl(int bandwidth) |
| 1388 | { |
| 1389 | SET_PDMA_LRO_BW_THRESHOLD(g_eth, bandwidth); |
| 1390 | |
| 1391 | return 0; |
| 1392 | } |
| 1393 | |
| 1394 | int hwlro_ring_enable_ctrl(int enable) |
| 1395 | { |
| 1396 | int i; |
| 1397 | |
| 1398 | pr_info("[%s] %s HW LRO rings\n", __func__, (enable) ? "Enable" : "Disable"); |
| 1399 | |
| 1400 | for (i = 1; i <= MTK_HW_LRO_RING_NUM; i++) |
| 1401 | SET_PDMA_RXRING_VALID(g_eth, i, enable); |
| 1402 | |
| 1403 | return 0; |
| 1404 | } |
| 1405 | |
| 1406 | int hwlro_stats_enable_ctrl(int enable) |
| 1407 | { |
| 1408 | pr_info("[%s] %s HW LRO statistics\n", __func__, (enable) ? "Enable" : "Disable"); |
| 1409 | mtk_hwlro_stats_ebl = enable; |
| 1410 | |
| 1411 | return 0; |
| 1412 | } |
| 1413 | |
| 1414 | static const mtk_lro_dbg_func lro_dbg_func[] = { |
| 1415 | [0] = hwlro_agg_cnt_ctrl, |
| 1416 | [1] = hwlro_agg_time_ctrl, |
| 1417 | [2] = hwlro_age_time_ctrl, |
| 1418 | [3] = hwlro_threshold_ctrl, |
| 1419 | [4] = hwlro_ring_enable_ctrl, |
| 1420 | [5] = hwlro_stats_enable_ctrl, |
| 1421 | }; |
| 1422 | |
| 1423 | ssize_t hw_lro_auto_tlb_write(struct file *file, const char __user *buffer, |
| 1424 | size_t count, loff_t *data) |
| 1425 | { |
| 1426 | char buf[32]; |
| 1427 | char *p_buf; |
| 1428 | char *p_token = NULL; |
| 1429 | char *p_delimiter = " \t"; |
| 1430 | long x = 0, y = 0; |
developer | 4c32b7a | 2021-11-13 16:46:43 +0800 | [diff] [blame] | 1431 | u32 len = count; |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1432 | int ret; |
| 1433 | |
| 1434 | if (len >= sizeof(buf)) { |
| 1435 | pr_info("Input handling fail!\n"); |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1436 | return -1; |
| 1437 | } |
| 1438 | |
| 1439 | if (copy_from_user(buf, buffer, len)) |
| 1440 | return -EFAULT; |
| 1441 | |
| 1442 | buf[len] = '\0'; |
| 1443 | |
| 1444 | p_buf = buf; |
| 1445 | p_token = strsep(&p_buf, p_delimiter); |
| 1446 | if (!p_token) |
| 1447 | x = 0; |
| 1448 | else |
| 1449 | ret = kstrtol(p_token, 10, &x); |
| 1450 | |
| 1451 | p_token = strsep(&p_buf, "\t\n "); |
| 1452 | if (p_token) |
| 1453 | ret = kstrtol(p_token, 10, &y); |
| 1454 | |
| 1455 | if (lro_dbg_func[x] && (ARRAY_SIZE(lro_dbg_func) > x)) |
| 1456 | (*lro_dbg_func[x]) (y); |
| 1457 | |
| 1458 | return count; |
| 1459 | } |
| 1460 | |
| 1461 | void hw_lro_auto_tlb_dump_v1(struct seq_file *seq, u32 index) |
| 1462 | { |
| 1463 | int i; |
| 1464 | struct mtk_lro_alt_v1 alt; |
| 1465 | __be32 addr; |
| 1466 | u32 tlb_info[9]; |
| 1467 | u32 dw_len, cnt, priority; |
| 1468 | u32 entry; |
| 1469 | |
| 1470 | if (index > 4) |
| 1471 | index = index - 1; |
| 1472 | entry = (index * 9) + 1; |
| 1473 | |
| 1474 | /* read valid entries of the auto-learn table */ |
| 1475 | mtk_w32(g_eth, entry, MTK_FE_ALT_CF8); |
| 1476 | |
| 1477 | for (i = 0; i < 9; i++) |
| 1478 | tlb_info[i] = mtk_r32(g_eth, MTK_FE_ALT_SEQ_CFC); |
| 1479 | |
| 1480 | memcpy(&alt, tlb_info, sizeof(struct mtk_lro_alt_v1)); |
| 1481 | |
| 1482 | dw_len = alt.alt_info7.dw_len; |
| 1483 | cnt = alt.alt_info6.cnt; |
| 1484 | |
| 1485 | if (mtk_r32(g_eth, MTK_PDMA_LRO_CTRL_DW0) & MTK_LRO_ALT_PKT_CNT_MODE) |
| 1486 | priority = cnt; /* packet count */ |
| 1487 | else |
| 1488 | priority = dw_len; /* byte count */ |
| 1489 | |
| 1490 | /* dump valid entries of the auto-learn table */ |
| 1491 | if (index >= 4) |
| 1492 | seq_printf(seq, "\n===== TABLE Entry: %d (Act) =====\n", index); |
| 1493 | else |
| 1494 | seq_printf(seq, "\n===== TABLE Entry: %d (LRU) =====\n", index); |
| 1495 | |
| 1496 | if (alt.alt_info8.ipv4) { |
| 1497 | addr = htonl(alt.alt_info1.sip0); |
| 1498 | seq_printf(seq, "SIP = %pI4 (IPv4)\n", &addr); |
| 1499 | } else { |
| 1500 | seq_printf(seq, "SIP = %08X:%08X:%08X:%08X (IPv6)\n", |
| 1501 | alt.alt_info4.sip3, alt.alt_info3.sip2, |
| 1502 | alt.alt_info2.sip1, alt.alt_info1.sip0); |
| 1503 | } |
| 1504 | |
| 1505 | seq_printf(seq, "DIP_ID = %d\n", alt.alt_info8.dip_id); |
| 1506 | seq_printf(seq, "TCP SPORT = %d | TCP DPORT = %d\n", |
| 1507 | alt.alt_info0.stp, alt.alt_info0.dtp); |
| 1508 | seq_printf(seq, "VLAN_VID_VLD = %d\n", alt.alt_info6.vlan_vid_vld); |
| 1509 | seq_printf(seq, "VLAN1 = %d | VLAN2 = %d | VLAN3 = %d | VLAN4 =%d\n", |
| 1510 | (alt.alt_info5.vlan_vid0 & 0xfff), |
| 1511 | ((alt.alt_info5.vlan_vid0 >> 12) & 0xfff), |
| 1512 | ((alt.alt_info6.vlan_vid1 << 8) | |
| 1513 | ((alt.alt_info5.vlan_vid0 >> 24) & 0xfff)), |
| 1514 | ((alt.alt_info6.vlan_vid1 >> 4) & 0xfff)); |
| 1515 | seq_printf(seq, "TPUT = %d | FREQ = %d\n", dw_len, cnt); |
| 1516 | seq_printf(seq, "PRIORITY = %d\n", priority); |
| 1517 | } |
| 1518 | |
| 1519 | void hw_lro_auto_tlb_dump_v2(struct seq_file *seq, u32 index) |
| 1520 | { |
| 1521 | int i; |
| 1522 | struct mtk_lro_alt_v2 alt; |
| 1523 | u32 score = 0, ipv4 = 0; |
| 1524 | u32 ipv6[4] = { 0 }; |
| 1525 | u32 tlb_info[12]; |
| 1526 | |
| 1527 | /* read valid entries of the auto-learn table */ |
| 1528 | mtk_w32(g_eth, index << MTK_LRO_ALT_INDEX_OFFSET, MTK_LRO_ALT_DBG); |
| 1529 | |
| 1530 | for (i = 0; i < 11; i++) |
| 1531 | tlb_info[i] = mtk_r32(g_eth, MTK_LRO_ALT_DBG_DATA); |
| 1532 | |
| 1533 | memcpy(&alt, tlb_info, sizeof(struct mtk_lro_alt_v2)); |
| 1534 | |
| 1535 | if (mtk_r32(g_eth, MTK_PDMA_LRO_CTRL_DW0) & MTK_LRO_ALT_PKT_CNT_MODE) |
| 1536 | score = 1; /* packet count */ |
| 1537 | else |
| 1538 | score = 0; /* byte count */ |
| 1539 | |
| 1540 | /* dump valid entries of the auto-learn table */ |
| 1541 | if (alt.alt_info0.valid) { |
| 1542 | if (index < 5) |
| 1543 | seq_printf(seq, |
| 1544 | "\n===== TABLE Entry: %d (onging) =====\n", |
| 1545 | index); |
| 1546 | else |
| 1547 | seq_printf(seq, |
| 1548 | "\n===== TABLE Entry: %d (candidate) =====\n", |
| 1549 | index); |
| 1550 | |
| 1551 | if (alt.alt_info1.v4_valid) { |
| 1552 | ipv4 = (alt.alt_info4.sip0_h << 23) | |
| 1553 | alt.alt_info5.sip0_l; |
| 1554 | seq_printf(seq, "SIP = 0x%x: (IPv4)\n", ipv4); |
| 1555 | |
| 1556 | ipv4 = (alt.alt_info8.dip0_h << 23) | |
| 1557 | alt.alt_info9.dip0_l; |
| 1558 | seq_printf(seq, "DIP = 0x%x: (IPv4)\n", ipv4); |
| 1559 | } else if (alt.alt_info1.v6_valid) { |
| 1560 | ipv6[3] = (alt.alt_info1.sip3_h << 23) | |
| 1561 | (alt.alt_info2.sip3_l << 9); |
| 1562 | ipv6[2] = (alt.alt_info2.sip2_h << 23) | |
| 1563 | (alt.alt_info3.sip2_l << 9); |
| 1564 | ipv6[1] = (alt.alt_info3.sip1_h << 23) | |
| 1565 | (alt.alt_info4.sip1_l << 9); |
| 1566 | ipv6[0] = (alt.alt_info4.sip0_h << 23) | |
| 1567 | (alt.alt_info5.sip0_l << 9); |
| 1568 | seq_printf(seq, "SIP = 0x%x:0x%x:0x%x:0x%x (IPv6)\n", |
| 1569 | ipv6[3], ipv6[2], ipv6[1], ipv6[0]); |
| 1570 | |
| 1571 | ipv6[3] = (alt.alt_info5.dip3_h << 23) | |
| 1572 | (alt.alt_info6.dip3_l << 9); |
| 1573 | ipv6[2] = (alt.alt_info6.dip2_h << 23) | |
| 1574 | (alt.alt_info7.dip2_l << 9); |
| 1575 | ipv6[1] = (alt.alt_info7.dip1_h << 23) | |
| 1576 | (alt.alt_info8.dip1_l << 9); |
| 1577 | ipv6[0] = (alt.alt_info8.dip0_h << 23) | |
| 1578 | (alt.alt_info9.dip0_l << 9); |
| 1579 | seq_printf(seq, "DIP = 0x%x:0x%x:0x%x:0x%x (IPv6)\n", |
| 1580 | ipv6[3], ipv6[2], ipv6[1], ipv6[0]); |
| 1581 | } |
| 1582 | |
| 1583 | seq_printf(seq, "TCP SPORT = %d | TCP DPORT = %d\n", |
| 1584 | (alt.alt_info9.sp_h << 7) | (alt.alt_info10.sp_l), |
| 1585 | alt.alt_info10.dp); |
| 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | int hw_lro_auto_tlb_read(struct seq_file *seq, void *v) |
| 1590 | { |
| 1591 | int i; |
| 1592 | u32 reg_val; |
| 1593 | u32 reg_op1, reg_op2, reg_op3, reg_op4; |
| 1594 | u32 agg_cnt, agg_time, age_time; |
| 1595 | |
| 1596 | seq_puts(seq, "Usage of /proc/mtketh/hw_lro_auto_tlb:\n"); |
| 1597 | seq_puts(seq, "echo [function] [setting] > /proc/mtketh/hw_lro_auto_tlb\n"); |
| 1598 | seq_puts(seq, "Functions:\n"); |
| 1599 | seq_puts(seq, "[0] = hwlro_agg_cnt_ctrl\n"); |
| 1600 | seq_puts(seq, "[1] = hwlro_agg_time_ctrl\n"); |
| 1601 | seq_puts(seq, "[2] = hwlro_age_time_ctrl\n"); |
| 1602 | seq_puts(seq, "[3] = hwlro_threshold_ctrl\n"); |
| 1603 | seq_puts(seq, "[4] = hwlro_ring_enable_ctrl\n"); |
| 1604 | seq_puts(seq, "[5] = hwlro_stats_enable_ctrl\n\n"); |
| 1605 | |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1606 | if (MTK_HAS_CAPS(g_eth->soc->caps, MTK_NETSYS_V2) || |
| 1607 | MTK_HAS_CAPS(g_eth->soc->caps, MTK_NETSYS_V3)) { |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1608 | for (i = 1; i <= 8; i++) |
| 1609 | hw_lro_auto_tlb_dump_v2(seq, i); |
| 1610 | } else { |
| 1611 | /* Read valid entries of the auto-learn table */ |
| 1612 | mtk_w32(g_eth, 0, MTK_FE_ALT_CF8); |
| 1613 | reg_val = mtk_r32(g_eth, MTK_FE_ALT_SEQ_CFC); |
| 1614 | |
| 1615 | seq_printf(seq, |
| 1616 | "HW LRO Auto-learn Table: (MTK_FE_ALT_SEQ_CFC=0x%x)\n", |
| 1617 | reg_val); |
| 1618 | |
| 1619 | for (i = 7; i >= 0; i--) { |
| 1620 | if (reg_val & (1 << i)) |
| 1621 | hw_lro_auto_tlb_dump_v1(seq, i); |
| 1622 | } |
| 1623 | } |
| 1624 | |
| 1625 | /* Read the agg_time/age_time/agg_cnt of LRO rings */ |
| 1626 | seq_puts(seq, "\nHW LRO Ring Settings\n"); |
| 1627 | |
| 1628 | for (i = 1; i <= MTK_HW_LRO_RING_NUM; i++) { |
| 1629 | reg_op1 = mtk_r32(g_eth, MTK_LRO_CTRL_DW1_CFG(i)); |
| 1630 | reg_op2 = mtk_r32(g_eth, MTK_LRO_CTRL_DW2_CFG(i)); |
| 1631 | reg_op3 = mtk_r32(g_eth, MTK_LRO_CTRL_DW3_CFG(i)); |
| 1632 | reg_op4 = mtk_r32(g_eth, MTK_PDMA_LRO_CTRL_DW2); |
| 1633 | |
| 1634 | agg_cnt = |
| 1635 | ((reg_op3 & 0x3) << 6) | |
| 1636 | ((reg_op2 >> MTK_LRO_RING_AGG_CNT_L_OFFSET) & 0x3f); |
| 1637 | agg_time = (reg_op2 >> MTK_LRO_RING_AGG_TIME_OFFSET) & 0xffff; |
| 1638 | age_time = |
| 1639 | ((reg_op2 & 0x3f) << 10) | |
| 1640 | ((reg_op1 >> MTK_LRO_RING_AGE_TIME_L_OFFSET) & 0x3ff); |
| 1641 | seq_printf(seq, |
| 1642 | "Ring[%d]: MAX_AGG_CNT=%d, AGG_TIME=%d, AGE_TIME=%d, Threshold=%d\n", |
developer | 089e885 | 2022-09-28 14:43:46 +0800 | [diff] [blame] | 1643 | (MTK_HAS_CAPS(g_eth->soc->caps, MTK_NETSYS_V1)) ? i : i+3, |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1644 | agg_cnt, agg_time, age_time, reg_op4); |
| 1645 | } |
| 1646 | |
| 1647 | seq_puts(seq, "\n"); |
| 1648 | |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
| 1652 | static int hw_lro_auto_tlb_open(struct inode *inode, struct file *file) |
| 1653 | { |
| 1654 | return single_open(file, hw_lro_auto_tlb_read, NULL); |
| 1655 | } |
| 1656 | |
| 1657 | static const struct file_operations hw_lro_auto_tlb_fops = { |
| 1658 | .owner = THIS_MODULE, |
| 1659 | .open = hw_lro_auto_tlb_open, |
| 1660 | .read = seq_read, |
| 1661 | .llseek = seq_lseek, |
| 1662 | .write = hw_lro_auto_tlb_write, |
| 1663 | .release = single_release |
| 1664 | }; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1665 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1666 | int reset_event_read(struct seq_file *seq, void *v) |
| 1667 | { |
| 1668 | struct mtk_eth *eth = g_eth; |
| 1669 | struct mtk_reset_event reset_event = eth->reset_event; |
| 1670 | |
| 1671 | seq_printf(seq, "[Event] [Count]\n"); |
| 1672 | seq_printf(seq, " FQ Empty: %d\n", |
| 1673 | reset_event.count[MTK_EVENT_FQ_EMPTY]); |
| 1674 | seq_printf(seq, " TSO Fail: %d\n", |
| 1675 | reset_event.count[MTK_EVENT_TSO_FAIL]); |
| 1676 | seq_printf(seq, " TSO Illegal: %d\n", |
| 1677 | reset_event.count[MTK_EVENT_TSO_ILLEGAL]); |
| 1678 | seq_printf(seq, " TSO Align: %d\n", |
| 1679 | reset_event.count[MTK_EVENT_TSO_ALIGN]); |
| 1680 | seq_printf(seq, " RFIFO OV: %d\n", |
| 1681 | reset_event.count[MTK_EVENT_RFIFO_OV]); |
| 1682 | seq_printf(seq, " RFIFO UF: %d\n", |
| 1683 | reset_event.count[MTK_EVENT_RFIFO_UF]); |
| 1684 | seq_printf(seq, " Force: %d\n", |
| 1685 | reset_event.count[MTK_EVENT_FORCE]); |
| 1686 | seq_printf(seq, "----------------------------\n"); |
| 1687 | seq_printf(seq, " Warm Cnt: %d\n", |
| 1688 | reset_event.count[MTK_EVENT_WARM_CNT]); |
| 1689 | seq_printf(seq, " Cold Cnt: %d\n", |
| 1690 | reset_event.count[MTK_EVENT_COLD_CNT]); |
| 1691 | seq_printf(seq, " Total Cnt: %d\n", |
| 1692 | reset_event.count[MTK_EVENT_TOTAL_CNT]); |
| 1693 | |
| 1694 | return 0; |
| 1695 | } |
| 1696 | |
| 1697 | static int reset_event_open(struct inode *inode, struct file *file) |
| 1698 | { |
| 1699 | return single_open(file, reset_event_read, 0); |
| 1700 | } |
| 1701 | |
| 1702 | ssize_t reset_event_write(struct file *file, const char __user *buffer, |
| 1703 | size_t count, loff_t *data) |
| 1704 | { |
| 1705 | struct mtk_eth *eth = g_eth; |
| 1706 | struct mtk_reset_event *reset_event = ð->reset_event; |
| 1707 | |
| 1708 | memset(reset_event, 0, sizeof(struct mtk_reset_event)); |
| 1709 | pr_info("MTK reset event counter is cleared !\n"); |
| 1710 | |
| 1711 | return count; |
| 1712 | } |
| 1713 | |
| 1714 | static const struct file_operations reset_event_fops = { |
| 1715 | .owner = THIS_MODULE, |
| 1716 | .open = reset_event_open, |
| 1717 | .read = seq_read, |
| 1718 | .llseek = seq_lseek, |
| 1719 | .write = reset_event_write, |
| 1720 | .release = single_release |
| 1721 | }; |
| 1722 | |
| 1723 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1724 | struct proc_dir_entry *proc_reg_dir; |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1725 | static struct proc_dir_entry *proc_esw_cnt, *proc_dbg_regs, *proc_reset_event; |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1726 | |
| 1727 | int debug_proc_init(struct mtk_eth *eth) |
| 1728 | { |
| 1729 | g_eth = eth; |
| 1730 | |
| 1731 | if (!proc_reg_dir) |
| 1732 | proc_reg_dir = proc_mkdir(PROCREG_DIR, NULL); |
| 1733 | |
| 1734 | proc_tx_ring = |
| 1735 | proc_create(PROCREG_TXRING, 0, proc_reg_dir, &tx_ring_fops); |
| 1736 | if (!proc_tx_ring) |
| 1737 | pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_TXRING); |
| 1738 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1739 | proc_hwtx_ring = |
| 1740 | proc_create(PROCREG_HWTXRING, 0, proc_reg_dir, &hwtx_ring_fops); |
| 1741 | if (!proc_hwtx_ring) |
| 1742 | pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_HWTXRING); |
| 1743 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1744 | proc_rx_ring = |
| 1745 | proc_create(PROCREG_RXRING, 0, proc_reg_dir, &rx_ring_fops); |
| 1746 | if (!proc_rx_ring) |
| 1747 | pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_RXRING); |
| 1748 | |
| 1749 | proc_esw_cnt = |
| 1750 | proc_create(PROCREG_ESW_CNT, 0, proc_reg_dir, &switch_count_fops); |
| 1751 | if (!proc_esw_cnt) |
| 1752 | pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_ESW_CNT); |
| 1753 | |
| 1754 | proc_dbg_regs = |
| 1755 | proc_create(PROCREG_DBG_REGS, 0, proc_reg_dir, &dbg_regs_fops); |
| 1756 | if (!proc_dbg_regs) |
| 1757 | pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_DBG_REGS); |
| 1758 | |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1759 | if (g_eth->hwlro) { |
| 1760 | proc_hw_lro_stats = |
| 1761 | proc_create(PROCREG_HW_LRO_STATS, 0, proc_reg_dir, |
| 1762 | &hw_lro_stats_fops); |
| 1763 | if (!proc_hw_lro_stats) |
| 1764 | pr_info("!! FAIL to create %s PROC !!\n", PROCREG_HW_LRO_STATS); |
| 1765 | |
| 1766 | proc_hw_lro_auto_tlb = |
| 1767 | proc_create(PROCREG_HW_LRO_AUTO_TLB, 0, proc_reg_dir, |
| 1768 | &hw_lro_auto_tlb_fops); |
| 1769 | if (!proc_hw_lro_auto_tlb) |
| 1770 | pr_info("!! FAIL to create %s PROC !!\n", |
| 1771 | PROCREG_HW_LRO_AUTO_TLB); |
| 1772 | } |
| 1773 | |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1774 | proc_reset_event = |
| 1775 | proc_create(PROCREG_RESET_EVENT, 0, proc_reg_dir, &reset_event_fops); |
| 1776 | if (!proc_reset_event) |
| 1777 | pr_notice("!! FAIL to create %s PROC !!\n", PROCREG_RESET_EVENT); |
| 1778 | |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1779 | return 0; |
| 1780 | } |
| 1781 | |
| 1782 | void debug_proc_exit(void) |
| 1783 | { |
| 1784 | if (proc_tx_ring) |
| 1785 | remove_proc_entry(PROCREG_TXRING, proc_reg_dir); |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1786 | if (proc_hwtx_ring) |
| 1787 | remove_proc_entry(PROCREG_HWTXRING, proc_reg_dir); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1788 | if (proc_rx_ring) |
| 1789 | remove_proc_entry(PROCREG_RXRING, proc_reg_dir); |
| 1790 | |
| 1791 | if (proc_esw_cnt) |
| 1792 | remove_proc_entry(PROCREG_ESW_CNT, proc_reg_dir); |
| 1793 | |
| 1794 | if (proc_reg_dir) |
| 1795 | remove_proc_entry(PROCREG_DIR, 0); |
| 1796 | |
| 1797 | if (proc_dbg_regs) |
| 1798 | remove_proc_entry(PROCREG_DBG_REGS, proc_reg_dir); |
developer | 77d03a7 | 2021-06-06 00:06:00 +0800 | [diff] [blame] | 1799 | |
| 1800 | if (g_eth->hwlro) { |
| 1801 | if (proc_hw_lro_stats) |
| 1802 | remove_proc_entry(PROCREG_HW_LRO_STATS, proc_reg_dir); |
| 1803 | |
| 1804 | if (proc_hw_lro_auto_tlb) |
| 1805 | remove_proc_entry(PROCREG_HW_LRO_AUTO_TLB, proc_reg_dir); |
| 1806 | } |
developer | 8051e04 | 2022-04-08 13:26:36 +0800 | [diff] [blame] | 1807 | |
| 1808 | if (proc_reset_event) |
| 1809 | remove_proc_entry(PROCREG_RESET_EVENT, proc_reg_dir); |
developer | fd40db2 | 2021-04-29 10:08:25 +0800 | [diff] [blame] | 1810 | } |
| 1811 | |