Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1711515 > unrolled thread

[PATCH net-next 00/11] net: dsa: add generic debugfs interface

Started byVivien Didelot <vivien.didelot@savoirfairelinux.com>
First post2017-08-15 00:30 +0200
Last post2017-08-19 00:00 +0200
Articles 20 on this page of 22 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net-next 00/11] net: dsa: add generic debugfs interface Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:30 +0200
    [PATCH net-next 09/11] net: dsa: debugfs: add port mdb Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:30 +0200
      Re: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb Andrew Lunn <andrew@lunn.ch> - 2017-08-15 01:00 +0200
      Re: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:40 +0200
    [PATCH net-next 01/11] net: dsa: legacy: assign dst->applied Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:30 +0200
      Re: [PATCH net-next 01/11] net: dsa: legacy: assign dst->applied Andrew Lunn <andrew@lunn.ch> - 2017-08-15 01:00 +0200
    [PATCH net-next 08/11] net: dsa: restore mdb dump Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:30 +0200
      Re: [PATCH net-next 08/11] net: dsa: restore mdb dump Andrew Lunn <andrew@lunn.ch> - 2017-08-15 00:50 +0200
      Re: [PATCH net-next 08/11] net: dsa: restore mdb dump Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:40 +0200
    [PATCH net-next 07/11] net: dsa: debugfs: add port fdb Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:40 +0200
      Re: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb Andrew Lunn <andrew@lunn.ch> - 2017-08-15 00:50 +0200
      Re: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:40 +0200
    [PATCH net-next 06/11] net: dsa: debugfs: add port registers Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:40 +0200
      Re: [PATCH net-next 06/11] net: dsa: debugfs: add port registers Andrew Lunn <andrew@lunn.ch> - 2017-08-15 00:50 +0200
      RE: [PATCH net-next 06/11] net: dsa: debugfs: add port registers <Woojung.Huh@microchip.com> - 2017-08-15 18:30 +0200
      Re: [PATCH net-next 06/11] net: dsa: debugfs: add port registers Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:40 +0200
    [PATCH net-next 05/11] net: dsa: debugfs: add port stats Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:40 +0200
      Re: [PATCH net-next 05/11] net: dsa: debugfs: add port stats Andrew Lunn <andrew@lunn.ch> - 2017-08-15 00:50 +0200
      Re: [PATCH net-next 05/11] net: dsa: debugfs: add port stats Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:40 +0200
    [PATCH net-next 02/11] net: dsa: add debugfs interface Vivien Didelot <vivien.didelot@savoirfairelinux.com> - 2017-08-15 00:40 +0200
      Re: [PATCH net-next 02/11] net: dsa: add debugfs interface Florian Fainelli <f.fainelli@gmail.com> - 2017-08-15 19:30 +0200
    Re: [PATCH net-next 00/11] net: dsa: add generic debugfs interface Florian Fainelli <f.fainelli@gmail.com> - 2017-08-19 00:00 +0200

Page 1 of 2  [1] 2  Next page →


#1711515 — [PATCH net-next 00/11] net: dsa: add generic debugfs interface

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:30 +0200
Subject[PATCH net-next 00/11] net: dsa: add generic debugfs interface
Message-ID<uew1Y-1pG-9@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1711516 — [PATCH net-next 09/11] net: dsa: debugfs: add port mdb

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:30 +0200
Subject[PATCH net-next 09/11] net: dsa: debugfs: add port mdb
Message-ID<uew1Y-1pG-27@gated-at.bofh.it>
In reply to#1711515
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 <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/debugfs.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 8204c62dc9c1..98c5068d20da 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -140,6 +140,20 @@ static const struct dsa_debugfs_ops dsa_debugfs_fdb_ops = {
 	.read = dsa_debugfs_fdb_read,
 };
 
