Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1711510 > unrolled thread
| Started by | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| First post | 2017-08-15 00:30 +0200 |
| Last post | 2017-08-15 19:50 +0200 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH net-next 11/11] net: dsa: debugfs: add port vlan Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:30 +0200
Re: [PATCH net-next 11/11] net: dsa: debugfs: add port vlan Andrew Lunn <andrew@lunn.ch> - 2017-08-15 01:00 +0200
Re: [PATCH net-next 11/11] net: dsa: debugfs: add port vlan Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:50 +0200
| From | Vivien Didelot <vivien.didelot@savoirfairelinux.com> |
|---|---|
| Date | 2017-08-15 00:30 +0200 |
| Subject | [PATCH net-next 11/11] net: dsa: debugfs: add port vlan |
| Message-ID | <uew1Y-1pG-7@gated-at.bofh.it> |
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 <vivien.didelot@savoirfairelinux.com>
---
net/dsa/debugfs.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 98c5068d20da..b00942368d29 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -286,6 +286,34 @@ static const struct dsa_debugfs_ops dsa_debugfs_tree_ops = {
.read = dsa_debugfs_tree_read,
};
+static int dsa_debugfs_vlan_dump_cb(u16 vid, bool pvid, bool untagged,
+ void *data)
+{
+ struct seq_file *seq = data;
+
+ seq_printf(seq, "vid %d", vid);
+ if (pvid)
+ seq_puts(seq, " pvid");
+ if (untagged)
+ seq_puts(seq, " untagged");
+ seq_puts(seq, "\n");
+
+ return 0;
+}
+
+static int dsa_debugfs_vlan_read(struct dsa_switch *ds, int id,
+ struct seq_file *seq)
+{
+ if (!ds->ops->port_vlan_dump)
+ return -EOPNOTSUPP;
+
+ return ds->ops->port_vlan_dump(ds, id, dsa_debugfs_vlan_dump_cb, seq);
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_vlan_ops = {
+ .read = dsa_debugfs_vlan_read,
+};
+
static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
{
struct dentry *dir;
@@ -318,6 +346,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
if (err)
return err;
+ err = dsa_debugfs_create_file(ds, dir, "vlan", port,
+ &dsa_debugfs_vlan_ops);
+ if (err)
+ return err;
+
return 0;
}
--
2.14.0
[toc] | [next] | [standalone]
| From | Andrew Lunn <andrew@lunn.ch> |
|---|---|
| Date | 2017-08-15 01:00 +0200 |
| Message-ID | <uewuZ-1zq-7@gated-at.bofh.it> |
| In reply to | #1711510 |
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 <vivien.didelot@savoirfairelinux.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
[toc] | [prev] | [next] | [standalone]
| From | Florian Fainelli <f.fainelli@gmail.com> |
|---|---|
| Date | 2017-08-15 19:50 +0200 |
| Message-ID | <ueO8y-4lv-1@gated-at.bofh.it> |
| In reply to | #1711510 |
On 08/14/2017 03:22 PM, 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 <vivien.didelot@savoirfairelinux.com>
> ---
> net/dsa/debugfs.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
> index 98c5068d20da..b00942368d29 100644
> --- a/net/dsa/debugfs.c
> +++ b/net/dsa/debugfs.c
> @@ -286,6 +286,34 @@ static const struct dsa_debugfs_ops dsa_debugfs_tree_ops = {
> .read = dsa_debugfs_tree_read,
> };
>
> +static int dsa_debugfs_vlan_dump_cb(u16 vid, bool pvid, bool untagged,
> + void *data)
> +{
> + struct seq_file *seq = data;
> +
> + seq_printf(seq, "vid %d", vid);
> + if (pvid)
> + seq_puts(seq, " pvid");
> + if (untagged)
> + seq_puts(seq, " untagged");
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web