From: Vivien Didelot <hidden> Date: 2017-08-14 22:27:15
This patch series adds a generic debugfs interface for the DSA
framework, so that all switch devices benefit from it, e.g. Marvell,
Broadcom, Microchip or any other DSA driver.
This is really convenient for debugging, especially CPU ports and DSA
links which are not exposed to userspace as net device. This interface
is currently the only way to easily inspect the hardware for such ports.
With the patch series, any switch device user is able to query the
hardware for the supported tagging protocol, the ports stats and
registers, as well as their FDB, MDB and VLAN entries.
This support is only compiled if CONFIG_DEBUG_FS is enabled. Below is
and example of usage of this interface on a multi-chip switch fabric:
# mount -t debugfs none /sys/kernel/debug
# cd /sys/kernel/debug/dsa/
# ls
switch0 switch1 switch2
# ls -l switch0/
drwxr-xr-x 2 root root 0 Jan 1 00:00 port0
drwxr-xr-x 2 root root 0 Jan 1 00:00 port1
drwxr-xr-x 2 root root 0 Jan 1 00:00 port2
drwxr-xr-x 2 root root 0 Jan 1 00:00 port5
drwxr-xr-x 2 root root 0 Jan 1 00:00 port6
-r--r--r-- 1 root root 0 Jan 1 00:00 tag_protocol
-r--r--r-- 1 root root 0 Jan 1 00:00 tree
# ls -l switch0/port6
-r--r--r-- 1 root root 0 Jan 1 00:00 fdb
-r--r--r-- 1 root root 0 Jan 1 00:00 mdb
-r--r--r-- 1 root root 0 Jan 1 00:00 regs
-r--r--r-- 1 root root 0 Jan 1 00:00 stats
-r--r--r-- 1 root root 0 Jan 1 00:00 vlan
# cat switch0/port2/vlan
vid 42 pvid untagged
# cat switch0/port1/fdb
vid 0 12:34:56:78:90:ab static unicast
# pr -mt switch0/port{5,6}/stats
in_good_octets : 0 in_good_octets : 13824
in_bad_octets : 0 in_bad_octets : 0
in_unicast : 0 in_unicast : 0
in_broadcasts : 0 in_broadcasts : 216
in_multicasts : 0 in_multicasts : 0
in_pause : 0 in_pause : 0
in_undersize : 0 in_undersize : 0
...
# pr -mt switch0/port{5,6}/regs
0: 4e07 0: 4d04
1: 403e 1: 003d
2: 0000 2: 0000
3: 3521 3: 3521
4: 0533 4: 373f
5: 8000 5: 0000
6: 005f 6: 003f
7: 002a 7: 002a
...
where switch0 port5 and port6 are CPU and DSA ports of a ZII Rev B.
Vivien Didelot (11):
net: dsa: legacy: assign dst->applied
net: dsa: add debugfs interface
net: dsa: debugfs: add tree
net: dsa: debugfs: add tag_protocol
net: dsa: debugfs: add port stats
net: dsa: debugfs: add port registers
net: dsa: debugfs: add port fdb
net: dsa: restore mdb dump
net: dsa: debugfs: add port mdb
net: dsa: restore VLAN dump
net: dsa: debugfs: add port vlan
drivers/net/dsa/b53/b53_common.c | 41 +++
drivers/net/dsa/b53/b53_priv.h | 2 +
drivers/net/dsa/bcm_sf2.c | 1 +
drivers/net/dsa/dsa_loop.c | 38 +++
drivers/net/dsa/microchip/ksz_common.c | 41 +++
drivers/net/dsa/mv88e6xxx/chip.c | 82 +++++-
include/net/dsa.h | 15 ++
net/dsa/Kconfig | 14 +
net/dsa/Makefile | 1 +
net/dsa/debugfs.c | 453 +++++++++++++++++++++++++++++++++
net/dsa/dsa.c | 3 +
net/dsa/dsa2.c | 4 +
net/dsa/dsa_priv.h | 13 +
net/dsa/legacy.c | 7 +
14 files changed, 707 insertions(+), 8 deletions(-)
create mode 100644 net/dsa/debugfs.c
--
2.14.0
From: Vivien Didelot <hidden> Date: 2017-08-14 22:27:12
The "applied" boolean of the dsa_switch_tree is only set in the new
bindings. This patch sets it in the legacy code as well.
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/legacy.c | 3 +++
1 file changed, 3 insertions(+)
From: Vivien Didelot <hidden> Date: 2017-08-14 22:27:18
This commit adds the boiler plate to create a DSA related debug
filesystem entry as well as a "tree" file, containing the tree index.
# cat switch1/tree
0
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/debugfs.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 108 insertions(+)
@@ -19,6 +20,107 @@/* DSA module debugfs directory */staticstructdentry*dsa_debugfs_dir;+structdsa_debugfs_ops{+int(*read)(structdsa_switch*ds,intid,structseq_file*seq);+int(*write)(structdsa_switch*ds,intid,char*buf);+};++structdsa_debugfs_priv{+conststructdsa_debugfs_ops*ops;+structdsa_switch*ds;+intid;+};++staticintdsa_debugfs_show(structseq_file*seq,void*p)+{+structdsa_debugfs_priv*priv=seq->private;+structdsa_switch*ds=priv->ds;++/* Somehow file mode is bypassed... Double check here */+if(!priv->ops->read)+return-EOPNOTSUPP;++returnpriv->ops->read(ds,priv->id,seq);+}++staticssize_tdsa_debugfs_write(structfile*file,constchar__user*user_buf,+size_tcount,loff_t*ppos)+{+structseq_file*seq=file->private_data;+structdsa_debugfs_priv*priv=seq->private;+structdsa_switch*ds=priv->ds;+charbuf[count+1];+interr;++/* Somehow file mode is bypassed... Double check here */+if(!priv->ops->write)+return-EOPNOTSUPP;++if(copy_from_user(buf,user_buf,count))+return-EFAULT;++buf[count]='\0';++err=priv->ops->write(ds,priv->id,buf);++returnerr?err:count;+}++staticintdsa_debugfs_open(structinode*inode,structfile*file)+{+returnsingle_open(file,dsa_debugfs_show,inode->i_private);+}++staticconststructfile_operationsdsa_debugfs_fops={+.open=dsa_debugfs_open,+.read=seq_read,+.write=dsa_debugfs_write,+.llseek=no_llseek,+.release=single_release,+.owner=THIS_MODULE,+};++staticintdsa_debugfs_create_file(structdsa_switch*ds,structdentry*dir,+char*name,intid,+conststructdsa_debugfs_ops*ops)+{+structdsa_debugfs_priv*priv;+structdentry*entry;+umode_tmode;++priv=devm_kzalloc(ds->dev,sizeof(*priv),GFP_KERNEL);+if(!priv)+return-ENOMEM;++priv->ops=ops;+priv->ds=ds;+priv->id=id;++mode=0;+if(ops->read)+mode|=0444;+if(ops->write)+mode|=0200;++entry=debugfs_create_file(name,mode,dir,priv,&dsa_debugfs_fops);+if(IS_ERR_OR_NULL(entry))+return-EFAULT;++return0;+}++staticintdsa_debugfs_tree_read(structdsa_switch*ds,intid,+structseq_file*seq)+{+seq_printf(seq,"%d\n",ds->dst->tree);++return0;+}++staticconststructdsa_debugfs_opsdsa_debugfs_tree_ops={+.read=dsa_debugfs_tree_read,+};+staticintdsa_debugfs_create_port(structdsa_switch*ds,intport){structdentry*dir;
@@ -36,6 +138,7 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)staticintdsa_debugfs_create_switch(structdsa_switch*ds){charname[32];+interr;inti;/* skip if there is no debugfs support */
@@ -48,6 +151,11 @@ static int dsa_debugfs_create_switch(struct dsa_switch *ds)if(IS_ERR_OR_NULL(ds->debugfs_dir))return-EFAULT;+err=dsa_debugfs_create_file(ds,ds->debugfs_dir,"tree",-1,+&dsa_debugfs_tree_ops);+if(err)+returnerr;+for(i=0;i<ds->num_ports;i++){if(!ds->ports[i].dn)continue;
@@ -1053,6 +1053,46 @@ int b53_vlan_del(struct dsa_switch *ds, int port,}EXPORT_SYMBOL(b53_vlan_del);+intb53_vlan_dump(structdsa_switch*ds,intport,dsa_vlan_dump_cb_t*cb,+void*data)+{+structb53_device*dev=ds->priv;+u16vid,vid_start=0,pvid;+structb53_vlan*vl;+booluntagged;+interr=0;++if(is5325(dev)||is5365(dev))+vid_start=1;++b53_read16(dev,B53_VLAN_PAGE,B53_VLAN_PORT_DEF_TAG(port),&pvid);++/* Use our software cache for dumps, since we do not have any HW+*operationreturningonlytheused/validVLANs+*/+for(vid=vid_start;vid<dev->num_vlans;vid++){+vl=&dev->vlans[vid];++if(!vl->valid)+continue;++if(!(vl->members&BIT(port)))+continue;++untagged=false;++if(vl->untag&BIT(port))+untagged=true;++err=cb(vid,pvid==vid,untagged,data);+if(err)+break;+}++returnerr;+}+EXPORT_SYMBOL(b53_vlan_dump);+/* Address Resolution Logic routines */staticintb53_arl_op_wait(structb53_device*dev){
@@ -257,6 +257,43 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,return0;}+staticintdsa_loop_port_vlan_dump(structdsa_switch*ds,intport,+dsa_vlan_dump_cb_t*cb,void*data)+{+structdsa_loop_priv*ps=ds->priv;+structmii_bus*bus=ps->bus;+structdsa_loop_vlan*vl;+u16vid,vid_start=0;+boolpvid,untagged;+interr=0;++dev_dbg(ds->dev,"%s\n",__func__);++/* Just do a sleeping operation to make lockdep checks effective */+mdiobus_read(bus,ps->port_base+port,MII_BMSR);++for(vid=vid_start;vid<DSA_LOOP_VLANS;vid++){+vl=&ps->vlans[vid];++if(!(vl->members&BIT(port)))+continue;++untagged=false;+pvid=false;++if(vl->untagged&BIT(port))+untagged=true;+if(ps->pvid==vid)+pvid=true;++err=cb(vid,pvid,untagged,data);+if(err)+break;+}++returnerr;+}+staticconststructdsa_switch_opsdsa_loop_driver={.get_tag_protocol=dsa_loop_get_protocol,.setup=dsa_loop_setup,
@@ -638,6 +638,46 @@ static int ksz_port_vlan_del(struct dsa_switch *ds, int port,return0;}+staticintksz_port_vlan_dump(structdsa_switch*ds,intport,+dsa_vlan_dump_cb_t*cb,void*data)+{+structksz_device*dev=ds->priv;+structvlan_table*vlan_cache;+boolpvid,untagged;+u16val;+intvid;+interr=0;++mutex_lock(&dev->vlan_mutex);++/* use dev->vlan_cache due to lack of searching valid vlan entry */+for(vid=0;vid<dev->num_vlans;vid++){+vlan_cache=&dev->vlan_cache[vid];++if(!(vlan_cache->table[0]&VLAN_VALID))+continue;++untagged=false;+pvid=false;++if(vlan_cache->table[2]&BIT(port)){+if(vlan_cache->table[1]&BIT(port))+untagged=true;+ksz_pread16(dev,port,REG_PORT_DEFAULT_VID,&val);+if(vid==(val&0xFFFFF))+pvid=true;++err=cb(vid,pvid,untagged,data);+if(err)+break;+}+}++mutex_unlock(&dev->vlan_mutex);++returnerr;+}+structalu_struct{/* entry 1 */u8is_static:1;
From: Vivien Didelot <hidden> Date: 2017-08-14 22:28:16
Add a debug filesystem "vlan" entry to query a port's hardware VLAN
entries through the .port_vlan_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Here are the VLAN entries for a CPU port:
# cat port5/vlan
vid 1
vid 42 pvid
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/debugfs.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
From: Vivien Didelot <hidden> Date: 2017-08-14 22:28:18
Add a debug filesystem "mdb" entry to query a port's hardware MDB
entries through the .port_mdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/debugfs.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
From: Vivien Didelot <hidden> Date: 2017-08-14 22:29:44
Add a debug filesystem "fdb" entry to query a port's hardware FDB
entries through the .port_fdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
# cat port1/fdb
vid 0 12:34:56:78:90:ab static unicast
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
From: Vivien Didelot <hidden> Date: 2017-08-14 22:29:46
The same dsa_fdb_dump_cb_t callback is used since there is no
distinction to do between FDB and MDB entries at this layer.
Implement mv88e6xxx_port_mdb_dump so that multicast addresses associated
to a switch port can be dumped.
Signed-off-by: Vivien Didelot <redacted>
---
drivers/net/dsa/mv88e6xxx/chip.c | 33 +++++++++++++++++++++++++--------
include/net/dsa.h | 3 +++
2 files changed, 28 insertions(+), 8 deletions(-)
@@ -447,6 +447,8 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)dst->cpu_dp->netdev->dsa_ptr=dst;dst->applied=true;+dsa_debugfs_create_tree(dst);+return0;}
@@ -458,6 +460,8 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)if(!dst->applied)return;+dsa_debugfs_destroy_tree(dst);+dst->cpu_dp->netdev->dsa_ptr=NULL;/* If we used a tagging format that doesn't have an ethertype
@@ -672,6 +674,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst){inti;+dsa_debugfs_destroy_tree(dst);+dst->cpu_dp->netdev->dsa_ptr=NULL;/* If we used a tagging format that doesn't have an ethertype
Hi Vivien
Minor nitpick. Rather than -EINVAL, how about seq_puts(seq, "Unknown - Please fix %s\n", __func__);
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-08-14 22:47:14
On Mon, Aug 14, 2017 at 06:22:38PM -0400, Vivien Didelot wrote:
Add a debug filesystem "fdb" entry to query a port's hardware FDB
entries through the .port_fdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
# cat port1/fdb
vid 0 12:34:56:78:90:ab static unicast
Signed-off-by: Vivien Didelot <redacted>
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-08-14 22:48:04
On Mon, Aug 14, 2017 at 06:22:39PM -0400, Vivien Didelot wrote:
The same dsa_fdb_dump_cb_t callback is used since there is no
distinction to do between FDB and MDB entries at this layer.
Implement mv88e6xxx_port_mdb_dump so that multicast addresses associated
to a switch port can be dumped.
Signed-off-by: Vivien Didelot <redacted>
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-08-14 22:50:11
On Mon, Aug 14, 2017 at 06:22:40PM -0400, Vivien Didelot wrote:
Add a debug filesystem "mdb" entry to query a port's hardware MDB
entries through the .port_mdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Signed-off-by: Vivien Didelot <redacted>
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-08-14 22:51:50
On Mon, Aug 14, 2017 at 06:22:41PM -0400, Vivien Didelot wrote:
This commit defines a dsa_vlan_dump_cb_t callback, similar to the FDB
dump callback and partly reverts commit a0b6b8c9fa3c ("net: dsa: Remove
support for vlan dump from DSA's drivers") to restore the DSA drivers
VLAN dump operations.
Signed-off-by: Vivien Didelot <redacted>
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-08-14 22:52:16
On Mon, Aug 14, 2017 at 06:22:42PM -0400, Vivien Didelot wrote:
Add a debug filesystem "vlan" entry to query a port's hardware VLAN
entries through the .port_vlan_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Here are the VLAN entries for a CPU port:
# cat port5/vlan
vid 1
vid 42 pvid
Signed-off-by: Vivien Didelot <redacted>
From: Andrew Lunn <andrew@lunn.ch> Date: 2017-08-14 22:53:02
On Mon, Aug 14, 2017 at 06:22:34PM -0400, Vivien Didelot wrote:
This commit adds the boiler plate to create a DSA related debug
filesystem entry as well as a "tree" file, containing the tree index.
# cat switch1/tree
0
Signed-off-by: Vivien Didelot <redacted>
Subject: [PATCH net-next 06/11] net: dsa: debugfs: add port registers
Add a debug filesystem "regs" entry to query a port's hardware registers
through the .get_regs_len and .get_regs_len switch operations.
This is very convenient because it allows one to dump the registers of
DSA links, which are not exposed to userspace.
This series will be very useful to get various debug information.
Do you have any plan to expand 32bit register access and switch-level registers
In addition to port-level registers?
quoted hunk
+static void dsa_debugfs_regs_read_count(struct dsa_switch *ds, int id,+ struct seq_file *seq, int count)+{+ u16 data[count * ETH_GSTRING_LEN];
I think this should be u16 data[count] because it is value of registers.
quoted hunk
+ struct ethtool_regs regs;+ int i;++ ds->ops->get_regs(ds, id, ®s, data);++ for (i = 0; i < count / 2; i++)+ seq_printf(seq, "%2d: %04x\n", i, data[i]);+}++static int dsa_debugfs_regs_read(struct dsa_switch *ds, int id,+ struct seq_file *seq)+{+ int count;++ if (!ds->ops->get_regs_len || !ds->ops->get_regs)+ return -EOPNOTSUPP;++ count = ds->ops->get_regs_len(ds, id);+ if (count < 0)+ return count;
Because get_regs_len returns length than count per mv88e6xxx/chip.c,
it requires some math before passing to dsa_debugfs_regs_read_count().
It does "count/2" in dsa-debugfs_regs_read_count(), however,
As commented above, "count" is used at "u16 data[...]".
So, it would be nice to match with name. Ie, count or size/length.
Thanks.
Woojung
This commit adds a DEBUG_FS dependent DSA core file creating a generic
debug filesystem interface for the DSA switch devices.
The interface can be mounted with:
# mount -t debugfs none /sys/kernel/debug
The dsa directory contains one directory per switch chip:
# cd /sys/kernel/debug/dsa/
# ls
switch0 switch1 switch2
Each chip directory contains one directory per port:
# ls -l switch0/
drwxr-xr-x 2 root root 0 Jan 1 00:00 port0
drwxr-xr-x 2 root root 0 Jan 1 00:00 port1
drwxr-xr-x 2 root root 0 Jan 1 00:00 port2
drwxr-xr-x 2 root root 0 Jan 1 00:00 port5
drwxr-xr-x 2 root root 0 Jan 1 00:00 port6
Future patches will add entry files to these directories.
Signed-off-by: Vivien Didelot <redacted>
---
quoted hunk
+static int dsa_debugfs_create_switch(struct dsa_switch *ds)+{+ char name[32];+ int i;++ /* skip if there is no debugfs support */+ if (!dsa_debugfs_dir)+ return 0;++ snprintf(name, sizeof(name), DSA_SWITCH_FMT, ds->index);++ ds->debugfs_dir = debugfs_create_dir(name, dsa_debugfs_dir);+ if (IS_ERR_OR_NULL(ds->debugfs_dir))+ return -EFAULT;++ for (i = 0; i < ds->num_ports; i++) {+ if (!ds->ports[i].dn)+ continue;
This won't create port directories when using platform data, can you
check for BIT(i) & ds->enabled_port_mask instead?
--
Florian
Might be worth adding a helper function: does dsa_tag_protocol_to_str()
which is in include/net/dsa.h so it's easy to keep in sync when new
taggers are added, then you can just do:
seq_puts(seq, dsa_tag_protocol_to_str(proto));
and/or use a temporary buffer for adding the trailing newline.
--
Florian
Add a debug filesystem "fdb" entry to query a port's hardware FDB
entries through the .port_fdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
# cat port1/fdb
vid 0 12:34:56:78:90:ab static unicast
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
The same dsa_fdb_dump_cb_t callback is used since there is no
distinction to do between FDB and MDB entries at this layer.
Implement mv88e6xxx_port_mdb_dump so that multicast addresses associated
to a switch port can be dumped.
Signed-off-by: Vivien Didelot <redacted>
---
drivers/net/dsa/mv88e6xxx/chip.c | 33 +++++++++++++++++++++++++--------
include/net/dsa.h | 3 +++
2 files changed, 28 insertions(+), 8 deletions(-)
@@ -1380,7 +1380,7 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,}staticintmv88e6xxx_port_db_dump_fid(structmv88e6xxx_chip*chip,-u16fid,u16vid,intport,+u16fid,u16vid,intport,boolmc,dsa_fdb_dump_cb_t*cb,void*data){structmv88e6xxx_atu_entryaddr;
@@ -1401,11 +1401,14 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,if(addr.trunk||(addr.portvec&BIT(port))==0)continue;-if(!is_unicast_ether_addr(addr.mac))+if((is_unicast_ether_addr(addr.mac)&&mc)||
Should not this remain:
if (!is_unicast_ether_addr(addr.mac) && mc) ||
(is_multicast_ether_addr(addr.mac) && !mc)
here, being:
- if this is an *not* an unicast address and MC dump is requested or
- if this is a multicast address and MC dump is not requested
--
Florian
Add a debug filesystem "mdb" entry to query a port's hardware MDB
entries through the .port_mdb_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Signed-off-by: Vivien Didelot <redacted>
This commit defines a dsa_vlan_dump_cb_t callback, similar to the FDB
dump callback and partly reverts commit a0b6b8c9fa3c ("net: dsa: Remove
support for vlan dump from DSA's drivers") to restore the DSA drivers
VLAN dump operations.
Signed-off-by: Vivien Didelot <redacted>
Add a debug filesystem "vlan" entry to query a port's hardware VLAN
entries through the .port_vlan_dump switch operation.
This is really convenient to query directly the hardware or inspect DSA
or CPU links, since these ports are not exposed to userspace.
Here are the VLAN entries for a CPU port:
# cat port5/vlan
vid 1
vid 42 pvid
Signed-off-by: Vivien Didelot <redacted>
---
net/dsa/debugfs.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
Personal preference: could we just specify something like:
vid 1 (t)
vid 42 (u) pvid
to clearly show which VLAN is tagged/untagged?
Other than that:
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
--
Florian
This patch series adds a generic debugfs interface for the DSA
framework, so that all switch devices benefit from it, e.g. Marvell,
Broadcom, Microchip or any other DSA driver.
This is really convenient for debugging, especially CPU ports and DSA
links which are not exposed to userspace as net device. This interface
is currently the only way to easily inspect the hardware for such ports.
With the patch series, any switch device user is able to query the
hardware for the supported tagging protocol, the ports stats and
registers, as well as their FDB, MDB and VLAN entries.
This support is only compiled if CONFIG_DEBUG_FS is enabled. Below is
and example of usage of this interface on a multi-chip switch fabric:
# mount -t debugfs none /sys/kernel/debug
# cd /sys/kernel/debug/dsa/
# ls
switch0 switch1 switch2
# ls -l switch0/
drwxr-xr-x 2 root root 0 Jan 1 00:00 port0
drwxr-xr-x 2 root root 0 Jan 1 00:00 port1
drwxr-xr-x 2 root root 0 Jan 1 00:00 port2
drwxr-xr-x 2 root root 0 Jan 1 00:00 port5
drwxr-xr-x 2 root root 0 Jan 1 00:00 port6
-r--r--r-- 1 root root 0 Jan 1 00:00 tag_protocol
-r--r--r-- 1 root root 0 Jan 1 00:00 tree
# ls -l switch0/port6
-r--r--r-- 1 root root 0 Jan 1 00:00 fdb
-r--r--r-- 1 root root 0 Jan 1 00:00 mdb
-r--r--r-- 1 root root 0 Jan 1 00:00 regs
-r--r--r-- 1 root root 0 Jan 1 00:00 stats
-r--r--r-- 1 root root 0 Jan 1 00:00 vlan
# cat switch0/port2/vlan
vid 42 pvid untagged
# cat switch0/port1/fdb
vid 0 12:34:56:78:90:ab static unicast
# pr -mt switch0/port{5,6}/stats
in_good_octets : 0 in_good_octets : 13824
in_bad_octets : 0 in_bad_octets : 0
in_unicast : 0 in_unicast : 0
in_broadcasts : 0 in_broadcasts : 216
in_multicasts : 0 in_multicasts : 0
in_pause : 0 in_pause : 0
in_undersize : 0 in_undersize : 0
...
# pr -mt switch0/port{5,6}/regs
0: 4e07 0: 4d04
1: 403e 1: 003d
2: 0000 2: 0000
3: 3521 3: 3521
4: 0533 4: 373f
5: 8000 5: 0000
6: 005f 6: 003f
7: 002a 7: 002a
...
where switch0 port5 and port6 are CPU and DSA ports of a ZII Rev B.
For this whole series:
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
On bcm_sf2
This commit adds the boiler plate to create a DSA related debug
filesystem entry as well as a "tree" file, containing the tree index.
# cat switch1/tree
0
Signed-off-by: Vivien Didelot <redacted>