+static int dsa_debugfs_mdb_read(struct dsa_switch *ds, int id,
+				struct seq_file *seq)
+{
+	if (!ds->ops->port_mdb_dump)
+		return -EOPNOTSUPP;
+
+	/* same callback as for FDB dump */
+	return ds->ops->port_mdb_dump(ds, id, dsa_debugfs_fdb_dump_cb, seq);
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_mdb_ops = {
+	.read = dsa_debugfs_mdb_read,
+};
+
 static void dsa_debugfs_regs_read_count(struct dsa_switch *ds, int id,
 					struct seq_file *seq, int count)
 {
@@ -289,6 +303,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
 	if (err)
 		return err;
 
+	err = dsa_debugfs_create_file(ds, dir, "mdb", port,
+				      &dsa_debugfs_mdb_ops);
+	if (err)
+		return err;
+
 	err = dsa_debugfs_create_file(ds, dir, "regs", port,
 				      &dsa_debugfs_regs_ops);
 	if (err)
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1711549 — Re: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-15 01:00 +0200
SubjectRe: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb
Message-ID<uewv0-1zq-25@gated-at.bofh.it>
In reply to#1711516
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 <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [next] | [standalone]


#1712392 — Re: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-08-15 19:40 +0200
SubjectRe: [PATCH net-next 09/11] net: dsa: debugfs: add port mdb
Message-ID<ueNYS-4hU-47@gated-at.bofh.it>
In reply to#1711516

On 08/14/2017 03:22 PM, 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 <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1711517 — [PATCH net-next 01/11] net: dsa: legacy: assign dst->applied

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:30 +0200
Subject[PATCH net-next 01/11] net: dsa: legacy: assign dst->applied
Message-ID<uew1Y-1pG-29@gated-at.bofh.it>
In reply to#1711515
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 <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/legacy.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index 91e6f7981d39..a6a0849483d1 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -605,6 +605,7 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
 	 */
 	wmb();
 	dev->dsa_ptr = dst;
+	dst->applied = true;
 
 	return 0;
 }
@@ -689,6 +690,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
 	dsa_cpu_port_ethtool_restore(dst->cpu_dp);
 
 	dev_put(dst->cpu_dp->netdev);
+
+	dst->applied = false;
 }
 
 static int dsa_remove(struct platform_device *pdev)
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1711544 — Re: [PATCH net-next 01/11] net: dsa: legacy: assign dst->applied

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-15 01:00 +0200
SubjectRe: [PATCH net-next 01/11] net: dsa: legacy: assign dst->applied
Message-ID<uewv0-1zq-11@gated-at.bofh.it>
In reply to#1711517
On Mon, Aug 14, 2017 at 06:22:32PM -0400, Vivien Didelot wrote:
> 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.

What is missing here is: Why? 

I see the next patch does a WARN_ON(!applied). Why have a WARN_ON?

  Andrew

[toc] | [prev] | [next] | [standalone]


#1711521 — [PATCH net-next 08/11] net: dsa: restore mdb dump

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:30 +0200
Subject[PATCH net-next 08/11] net: dsa: restore mdb dump
Message-ID<uew1Z-1pG-33@gated-at.bofh.it>
In reply to#1711515
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 <vivien.didelot@savoirfairelinux.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 33 +++++++++++++++++++++++++--------
 include/net/dsa.h                |  3 +++
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 918d8f0fe091..2ad32734b6f6 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -1380,7 +1380,7 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
 }
 
 static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
-				      u16 fid, u16 vid, int port,
+				      u16 fid, u16 vid, int port, bool mc,
 				      dsa_fdb_dump_cb_t *cb, void *data)
 {
 	struct mv88e6xxx_atu_entry addr;
@@ -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) ||
+		    (is_multicast_ether_addr(addr.mac) && !mc))
 			continue;
 
-		is_static = (addr.state ==
-			     MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
+		is_static = addr.state == mc ?
+			MV88E6XXX_G1_ATU_DATA_STATE_MC_STATIC :
+			MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC;
+
 		err = cb(addr.mac, vid, is_static, data);
 		if (err)
 			return err;
@@ -1415,7 +1418,7 @@ static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
 }
 
 static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
-				  dsa_fdb_dump_cb_t *cb, void *data)
+				  bool mc, dsa_fdb_dump_cb_t *cb, void *data)
 {
 	struct mv88e6xxx_vtu_entry vlan = {
 		.vid = chip->info->max_vid,
@@ -1428,7 +1431,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
 	if (err)
 		return err;
 
-	err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, cb, data);
+	err = mv88e6xxx_port_db_dump_fid(chip, fid, 0, port, mc, cb, data);
 	if (err)
 		return err;
 
@@ -1442,7 +1445,7 @@ static int mv88e6xxx_port_db_dump(struct mv88e6xxx_chip *chip, int port,
 			break;
 
 		err = mv88e6xxx_port_db_dump_fid(chip, vlan.fid, vlan.vid, port,
-						 cb, data);
+						 mc, cb, data);
 		if (err)
 			return err;
 	} while (vlan.vid < chip->info->max_vid);
@@ -1457,7 +1460,7 @@ static int mv88e6xxx_port_fdb_dump(struct dsa_switch *ds, int port,
 	int err;
 
 	mutex_lock(&chip->reg_lock);
-	err = mv88e6xxx_port_db_dump(chip, port, cb, data);
+	err = mv88e6xxx_port_db_dump(chip, port, false, cb, data);
 	mutex_unlock(&chip->reg_lock);
 
 	return err;
@@ -3777,6 +3780,19 @@ static int mv88e6xxx_port_mdb_del(struct dsa_switch *ds, int port,
 	return err;
 }
 
+static int mv88e6xxx_port_mdb_dump(struct dsa_switch *ds, int port,
+				   dsa_fdb_dump_cb_t *cb, void *data)
+{
+	struct mv88e6xxx_chip *chip = ds->priv;
+	int err;
+
+	mutex_lock(&chip->reg_lock);
+	err = mv88e6xxx_port_db_dump(chip, port, true, cb, data);
+	mutex_unlock(&chip->reg_lock);
+
+	return err;
+}
+
 static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.probe			= mv88e6xxx_drv_probe,
 	.get_tag_protocol	= mv88e6xxx_get_tag_protocol,
@@ -3810,6 +3826,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = {
 	.port_mdb_prepare       = mv88e6xxx_port_mdb_prepare,
 	.port_mdb_add           = mv88e6xxx_port_mdb_add,
 	.port_mdb_del           = mv88e6xxx_port_mdb_del,
+	.port_mdb_dump          = mv88e6xxx_port_mdb_dump,
 	.crosschip_bridge_join	= mv88e6xxx_crosschip_bridge_join,
 	.crosschip_bridge_leave	= mv88e6xxx_crosschip_bridge_leave,
 };
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 4ef5d38755d9..1fd419031948 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -288,6 +288,7 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
 		return ds->rtable[dst->cpu_dp->ds->index];
 }
 
