Commit d35bd876 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

dsa: mv88x6xxx: Add debugfs interface for device map

The device map is used to route packets between cascaded switches.
Add dumping a switches device map via debugfs.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 532c7a35
...@@ -1786,6 +1786,45 @@ static const struct file_operations mv88e6xxx_stats_fops = { ...@@ -1786,6 +1786,45 @@ static const struct file_operations mv88e6xxx_stats_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int mv88e6xxx_device_map_show(struct seq_file *s, void *p)
{
struct dsa_switch *ds = s->private;
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
int target, ret;
seq_puts(s, "Target Port\n");
mutex_lock(&ps->smi_mutex);
for (target = 0; target < 32; target++) {
ret = _mv88e6xxx_reg_write(
ds, REG_GLOBAL2, GLOBAL2_DEVICE_MAPPING,
target << GLOBAL2_DEVICE_MAPPING_TARGET_SHIFT);
if (ret < 0)
goto out;
ret = _mv88e6xxx_reg_read(ds, REG_GLOBAL2,
GLOBAL2_DEVICE_MAPPING);
seq_printf(s, " %2d %2d\n", target,
ret & GLOBAL2_DEVICE_MAPPING_PORT_MASK);
}
out:
mutex_unlock(&ps->smi_mutex);
return 0;
}
static int mv88e6xxx_device_map_open(struct inode *inode, struct file *file)
{
return single_open(file, mv88e6xxx_device_map_show, inode->i_private);
}
static const struct file_operations mv88e6xxx_device_map_fops = {
.open = mv88e6xxx_device_map_open,
.read = seq_read,
.llseek = no_llseek,
.release = single_release,
.owner = THIS_MODULE,
};
int mv88e6xxx_setup_common(struct dsa_switch *ds) int mv88e6xxx_setup_common(struct dsa_switch *ds)
{ {
struct mv88e6xxx_priv_state *ps = ds_to_priv(ds); struct mv88e6xxx_priv_state *ps = ds_to_priv(ds);
...@@ -1812,6 +1851,8 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds) ...@@ -1812,6 +1851,8 @@ int mv88e6xxx_setup_common(struct dsa_switch *ds)
debugfs_create_file("stats", S_IRUGO, ps->dbgfs, ds, debugfs_create_file("stats", S_IRUGO, ps->dbgfs, ds,
&mv88e6xxx_stats_fops); &mv88e6xxx_stats_fops);
debugfs_create_file("device_map", S_IRUGO, ps->dbgfs, ds,
&mv88e6xxx_device_map_fops);
return 0; return 0;
} }
......
...@@ -260,6 +260,7 @@ ...@@ -260,6 +260,7 @@
#define GLOBAL2_DEVICE_MAPPING 0x06 #define GLOBAL2_DEVICE_MAPPING 0x06
#define GLOBAL2_DEVICE_MAPPING_UPDATE BIT(15) #define GLOBAL2_DEVICE_MAPPING_UPDATE BIT(15)
#define GLOBAL2_DEVICE_MAPPING_TARGET_SHIFT 8 #define GLOBAL2_DEVICE_MAPPING_TARGET_SHIFT 8
#define GLOBAL2_DEVICE_MAPPING_PORT_MASK 0x0f
#define GLOBAL2_TRUNK_MASK 0x07 #define GLOBAL2_TRUNK_MASK 0x07
#define GLOBAL2_TRUNK_MASK_UPDATE BIT(15) #define GLOBAL2_TRUNK_MASK_UPDATE BIT(15)
#define GLOBAL2_TRUNK_MASK_NUM_SHIFT 12 #define GLOBAL2_TRUNK_MASK_NUM_SHIFT 12
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment