[PATCH net-next 0/5] net: dsa: loop: Preparatory changes for

STALE2246d

15 messages, 3 authors, 2020-08-04 · open the first message on its own page

[PATCH net-next 0/5] net: dsa: loop: Preparatory changes for

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:04:00

Hi David,

These patches are all meant to help pave the way for a 802.1Q data path
added to the mockup driver, making it more useful than just testing for
configuration. Sending those out now since there is no real need to
wait.

Thanks

Florian Fainelli (5):
  net: dsa: loop: PVID should be per-port
  net: dsa: loop: Support 4K VLANs
  net: dsa: loop: Move data structures to header
  net: dsa: loop: Wire-up MTU callbacks
  net: dsa: loop: Set correct number of ports

 drivers/net/dsa/dsa_loop.c | 61 ++++++++++++++------------------------
 include/linux/dsa/loop.h   | 41 +++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 38 deletions(-)
 create mode 100644 include/linux/dsa/loop.h

-- 
2.25.1

[PATCH net-next 2/5] net: dsa: loop: Support 4K VLANs

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:04:05

Allocate a 4K array of VLANs instead of limiting ourselves to just 5
which is arbitrary.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 4a57238cdfd8..6e97b44c6f3f 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -48,12 +48,10 @@ struct dsa_loop_port {
 	u16 pvid;
 };
 
-#define DSA_LOOP_VLANS	5
-
 struct dsa_loop_priv {
 	struct mii_bus	*bus;
 	unsigned int	port_base;
-	struct dsa_loop_vlan vlans[DSA_LOOP_VLANS];
+	struct dsa_loop_vlan vlans[VLAN_N_VID];
 	struct net_device *netdev;
 	struct dsa_loop_port ports[DSA_MAX_PORTS];
 };
@@ -191,7 +189,7 @@ dsa_loop_port_vlan_prepare(struct dsa_switch *ds, int port,
 	/* Just do a sleeping operation to make lockdep checks effective */
 	mdiobus_read(bus, ps->port_base + port, MII_BMSR);
 
-	if (vlan->vid_end > DSA_LOOP_VLANS)
+	if (vlan->vid_end > ARRAY_SIZE(ps->vlans))
 		return -ERANGE;
 
 	return 0;
-- 
2.25.1

[PATCH net-next 4/5] net: dsa: loop: Wire-up MTU callbacks

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:04:07

For now we simply store the port MTU into a per-port member.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 17 +++++++++++++++++
 include/linux/dsa/loop.h   |  1 +
 2 files changed, 18 insertions(+)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index ed0b580c9944..6a7d661b5a59 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -225,6 +225,21 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
 	return 0;
 }
 