+/* FDB (and MDB) dump callback */
 typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid,
 			      bool is_static, void *data);
 struct dsa_switch_ops {
@@ -417,6 +418,8 @@ struct dsa_switch_ops {
 				struct switchdev_trans *trans);
 	int	(*port_mdb_del)(struct dsa_switch *ds, int port,
 				const struct switchdev_obj_port_mdb *mdb);
+	int	(*port_mdb_dump)(struct dsa_switch *ds, int port,
+				 dsa_fdb_dump_cb_t *cb, void *data);
 	/*
 	 * RXNFC
 	 */
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1711531 — Re: [PATCH net-next 08/11] net: dsa: restore mdb dump

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-15 00:50 +0200
SubjectRe: [PATCH net-next 08/11] net: dsa: restore mdb dump
Message-ID<uewlj-1wb-13@gated-at.bofh.it>
In reply to#1711521
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 <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [next] | [standalone]


#1712384 — Re: [PATCH net-next 08/11] net: dsa: restore mdb dump

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-08-15 19:40 +0200
SubjectRe: [PATCH net-next 08/11] net: dsa: restore mdb dump
Message-ID<ueNYR-4hU-9@gated-at.bofh.it>
In reply to#1711521

On 08/14/2017 03:22 PM, 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 <vivien.didelot@savoirfairelinux.com>
> ---
>  drivers/net/dsa/mv88e6xxx/chip.c | 33 +++++++++++++++++++++++++--------
>  include/net/dsa.h                |  3 +++
>  2 files changed, 28 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
> index 918d8f0fe091..2ad32734b6f6 100644
> --- a/drivers/net/dsa/mv88e6xxx/chip.c
> +++ b/drivers/net/dsa/mv88e6xxx/chip.c
> @@ -1380,7 +1380,7 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
>  }
>  
>  static int mv88e6xxx_port_db_dump_fid(struct mv88e6xxx_chip *chip,
> -				      u16 fid, u16 vid, int port,
> +				      u16 fid, u16 vid, int port, bool mc,
>  				      dsa_fdb_dump_cb_t *cb, void *data)
>  {
>  	struct mv88e6xxx_atu_entry addr;
> @@ -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

[toc] | [prev] | [next] | [standalone]


#1711522 — [PATCH net-next 07/11] net: dsa: debugfs: add port fdb

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:40 +0200
Subject[PATCH net-next 07/11] net: dsa: debugfs: add port fdb
Message-ID<uewbD-1sJ-5@gated-at.bofh.it>
In reply to#1711515
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 <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 012fcf466cc1..8204c62dc9c1 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -10,6 +10,7 @@
  */
 
 #include <linux/debugfs.h>
+#include <linux/etherdevice.h>
 #include <linux/seq_file.h>
 
 #include "dsa_priv.h"
@@ -109,6 +110,36 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
 	return 0;
 }
 
