diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2011-01-08 18:03:57 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2011-01-08 18:03:57 +0000 |
commit | 2743857121688903c2842429f967a5c58059fc9f (patch) | |
tree | 85ce9f9573a895341ad3709b325164e913eaaa24 /target/linux/generic/files/drivers/net/phy | |
parent | 69e8309e23b96176a74c356e47c48bac610bdda1 (diff) |
generic: rtl8366: add debugfs file for VLAN4K table
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@24933 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net/phy')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8366_smi.c | 59 | ||||
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/rtl8366_smi.h | 1 |
2 files changed, 60 insertions, 0 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c index e60b708d74..9fff2cc54a 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.c @@ -561,6 +561,43 @@ static ssize_t rtl8366_read_debugfs_vlan_mc(struct file *file, return simple_read_from_buffer(user_buf, count, ppos, buf, len); } +#define RTL8366_VLAN4K_PAGE_SIZE 64 +#define RTL8366_VLAN4K_NUM_PAGES (4096 / RTL8366_VLAN4K_PAGE_SIZE) + +static ssize_t rtl8366_read_debugfs_vlan_4k(struct file *file, + char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct rtl8366_smi *smi = (struct rtl8366_smi *)file->private_data; + int i, len = 0; + int offset; + char *buf = smi->buf; + + if (smi->dbg_vlan_4k_page >= RTL8366_VLAN4K_NUM_PAGES) { + len += snprintf(buf + len, sizeof(smi->buf) - len, + "invalid page: %u\n", smi->dbg_vlan_4k_page); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); + } + + len += snprintf(buf + len, sizeof(smi->buf) - len, + "%4s %6s %6s %3s\n", + "vid", "member", "untag", "fid"); + + offset = RTL8366_VLAN4K_PAGE_SIZE * smi->dbg_vlan_4k_page; + for (i = 0; i < RTL8366_VLAN4K_PAGE_SIZE; i++) { + struct rtl8366_vlan_4k vlan4k; + + smi->ops->get_vlan_4k(smi, offset + i, &vlan4k); + + len += snprintf(buf + len, sizeof(smi->buf) - len, + "%4d 0x%04x 0x%04x %3d\n", + vlan4k.vid, vlan4k.member, + vlan4k.untag, vlan4k.fid); + } + + return simple_read_from_buffer(user_buf, count, ppos, buf, len); +} + static ssize_t rtl8366_read_debugfs_pvid(struct file *file, char __user *user_buf, size_t count, loff_t *ppos) @@ -703,6 +740,12 @@ static const struct file_operations fops_rtl8366_vlan_mc = { .owner = THIS_MODULE }; +static const struct file_operations fops_rtl8366_vlan_4k = { + .read = rtl8366_read_debugfs_vlan_4k, + .open = rtl8366_debugfs_open, + .owner = THIS_MODULE +}; + static const struct file_operations fops_rtl8366_pvid = { .read = rtl8366_read_debugfs_pvid, .open = rtl8366_debugfs_open, @@ -754,6 +797,22 @@ static void rtl8366_debugfs_init(struct rtl8366_smi *smi) return; } + node = debugfs_create_u8("vlan_4k_page", S_IRUGO | S_IWUSR, root, + &smi->dbg_vlan_4k_page); + if (!node) { + dev_err(smi->parent, "Creating debugfs file '%s' failed\n", + "vlan_4k_page"); + return; + } + + node = debugfs_create_file("vlan_4k", S_IRUSR, root, smi, + &fops_rtl8366_vlan_4k); + if (!node) { + dev_err(smi->parent, "Creating debugfs file '%s' failed\n", + "vlan_4k"); + return; + } + node = debugfs_create_file("pvid", S_IRUSR, root, smi, &fops_rtl8366_pvid); if (!node) { diff --git a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h index bdc7dfb023..12768a4455 100644 --- a/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h +++ b/target/linux/generic/files/drivers/net/phy/rtl8366_smi.h @@ -52,6 +52,7 @@ struct rtl8366_smi { #ifdef CONFIG_RTL8366S_PHY_DEBUG_FS struct dentry *debugfs_root; u16 dbg_reg; + u8 dbg_vlan_4k_page; #endif }; |