+static int dsa_loop_port_change_mtu(struct dsa_switch *ds, int port,
+				    int new_mtu)
+{
+	struct dsa_loop_priv *priv = ds->priv;
+
+	priv->ports[port].mtu = new_mtu;
+
+	return 0;
+}
+
+static int dsa_loop_port_max_mtu(struct dsa_switch *ds, int port)
+{
+	return ETH_MAX_MTU;
+}
+
 static const struct dsa_switch_ops dsa_loop_driver = {
 	.get_tag_protocol	= dsa_loop_get_protocol,
 	.setup			= dsa_loop_setup,
@@ -241,6 +256,8 @@ static const struct dsa_switch_ops dsa_loop_driver = {
 	.port_vlan_prepare	= dsa_loop_port_vlan_prepare,
 	.port_vlan_add		= dsa_loop_port_vlan_add,
 	.port_vlan_del		= dsa_loop_port_vlan_del,
+	.port_change_mtu	= dsa_loop_port_change_mtu,
+	.port_max_mtu		= dsa_loop_port_max_mtu,
 };
 
 static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
diff --git a/include/linux/dsa/loop.h b/include/linux/dsa/loop.h
index bb39401a8056..5a3470bcc8a7 100644
--- a/include/linux/dsa/loop.h
+++ b/include/linux/dsa/loop.h
@@ -27,6 +27,7 @@ enum dsa_loop_mib_counters {
 struct dsa_loop_port {
 	struct dsa_loop_mib_entry mib[__DSA_LOOP_CNT_MAX];
 	u16 pvid;
+	int mtu;
 };
 
 struct dsa_loop_priv {
-- 
2.25.1

[PATCH net-next 5/5] net: dsa: loop: Set correct number of ports

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:04:09

We only support DSA_LOOP_NUM_PORTS in the switch, do not tell the DSA
core to allocate up to DSA_MAX_PORTS which is nearly the double (6 vs.
11).

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 6a7d661b5a59..eb600b3dbf26 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -275,7 +275,7 @@ static int dsa_loop_drv_probe(struct mdio_device *mdiodev)
 		return -ENOMEM;
 
 	ds->dev = &mdiodev->dev;
-	ds->num_ports = DSA_MAX_PORTS;
+	ds->num_ports = DSA_LOOP_NUM_PORTS;
 
 	ps = devm_kzalloc(&mdiodev->dev, sizeof(*ps), GFP_KERNEL);
 	if (!ps)
-- 
2.25.1

[PATCH net-next 3/5] net: dsa: loop: Move data structures to header

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:04:10

In preparation for adding support for a mockup data path, move the
driver data structures to include/linux/dsa/loop.h such that we can
share them between net/dsa/ and drivers/net/dsa/ later on.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 32 +-----------------------------
 include/linux/dsa/loop.h   | 40 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 31 deletions(-)
 create mode 100644 include/linux/dsa/loop.h
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 6e97b44c6f3f..ed0b580c9944 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -14,28 +14,11 @@
 #include <linux/workqueue.h>
 #include <linux/module.h>
 #include <linux/if_bridge.h>
+#include <linux/dsa/loop.h>
 #include <net/dsa.h>
 
 #include "dsa_loop.h"
 
-struct dsa_loop_vlan {
-	u16 members;
-	u16 untagged;
-};
-
-struct dsa_loop_mib_entry {
-	char name[ETH_GSTRING_LEN];
-	unsigned long val;
-};
-
-enum dsa_loop_mib_counters {
-	DSA_LOOP_PHY_READ_OK,
-	DSA_LOOP_PHY_READ_ERR,
-	DSA_LOOP_PHY_WRITE_OK,
-	DSA_LOOP_PHY_WRITE_ERR,
-	__DSA_LOOP_CNT_MAX,
-};
-
 static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
 	[DSA_LOOP_PHY_READ_OK]	= { "phy_read_ok", },
 	[DSA_LOOP_PHY_READ_ERR]	= { "phy_read_err", },
@@ -43,19 +26,6 @@ static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
 	[DSA_LOOP_PHY_WRITE_ERR] = { "phy_write_err", },
 };
 
-struct dsa_loop_port {
-	struct dsa_loop_mib_entry mib[__DSA_LOOP_CNT_MAX];
-	u16 pvid;
-};
-
-struct dsa_loop_priv {
-	struct mii_bus	*bus;
-	unsigned int	port_base;
-	struct dsa_loop_vlan vlans[VLAN_N_VID];
-	struct net_device *netdev;
-	struct dsa_loop_port ports[DSA_MAX_PORTS];
-};
-
 static struct phy_device *phydevs[PHY_MAX_ADDR];
 
 static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,
diff --git a/include/linux/dsa/loop.h b/include/linux/dsa/loop.h
new file mode 100644
index 000000000000..bb39401a8056
--- /dev/null
+++ b/include/linux/dsa/loop.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef DSA_LOOP_H
+#define DSA_LOOP_H
+
+#include <linux/types.h>
+#include <linux/ethtool.h>
+#include <net/dsa.h>
+
+struct dsa_loop_vlan {
+	u16 members;
+	u16 untagged;
+};
+
+struct dsa_loop_mib_entry {
+	char name[ETH_GSTRING_LEN];
+	unsigned long val;
+};
+
+enum dsa_loop_mib_counters {
+	DSA_LOOP_PHY_READ_OK,
+	DSA_LOOP_PHY_READ_ERR,
+	DSA_LOOP_PHY_WRITE_OK,
+	DSA_LOOP_PHY_WRITE_ERR,
+	__DSA_LOOP_CNT_MAX,
+};
+
+struct dsa_loop_port {
+	struct dsa_loop_mib_entry mib[__DSA_LOOP_CNT_MAX];
+	u16 pvid;
+};
+
+struct dsa_loop_priv {
+	struct mii_bus	*bus;
+	unsigned int	port_base;
+	struct dsa_loop_vlan vlans[VLAN_N_VID];
+	struct net_device *netdev;
+	struct dsa_loop_port ports[DSA_MAX_PORTS];
+};
+
+#endif /* DSA_LOOP_H */
-- 
2.25.1

[PATCH net-next 1/5] net: dsa: loop: PVID should be per-port

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:04:12

The PVID should be per-port, this is a preliminary change to support a
802.1Q data path in the driver.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index f8bc85a6e670..4a57238cdfd8 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -45,6 +45,7 @@ static struct dsa_loop_mib_entry dsa_loop_mibs[] = {
 
 struct dsa_loop_port {
 	struct dsa_loop_mib_entry mib[__DSA_LOOP_CNT_MAX];
+	u16 pvid;
 };
 
 #define DSA_LOOP_VLANS	5
@@ -55,7 +56,6 @@ struct dsa_loop_priv {
 	struct dsa_loop_vlan vlans[DSA_LOOP_VLANS];
 	struct net_device *netdev;
 	struct dsa_loop_port ports[DSA_MAX_PORTS];
-	u16 pvid;
 };
 
 static struct phy_device *phydevs[PHY_MAX_ADDR];
@@ -224,7 +224,7 @@ static void dsa_loop_port_vlan_add(struct dsa_switch *ds, int port,
 	}
 
 	if (pvid)
-		ps->pvid = vid;
+		ps->ports[port].pvid = vid;
 }
 
 static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
@@ -234,7 +234,7 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
 	struct dsa_loop_priv *ps = ds->priv;
 	struct mii_bus *bus = ps->bus;
 	struct dsa_loop_vlan *vl;
-	u16 vid, pvid = ps->pvid;
+	u16 vid, pvid = ps->ports[port].pvid;
 
 	/* Just do a sleeping operation to make lockdep checks effective */
 	mdiobus_read(bus, ps->port_base + port, MII_BMSR);
@@ -252,7 +252,7 @@ static int dsa_loop_port_vlan_del(struct dsa_switch *ds, int port,
 		dev_dbg(ds->dev, "%s: port: %d vlan: %d, %stagged, pvid: %d\n",
 			__func__, port, vid, untagged ? "un" : "", pvid);
 	}
-	ps->pvid = pvid;
+	ps->ports[port].pvid = pvid;
 
 	return 0;
 }
-- 
2.25.1

Re: [PATCH net-next 2/5] net: dsa: loop: Support 4K VLANs

From: Andrew Lunn <andrew@lunn.ch>
Date: 2020-08-03 20:27:42

On Mon, Aug 03, 2020 at 01:03:51PM -0700, Florian Fainelli wrote:
quoted hunk
Allocate a 4K array of VLANs instead of limiting ourselves to just 5
which is arbitrary.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 4a57238cdfd8..6e97b44c6f3f 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -48,12 +48,10 @@ struct dsa_loop_port {
 	u16 pvid;
 };
 
-#define DSA_LOOP_VLANS	5
-
 struct dsa_loop_priv {
 	struct mii_bus	*bus;
 	unsigned int	port_base;
-	struct dsa_loop_vlan vlans[DSA_LOOP_VLANS];
+	struct dsa_loop_vlan vlans[VLAN_N_VID];
 	struct net_device *netdev;
 	struct dsa_loop_port ports[DSA_MAX_PORTS];
That is 4K x (2 x u16) = 16K RAM. I suppose for a test driver which is
never expected to be used in production, that is O.K.

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

    Andrew

Re: [PATCH net-next 2/5] net: dsa: loop: Support 4K VLANs

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:29:21


On 8/3/2020 1:27 PM, Andrew Lunn wrote:
On Mon, Aug 03, 2020 at 01:03:51PM -0700, Florian Fainelli wrote:
quoted
Allocate a 4K array of VLANs instead of limiting ourselves to just 5
which is arbitrary.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/dsa/dsa_loop.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/dsa/dsa_loop.c b/drivers/net/dsa/dsa_loop.c
index 4a57238cdfd8..6e97b44c6f3f 100644
--- a/drivers/net/dsa/dsa_loop.c
+++ b/drivers/net/dsa/dsa_loop.c
@@ -48,12 +48,10 @@ struct dsa_loop_port {
 	u16 pvid;
 };
 
-#define DSA_LOOP_VLANS	5
-
 struct dsa_loop_priv {
 	struct mii_bus	*bus;
 	unsigned int	port_base;
-	struct dsa_loop_vlan vlans[DSA_LOOP_VLANS];
+	struct dsa_loop_vlan vlans[VLAN_N_VID];
 	struct net_device *netdev;
 	struct dsa_loop_port ports[DSA_MAX_PORTS];
That is 4K x (2 x u16) = 16K RAM. I suppose for a test driver which is
never expected to be used in production, that is O.K.
I think so too, if we are worried we could switch to vmalloc() down the
road.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
-- 
Florian

Re: [PATCH net-next 5/5] net: dsa: loop: Set correct number of ports

From: Andrew Lunn <andrew@lunn.ch>
Date: 2020-08-03 20:29:24

On Mon, Aug 03, 2020 at 01:03:54PM -0700, Florian Fainelli wrote:
We only support DSA_LOOP_NUM_PORTS in the switch, do not tell the DSA
core to allocate up to DSA_MAX_PORTS which is nearly the double (6 vs.
11).

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

Re: [PATCH net-next 4/5] net: dsa: loop: Wire-up MTU callbacks

From: Andrew Lunn <andrew@lunn.ch>
Date: 2020-08-03 20:29:40

On Mon, Aug 03, 2020 at 01:03:53PM -0700, Florian Fainelli wrote:
For now we simply store the port MTU into a per-port member.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

Re: [PATCH net-next 0/5] net: dsa: loop: Preparatory changes for

From: Andrew Lunn <andrew@lunn.ch>
Date: 2020-08-03 20:33:59

On Mon, Aug 03, 2020 at 01:03:49PM -0700, Florian Fainelli wrote:
Hi David,

These patches are all meant to help pave the way for a 802.1Q data path
added to the mockup driver, making it more useful than just testing for
configuration.
Could you give some more details. I assume the tag driver is going be
to more active. At least, that would make sense with the data
structure moves.

	  Andrew

Re: [PATCH net-next 1/5] net: dsa: loop: PVID should be per-port

From: Andrew Lunn <andrew@lunn.ch>
Date: 2020-08-03 20:34:35

On Mon, Aug 03, 2020 at 01:03:50PM -0700, Florian Fainelli wrote:
The PVID should be per-port, this is a preliminary change to support a
802.1Q data path in the driver.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

Re: [PATCH net-next 0/5] net: dsa: loop: Preparatory changes for

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-03 20:36:58


On 8/3/2020 1:33 PM, Andrew Lunn wrote:
On Mon, Aug 03, 2020 at 01:03:49PM -0700, Florian Fainelli wrote:
quoted
Hi David,

These patches are all meant to help pave the way for a 802.1Q data path
added to the mockup driver, making it more useful than just testing for
configuration.
Could you give some more details. I assume the tag driver is going be
to more active. At least, that would make sense with the data
structure moves.
Still working on a 802.1Q data path that allows to carry VLAN tags from
the DSA CPU interface (guest side) to a tap (host side) and from there
you can ping, bridge etc. devices. I am having some problems with the
responses sent back to the guest which are incorrectly tagged on ingress.

You can see the WIP here:
https://github.com/ffainelli/linux/commits/dsa-loop-8021q
-- 
Florian

Re: [PATCH net-next 0/5] net: dsa: loop: Preparatory changes for

From: David Miller <davem@davemloft.net>
Date: 2020-08-04 01:20:24

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon,  3 Aug 2020 13:03:49 -0700
These patches are all meant to help pave the way for a 802.1Q data path
added to the mockup driver, making it more useful than just testing for
configuration. Sending those out now since there is no real need to
wait.
Series applied, I added "a 802.1Q data path" to the subject line I integrated
into the merge commit for the series as it seems your Subject line here was
chopped off.

Re: [PATCH net-next 0/5] net: dsa: loop: Preparatory changes for

From: Florian Fainelli <f.fainelli@gmail.com>
Date: 2020-08-04 02:22:36


On 8/3/2020 6:20 PM, David Miller wrote:
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon,  3 Aug 2020 13:03:49 -0700
quoted
These patches are all meant to help pave the way for a 802.1Q data path
added to the mockup driver, making it more useful than just testing for
configuration. Sending those out now since there is no real need to
wait.
Series applied, I added "a 802.1Q data path" to the subject line I integrated
into the merge commit for the series as it seems your Subject line here was
chopped off.
Yes it was, the merge commit looks good to me, thank you.
-- 
Florian
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help