+static int dsa_debugfs_fdb_dump_cb(const unsigned char *addr, u16 vid,
+				   bool is_static, void *data)
+{
+	struct seq_file *seq = data;
+	int i;
+
+	seq_printf(seq, "vid %d", vid);
+	for (i = 0; i < ETH_ALEN; i++)
+		seq_printf(seq, "%s%02x", i ? ":" : "    ", addr[i]);
+	seq_printf(seq, "    %s", is_static ? "static" : "dynamic");
+	seq_printf(seq, "    %s", is_unicast_ether_addr(addr) ?
+		   "unicast" : "multicast");
+	seq_puts(seq, "\n");
+
+	return 0;
+}
+
+static int dsa_debugfs_fdb_read(struct dsa_switch *ds, int id,
+				struct seq_file *seq)
+{
+	if (!ds->ops->port_fdb_dump)
+		return -EOPNOTSUPP;
+
+	return ds->ops->port_fdb_dump(ds, id, dsa_debugfs_fdb_dump_cb, seq);
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_fdb_ops = {
+	.read = dsa_debugfs_fdb_read,
+};
+
 static void dsa_debugfs_regs_read_count(struct dsa_switch *ds, int id,
 					struct seq_file *seq, int count)
 {
@@ -253,6 +284,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
 	if (IS_ERR_OR_NULL(dir))
 		return -EFAULT;
 
+	err = dsa_debugfs_create_file(ds, dir, "fdb", port,
+				      &dsa_debugfs_fdb_ops);
+	if (err)
+		return err;
+
 	err = dsa_debugfs_create_file(ds, dir, "regs", port,
 				      &dsa_debugfs_regs_ops);
 	if (err)
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1711533 — Re: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-15 00:50 +0200
SubjectRe: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb
Message-ID<uewlk-1wb-15@gated-at.bofh.it>
In reply to#1711522
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 <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [next] | [standalone]


#1712386 — Re: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-08-15 19:40 +0200
SubjectRe: [PATCH net-next 07/11] net: dsa: debugfs: add port fdb
Message-ID<ueNYR-4hU-19@gated-at.bofh.it>
In reply to#1711522

On 08/14/2017 03:22 PM, 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 <vivien.didelot@savoirfairelinux.com>
> ---
>  net/dsa/debugfs.c | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)
> 
> diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
> index 012fcf466cc1..8204c62dc9c1 100644
> --- a/net/dsa/debugfs.c
> +++ b/net/dsa/debugfs.c
> @@ -10,6 +10,7 @@
>   */
>  
>  #include <linux/debugfs.h>
> +#include <linux/etherdevice.h>
>  #include <linux/seq_file.h>
>  
>  #include "dsa_priv.h"
> @@ -109,6 +110,36 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
>  	return 0;
>  }
>  
> +static int dsa_debugfs_fdb_dump_cb(const unsigned char *addr, u16 vid,
> +				   bool is_static, void *data)
> +{
> +	struct seq_file *seq = data;
> +	int i;

unsigned int i?

> +
> +	seq_printf(seq, "vid %d", vid);
> +	for (i = 0; i < ETH_ALEN; i++)
> +		seq_printf(seq, "%s%02x", i ? ":" : "    ", addr[i]);

Too bad we can use %pM here, or can we?

Other than that:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1711523 — [PATCH net-next 06/11] net: dsa: debugfs: add port registers

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:40 +0200
Subject[PATCH net-next 06/11] net: dsa: debugfs: add port registers
Message-ID<uewbD-1sJ-9@gated-at.bofh.it>
In reply to#1711515
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.

Here are the registers of a zii-rev-b CPU and DSA ports:

    # 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
     8: 2080			     8: 2080
     9: 0001			     9: 0001
    10: 0000			    10: 0000
    11: 0020			    11: 0000
    12: 0000			    12: 0000
    13: 0000			    13: 0000
    14: 0000			    14: 0000
    15: 9100			    15: dada
    16: 0000			    16: 0000
    17: 0000			    17: 0000
    18: 0000			    18: 0000
    19: 0000			    19: 00d8
    20: 0000			    20: 0000
    21: 0000			    21: 0000
    22: 0022			    22: 0000
    23: 0000			    23: 0000
    24: 3210			    24: 3210
    25: 7654			    25: 7654
    26: 0000			    26: 0000
    27: 8000			    27: 8000
    28: 0000			    28: 0000
    29: 0000			    29: 0000
    30: 0000			    30: 0000
    31: 0000			    31: 0000

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 5f91b4423404..012fcf466cc1 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -109,6 +109,40 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
 	return 0;
 }
 
+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];
+	struct ethtool_regs regs;
+	int i;
+
+	ds->ops->get_regs(ds, id, &regs, 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;
+
+	dsa_debugfs_regs_read_count(ds, id, seq, count);
+
+	return 0;
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_regs_ops = {
+	.read = dsa_debugfs_regs_read,
+};
+
 static void dsa_debugfs_stats_read_count(struct dsa_switch *ds, int id,
 					 struct seq_file *seq, int count)
 {
@@ -219,6 +253,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
 	if (IS_ERR_OR_NULL(dir))
 		return -EFAULT;
 
+	err = dsa_debugfs_create_file(ds, dir, "regs", port,
+				      &dsa_debugfs_regs_ops);
+	if (err)
+		return err;
+
 	err = dsa_debugfs_create_file(ds, dir, "stats", port,
 				      &dsa_debugfs_stats_ops);
 	if (err)
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1711534 — Re: [PATCH net-next 06/11] net: dsa: debugfs: add port registers

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-15 00:50 +0200
SubjectRe: [PATCH net-next 06/11] net: dsa: debugfs: add port registers
Message-ID<uewlk-1wb-17@gated-at.bofh.it>
In reply to#1711523
On Mon, Aug 14, 2017 at 06:22:37PM -0400, Vivien Didelot wrote:
> 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.
> 
> Here are the registers of a zii-rev-b CPU and DSA ports:
> 
>     # 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
>      8: 2080			     8: 2080
>      9: 0001			     9: 0001
>     10: 0000			    10: 0000
>     11: 0020			    11: 0000
>     12: 0000			    12: 0000
>     13: 0000			    13: 0000
>     14: 0000			    14: 0000
>     15: 9100			    15: dada
>     16: 0000			    16: 0000
>     17: 0000			    17: 0000
>     18: 0000			    18: 0000
>     19: 0000			    19: 00d8
>     20: 0000			    20: 0000
>     21: 0000			    21: 0000
>     22: 0022			    22: 0000
>     23: 0000			    23: 0000
>     24: 3210			    24: 3210
>     25: 7654			    25: 7654
>     26: 0000			    26: 0000
>     27: 8000			    27: 8000
>     28: 0000			    28: 0000
>     29: 0000			    29: 0000
>     30: 0000			    30: 0000
>     31: 0000			    31: 0000
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [next] | [standalone]


#1712323 — RE: [PATCH net-next 06/11] net: dsa: debugfs: add port registers

From<Woojung.Huh@microchip.com>
Date2017-08-15 18:30 +0200
SubjectRE: [PATCH net-next 06/11] net: dsa: debugfs: add port registers
Message-ID<ueMT9-3Ar-39@gated-at.bofh.it>
In reply to#1711523
Vivien,

> 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?

> +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.

> +	struct ethtool_regs regs;
> +	int i;
> +
> +	ds->ops->get_regs(ds, id, &regs, 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

[toc] | [prev] | [next] | [standalone]


#1712390 — Re: [PATCH net-next 06/11] net: dsa: debugfs: add port registers

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-08-15 19:40 +0200
SubjectRe: [PATCH net-next 06/11] net: dsa: debugfs: add port registers
Message-ID<ueNYS-4hU-33@gated-at.bofh.it>
In reply to#1711523

On 08/14/2017 03:22 PM, Vivien Didelot wrote:
> 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.
> 
> Here are the registers of a zii-rev-b CPU and DSA ports:
> 
>     # 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
>      8: 2080			     8: 2080
>      9: 0001			     9: 0001
>     10: 0000			    10: 0000
>     11: 0020			    11: 0000
>     12: 0000			    12: 0000
>     13: 0000			    13: 0000
>     14: 0000			    14: 0000
>     15: 9100			    15: dada
>     16: 0000			    16: 0000
>     17: 0000			    17: 0000
>     18: 0000			    18: 0000
>     19: 0000			    19: 00d8
>     20: 0000			    20: 0000
>     21: 0000			    21: 0000
>     22: 0022			    22: 0000
>     23: 0000			    23: 0000
>     24: 3210			    24: 3210
>     25: 7654			    25: 7654
>     26: 0000			    26: 0000
>     27: 8000			    27: 8000
>     28: 0000			    28: 0000
>     29: 0000			    29: 0000
>     30: 0000			    30: 0000
>     31: 0000			    31: 0000
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>


Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1711524 — [PATCH net-next 05/11] net: dsa: debugfs: add port stats

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:40 +0200
Subject[PATCH net-next 05/11] net: dsa: debugfs: add port stats
Message-ID<uewbD-1sJ-13@gated-at.bofh.it>
In reply to#1711515
Add a debug filesystem "stats" entry to query a port's hardware
statistics through the DSA switch .get_sset_count, .get_strings and
.get_ethtool_stats operations.

This allows one to get statistics about DSA links interconnecting
switches, which is very convenient because this kind of port is not
exposed to userspace.

Here are the stats of a zii-rev-b DSA and CPU ports:

    # 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
    in_fragments        : 0             in_fragments        : 0
    in_oversize         : 0             in_oversize         : 0
    in_jabber           : 0             in_jabber           : 0
    in_rx_error         : 0             in_rx_error         : 0
    in_fcs_error        : 0             in_fcs_error        : 0
    out_octets          : 9216          out_octets          : 0
    out_unicast         : 0             out_unicast         : 0
    out_broadcasts      : 144           out_broadcasts      : 0
    out_multicasts      : 0             out_multicasts      : 0
    out_pause           : 0             out_pause           : 0
    excessive           : 0             excessive           : 0
    collisions          : 0             collisions          : 0
    deferred            : 0             deferred            : 0
    single              : 0             single              : 0
    multiple            : 0             multiple            : 0
    out_fcs_error       : 0             out_fcs_error       : 0
    late                : 0             late                : 0
    hist_64bytes        : 0             hist_64bytes        : 0
    hist_65_127bytes    : 0             hist_65_127bytes    : 0
    hist_128_255bytes   : 0             hist_128_255bytes   : 0
    hist_256_511bytes   : 0             hist_256_511bytes   : 0
    hist_512_1023bytes  : 0             hist_512_1023bytes  : 0
    hist_1024_max_bytes : 0             hist_1024_max_bytes : 0
    sw_in_discards      : 0             sw_in_discards      : 0
    sw_in_filtered      : 0             sw_in_filtered      : 0
    sw_out_filtered     : 0             sw_out_filtered     : 216

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 net/dsa/debugfs.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
index 30a732e86161..5f91b4423404 100644
--- a/net/dsa/debugfs.c
+++ b/net/dsa/debugfs.c
@@ -109,6 +109,43 @@ static int dsa_debugfs_create_file(struct dsa_switch *ds, struct dentry *dir,
 	return 0;
 }
 
+static void dsa_debugfs_stats_read_count(struct dsa_switch *ds, int id,
+					 struct seq_file *seq, int count)
+{
+	u8 strings[count * ETH_GSTRING_LEN];
+	u64 stats[count];
+	int i;
+
+	ds->ops->get_strings(ds, id, strings);
+	ds->ops->get_ethtool_stats(ds, id, stats);
+
+	for (i = 0; i < count; i++)
+		seq_printf(seq, "%-20s: %lld\n", strings + i * ETH_GSTRING_LEN,
+			   stats[i]);
+}
+
+static int dsa_debugfs_stats_read(struct dsa_switch *ds, int id,
+				  struct seq_file *seq)
+{
+	int count;
+
+	if (!ds->ops->get_sset_count || !ds->ops->get_strings ||
+	    !ds->ops->get_ethtool_stats)
+		return -EOPNOTSUPP;
+
+	count = ds->ops->get_sset_count(ds);
+	if (count < 0)
+		return count;
+
+	dsa_debugfs_stats_read_count(ds, id, seq, count);
+
+	return 0;
+}
+
+static const struct dsa_debugfs_ops dsa_debugfs_stats_ops = {
+	.read = dsa_debugfs_stats_read,
+};
+
 static int dsa_debugfs_tag_protocol_read(struct dsa_switch *ds, int id,
 					 struct seq_file *seq)
 {
@@ -174,6 +211,7 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
 {
 	struct dentry *dir;
 	char name[32];
+	int err;
 
 	snprintf(name, sizeof(name), DSA_PORT_FMT, port);
 
@@ -181,6 +219,11 @@ static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
 	if (IS_ERR_OR_NULL(dir))
 		return -EFAULT;
 
+	err = dsa_debugfs_create_file(ds, dir, "stats", port,
+				      &dsa_debugfs_stats_ops);
+	if (err)
+		return err;
+
 	return 0;
 }
 
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


#1711535 — Re: [PATCH net-next 05/11] net: dsa: debugfs: add port stats

FromAndrew Lunn <andrew@lunn.ch>
Date2017-08-15 00:50 +0200
SubjectRe: [PATCH net-next 05/11] net: dsa: debugfs: add port stats
Message-ID<uewlk-1wb-21@gated-at.bofh.it>
In reply to#1711524
On Mon, Aug 14, 2017 at 06:22:36PM -0400, Vivien Didelot wrote:
> Add a debug filesystem "stats" entry to query a port's hardware
> statistics through the DSA switch .get_sset_count, .get_strings and
> .get_ethtool_stats operations.
> 
> This allows one to get statistics about DSA links interconnecting
> switches, which is very convenient because this kind of port is not
> exposed to userspace.
> 
> Here are the stats of a zii-rev-b DSA and CPU ports:
> 
>     # 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
>     in_fragments        : 0             in_fragments        : 0
>     in_oversize         : 0             in_oversize         : 0
>     in_jabber           : 0             in_jabber           : 0
>     in_rx_error         : 0             in_rx_error         : 0
>     in_fcs_error        : 0             in_fcs_error        : 0
>     out_octets          : 9216          out_octets          : 0
>     out_unicast         : 0             out_unicast         : 0
>     out_broadcasts      : 144           out_broadcasts      : 0
>     out_multicasts      : 0             out_multicasts      : 0
>     out_pause           : 0             out_pause           : 0
>     excessive           : 0             excessive           : 0
>     collisions          : 0             collisions          : 0
>     deferred            : 0             deferred            : 0
>     single              : 0             single              : 0
>     multiple            : 0             multiple            : 0
>     out_fcs_error       : 0             out_fcs_error       : 0
>     late                : 0             late                : 0
>     hist_64bytes        : 0             hist_64bytes        : 0
>     hist_65_127bytes    : 0             hist_65_127bytes    : 0
>     hist_128_255bytes   : 0             hist_128_255bytes   : 0
>     hist_256_511bytes   : 0             hist_256_511bytes   : 0
>     hist_512_1023bytes  : 0             hist_512_1023bytes  : 0
>     hist_1024_max_bytes : 0             hist_1024_max_bytes : 0
>     sw_in_discards      : 0             sw_in_discards      : 0
>     sw_in_filtered      : 0             sw_in_filtered      : 0
>     sw_out_filtered     : 0             sw_out_filtered     : 216
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

[toc] | [prev] | [next] | [standalone]


#1712387 — Re: [PATCH net-next 05/11] net: dsa: debugfs: add port stats

FromFlorian Fainelli <f.fainelli@gmail.com>
Date2017-08-15 19:40 +0200
SubjectRe: [PATCH net-next 05/11] net: dsa: debugfs: add port stats
Message-ID<ueNYS-4hU-29@gated-at.bofh.it>
In reply to#1711524

On 08/14/2017 03:22 PM, Vivien Didelot wrote:
> Add a debug filesystem "stats" entry to query a port's hardware
> statistics through the DSA switch .get_sset_count, .get_strings and
> .get_ethtool_stats operations.
> 
> This allows one to get statistics about DSA links interconnecting
> switches, which is very convenient because this kind of port is not
> exposed to userspace.
> 
> Here are the stats of a zii-rev-b DSA and CPU ports:
> 
>     # 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
>     in_fragments        : 0             in_fragments        : 0
>     in_oversize         : 0             in_oversize         : 0
>     in_jabber           : 0             in_jabber           : 0
>     in_rx_error         : 0             in_rx_error         : 0
>     in_fcs_error        : 0             in_fcs_error        : 0
>     out_octets          : 9216          out_octets          : 0
>     out_unicast         : 0             out_unicast         : 0
>     out_broadcasts      : 144           out_broadcasts      : 0
>     out_multicasts      : 0             out_multicasts      : 0
>     out_pause           : 0             out_pause           : 0
>     excessive           : 0             excessive           : 0
>     collisions          : 0             collisions          : 0
>     deferred            : 0             deferred            : 0
>     single              : 0             single              : 0
>     multiple            : 0             multiple            : 0
>     out_fcs_error       : 0             out_fcs_error       : 0
>     late                : 0             late                : 0
>     hist_64bytes        : 0             hist_64bytes        : 0
>     hist_65_127bytes    : 0             hist_65_127bytes    : 0
>     hist_128_255bytes   : 0             hist_128_255bytes   : 0
>     hist_256_511bytes   : 0             hist_256_511bytes   : 0
>     hist_512_1023bytes  : 0             hist_512_1023bytes  : 0
>     hist_1024_max_bytes : 0             hist_1024_max_bytes : 0
>     sw_in_discards      : 0             sw_in_discards      : 0
>     sw_in_filtered      : 0             sw_in_filtered      : 0
>     sw_out_filtered     : 0             sw_out_filtered     : 216
> 
> Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

[toc] | [prev] | [next] | [standalone]


#1711528 — [PATCH net-next 02/11] net: dsa: add debugfs interface

FromVivien Didelot <vivien.didelot@savoirfairelinux.com>
Date2017-08-15 00:40 +0200
Subject[PATCH net-next 02/11] net: dsa: add debugfs interface
Message-ID<uewbD-1sJ-19@gated-at.bofh.it>
In reply to#1711515
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 <vivien.didelot@savoirfairelinux.com>
---
 include/net/dsa.h  |   7 ++++
 net/dsa/Kconfig    |  14 +++++++
 net/dsa/Makefile   |   1 +
 net/dsa/debugfs.c  | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 net/dsa/dsa.c      |   3 ++
 net/dsa/dsa2.c     |   4 ++
 net/dsa/dsa_priv.h |  13 ++++++
 net/dsa/legacy.c   |   4 ++
 8 files changed, 167 insertions(+)
 create mode 100644 net/dsa/debugfs.c

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 7f46b521313e..4ef5d38755d9 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -212,6 +212,13 @@ struct dsa_switch {
 	 */
 	void *priv;
 
+#ifdef CONFIG_NET_DSA_DEBUGFS
+	/*
+	 * Debugfs interface.
+	 */
+	struct dentry *debugfs_dir;
+#endif
+
 	/*
 	 * Configuration data for this switch.
 	 */
diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
index cc5f8f971689..0f05a1e59dd2 100644
--- a/net/dsa/Kconfig
+++ b/net/dsa/Kconfig
@@ -15,6 +15,20 @@ config NET_DSA
 
 if NET_DSA
 
+config NET_DSA_DEBUGFS
+	bool "Distributed Switch Architecture debugfs interface"
+	depends on DEBUG_FS
+	---help---
+	  Enable creation of debugfs files for the DSA core.
+
+	  These debugfs files provide per-switch information, such as the tag
+	  protocol in use and ports connectivity. They also allow querying the
+	  hardware directly through the switch operations for debugging instead
+	  of going through the bridge, switchdev and DSA layers.
+
+	  This is also a way to inspect the stats and FDB, MDB or VLAN entries
+	  of CPU and DSA links, since they are not exposed to userspace.
+
 # tagging formats
 config NET_DSA_TAG_BRCM
 	bool
diff --git a/net/dsa/Makefile b/net/dsa/Makefile
index fcce25da937c..7f60c6dfaffb 100644
--- a/net/dsa/Makefile
+++ b/net/dsa/Makefile
@@ -1,6 +1,7 @@
 # the core
 obj-$(CONFIG_NET_DSA) += dsa_core.o
 dsa_core-y += dsa.o dsa2.o legacy.o port.o slave.o switch.o
+dsa_core-$(CONFIG_NET_DSA_DEBUGFS) += debugfs.o
 
 # tagging formats
 dsa_core-$(CONFIG_NET_DSA_TAG_BRCM) += tag_brcm.o
diff --git a/net/dsa/debugfs.c b/net/dsa/debugfs.c
new file mode 100644
index 000000000000..68caf5a2c0c3
--- /dev/null
+++ b/net/dsa/debugfs.c
@@ -0,0 +1,121 @@
+/*
+ * net/dsa/debugfs.c - DSA debugfs interface
+ * Copyright (c) 2017 Savoir-faire Linux, Inc.
+ *	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include <linux/debugfs.h>
+
+#include "dsa_priv.h"
+
+#define DSA_SWITCH_FMT	"switch%d"
+#define DSA_PORT_FMT	"port%d"
+
+/* DSA module debugfs directory */
+static struct dentry *dsa_debugfs_dir;
+
+static int dsa_debugfs_create_port(struct dsa_switch *ds, int port)
+{
+	struct dentry *dir;
+	char name[32];
+
+	snprintf(name, sizeof(name), DSA_PORT_FMT, port);
+
+	dir = debugfs_create_dir(name, ds->debugfs_dir);
+	if (IS_ERR_OR_NULL(dir))
+		return -EFAULT;
+
+	return 0;
+}
+
+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;
+
+		err = dsa_debugfs_create_port(ds, i);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
+
+static void dsa_debugfs_destroy_switch(struct dsa_switch *ds)
+{
+	/* handles NULL */
+	debugfs_remove_recursive(ds->debugfs_dir);
+}
+
+void dsa_debugfs_create_tree(struct dsa_switch_tree *dst)
+{
+	struct dsa_switch *ds;
+	int i, err;
+
+	WARN_ON(!dst->applied);
+
+	for (i = 0; i < DSA_MAX_SWITCHES; i++) {
+		ds = dst->ds[i];
+		if (!ds)
+			continue;
+
+		err = dsa_debugfs_create_switch(ds);
+		if (err) {
+			pr_warn("DSA: failed to create debugfs interface for switch %d (%d)\n",
+				ds->index, err);
+			dsa_debugfs_destroy_tree(dst);
+			break;
+		}
+	}
+}
+
+void dsa_debugfs_destroy_tree(struct dsa_switch_tree *dst)
+{
+	struct dsa_switch *ds;
+	int i;
+
+	for (i = 0; i < DSA_MAX_SWITCHES; i++) {
+		ds = dst->ds[i];
+		if (!ds)
+			continue;
+
+		dsa_debugfs_destroy_switch(ds);
+	}
+}
+
+void dsa_debugfs_create_module(void)
+{
+	dsa_debugfs_dir = debugfs_create_dir("dsa", NULL);
+	if (IS_ERR(dsa_debugfs_dir)) {
+		pr_warn("DSA: failed to create debugfs interface\n");
+		dsa_debugfs_dir = NULL;
+	}
+
+	if (dsa_debugfs_dir)
+		pr_info("DSA: debugfs interface created\n");
+}
+
+void dsa_debugfs_destroy_module(void)
+{
+	/* handles NULL */
+	debugfs_remove_recursive(dsa_debugfs_dir);
+}
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 99e38af85fc5..62e49ff6d737 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -308,12 +308,15 @@ static int __init dsa_init_module(void)
 
 	dev_add_pack(&dsa_pack_type);
 
+	dsa_debugfs_create_module();
+
 	return 0;
 }
 module_init(dsa_init_module);
 
 static void __exit dsa_cleanup_module(void)
 {
+	dsa_debugfs_destroy_module();
 	dsa_slave_unregister_notifier();
 	dev_remove_pack(&dsa_pack_type);
 	dsa_legacy_unregister();
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index cceaa4dd9f53..5912618ad63d 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -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);
+
 	return 0;
 }
 
@@ -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
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 9c3eeb72462d..84ca3a50a58b 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -93,6 +93,19 @@ struct dsa_slave_priv {
 	struct list_head	mall_tc_list;
 };
 
+/* debugfs.c */
+#ifdef CONFIG_NET_DSA_DEBUGFS
+void dsa_debugfs_create_module(void);
+void dsa_debugfs_destroy_module(void);
+void dsa_debugfs_create_tree(struct dsa_switch_tree *dst);
+void dsa_debugfs_destroy_tree(struct dsa_switch_tree *dst);
+#else
+static inline void dsa_debugfs_create_module(void) { }
+static inline void dsa_debugfs_destroy_module(void) { }
+static inline void dsa_debugfs_create_tree(struct dsa_switch_tree *dst) { }
+static inline void dsa_debugfs_destroy_tree(struct dsa_switch_tree *dst) { }
+#endif
+
 /* dsa.c */
 int dsa_cpu_dsa_setup(struct dsa_port *port);
 void dsa_cpu_dsa_destroy(struct dsa_port *dport);
diff --git a/net/dsa/legacy.c b/net/dsa/legacy.c
index a6a0849483d1..007034ebd218 100644
--- a/net/dsa/legacy.c
+++ b/net/dsa/legacy.c
@@ -607,6 +607,8 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
 	dev->dsa_ptr = dst;
 	dst->applied = true;
 
+	dsa_debugfs_create_tree(dst);
+
 	return 0;
 }
 
@@ -672,6 +674,8 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
 {
 	int i;
 
+	dsa_debugfs_destroy_tree(dst);
+
 	dst->cpu_dp->netdev->dsa_ptr = NULL;
 
 	/* If we used a tagging format that doesn't have an ethertype
-- 
2.14.0

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | linux.kernel


csiph-web