* [PATCH net-next] net: dsa: microchip: add MRP software ring support
@ 2023-11-22 11:20 Rasmus Villemoes
2023-11-22 11:35 ` Vladimir Oltean
0 siblings, 1 reply; 4+ messages in thread
From: Rasmus Villemoes @ 2023-11-22 11:20 UTC (permalink / raw)
To: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Florian Fainelli,
Vladimir Oltean, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni
Cc: netdev, Per Noergaard Christensen, Rasmus Villemoes
From: Per Noergaard Christensen <per.christensen@prevas.dk>
Add dummy functions that tells the MRP bridge instance to use
implemented software routines instead of hardware-offloading.
Signed-off-by: Per Noergaard Christensen <per.christensen@prevas.dk>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
---
drivers/net/dsa/microchip/ksz_common.c | 55 ++++++++++++++++++++++++++
drivers/net/dsa/microchip/ksz_common.h | 1 +
2 files changed, 56 insertions(+)
diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
index 3fed406fb46a..b0935997dc05 100644
--- a/drivers/net/dsa/microchip/ksz_common.c
+++ b/drivers/net/dsa/microchip/ksz_common.c
@@ -3566,6 +3566,57 @@ static int ksz_set_wol(struct dsa_switch *ds, int port,
return -EOPNOTSUPP;
}
+static int ksz_port_mrp_add(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_mrp *mrp)
+{
+ struct dsa_port *dp = dsa_to_port(ds, port);
+ struct ksz_device *dev = ds->priv;
+
+ /* port different from requested mrp ports */
+ if (mrp->p_port != dp->user && mrp->s_port != dp->user)
+ return -EOPNOTSUPP;
+
+ /* save ring id */
+ dev->ports[port].mrp_ring_id = mrp->ring_id;
+ return 0;
+}
+
+static int ksz_port_mrp_del(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_mrp *mrp)
+{
+ struct ksz_device *dev = ds->priv;
+
+ /* check if port not part of ring id */
+ if (mrp->ring_id != dev->ports[port].mrp_ring_id)
+ return -EOPNOTSUPP;
+
+ /* clear ring id */
+ dev->ports[port].mrp_ring_id = 0;
+ return 0;
+}
+
+static int ksz_port_mrp_add_ring_role(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_ring_role_mrp *mrp)
+{
+ struct ksz_device *dev = ds->priv;
+
+ if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
+ return 0;
+
+ return -EOPNOTSUPP;
+}
+
+static int ksz_port_mrp_del_ring_role(struct dsa_switch *ds, int port,
+ const struct switchdev_obj_ring_role_mrp *mrp)
+{
+ struct ksz_device *dev = ds->priv;
+
+ if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
+ return 0;
+
+ return -EOPNOTSUPP;
+}
+
static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
const unsigned char *addr)
{
@@ -3799,6 +3850,10 @@ static const struct dsa_switch_ops ksz_switch_ops = {
.port_fdb_del = ksz_port_fdb_del,
.port_mdb_add = ksz_port_mdb_add,
.port_mdb_del = ksz_port_mdb_del,
+ .port_mrp_add = ksz_port_mrp_add,
+ .port_mrp_del = ksz_port_mrp_del,
+ .port_mrp_add_ring_role = ksz_port_mrp_add_ring_role,
+ .port_mrp_del_ring_role = ksz_port_mrp_del_ring_role,
.port_mirror_add = ksz_port_mirror_add,
.port_mirror_del = ksz_port_mirror_del,
.get_stats64 = ksz_get_stats64,
diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
index b7e8a403a132..24015f0a9c98 100644
--- a/drivers/net/dsa/microchip/ksz_common.h
+++ b/drivers/net/dsa/microchip/ksz_common.h
@@ -110,6 +110,7 @@ struct ksz_port {
bool remove_tag; /* Remove Tag flag set, for ksz8795 only */
bool learning;
int stp_state;
+ u32 mrp_ring_id;
struct phy_device phydev;
u32 fiber:1; /* port is fiber */
--
2.40.1.1.g1c60b9335d
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: dsa: microchip: add MRP software ring support
2023-11-22 11:20 [PATCH net-next] net: dsa: microchip: add MRP software ring support Rasmus Villemoes
@ 2023-11-22 11:35 ` Vladimir Oltean
2023-11-22 13:28 ` Horatiu Vultur
2023-11-24 8:28 ` Rasmus Villemoes
0 siblings, 2 replies; 4+ messages in thread
From: Vladimir Oltean @ 2023-11-22 11:35 UTC (permalink / raw)
To: Rasmus Villemoes, Horatiu Vultur
Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Florian Fainelli,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, Per Noergaard Christensen
On Wed, Nov 22, 2023 at 12:20:06PM +0100, Rasmus Villemoes wrote:
> From: Per Noergaard Christensen <per.christensen@prevas.dk>
>
> Add dummy functions that tells the MRP bridge instance to use
> implemented software routines instead of hardware-offloading.
>
> Signed-off-by: Per Noergaard Christensen <per.christensen@prevas.dk>
> Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> ---
> drivers/net/dsa/microchip/ksz_common.c | 55 ++++++++++++++++++++++++++
> drivers/net/dsa/microchip/ksz_common.h | 1 +
> 2 files changed, 56 insertions(+)
>
> diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> index 3fed406fb46a..b0935997dc05 100644
> --- a/drivers/net/dsa/microchip/ksz_common.c
> +++ b/drivers/net/dsa/microchip/ksz_common.c
> @@ -3566,6 +3566,57 @@ static int ksz_set_wol(struct dsa_switch *ds, int port,
> return -EOPNOTSUPP;
> }
>
> +static int ksz_port_mrp_add(struct dsa_switch *ds, int port,
> + const struct switchdev_obj_mrp *mrp)
> +{
> + struct dsa_port *dp = dsa_to_port(ds, port);
> + struct ksz_device *dev = ds->priv;
> +
> + /* port different from requested mrp ports */
> + if (mrp->p_port != dp->user && mrp->s_port != dp->user)
> + return -EOPNOTSUPP;
> +
> + /* save ring id */
> + dev->ports[port].mrp_ring_id = mrp->ring_id;
> + return 0;
> +}
> +
> +static int ksz_port_mrp_del(struct dsa_switch *ds, int port,
> + const struct switchdev_obj_mrp *mrp)
> +{
> + struct ksz_device *dev = ds->priv;
> +
> + /* check if port not part of ring id */
> + if (mrp->ring_id != dev->ports[port].mrp_ring_id)
> + return -EOPNOTSUPP;
> +
> + /* clear ring id */
> + dev->ports[port].mrp_ring_id = 0;
> + return 0;
> +}
> +
> +static int ksz_port_mrp_add_ring_role(struct dsa_switch *ds, int port,
> + const struct switchdev_obj_ring_role_mrp *mrp)
> +{
> + struct ksz_device *dev = ds->priv;
> +
> + if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
> + return 0;
> +
> + return -EOPNOTSUPP;
> +}
> +
> +static int ksz_port_mrp_del_ring_role(struct dsa_switch *ds, int port,
> + const struct switchdev_obj_ring_role_mrp *mrp)
> +{
> + struct ksz_device *dev = ds->priv;
> +
> + if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
> + return 0;
> +
> + return -EOPNOTSUPP;
> +}
> +
> static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
> const unsigned char *addr)
> {
> @@ -3799,6 +3850,10 @@ static const struct dsa_switch_ops ksz_switch_ops = {
> .port_fdb_del = ksz_port_fdb_del,
> .port_mdb_add = ksz_port_mdb_add,
> .port_mdb_del = ksz_port_mdb_del,
> + .port_mrp_add = ksz_port_mrp_add,
> + .port_mrp_del = ksz_port_mrp_del,
> + .port_mrp_add_ring_role = ksz_port_mrp_add_ring_role,
> + .port_mrp_del_ring_role = ksz_port_mrp_del_ring_role,
> .port_mirror_add = ksz_port_mirror_add,
> .port_mirror_del = ksz_port_mirror_del,
> .get_stats64 = ksz_get_stats64,
> diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> index b7e8a403a132..24015f0a9c98 100644
> --- a/drivers/net/dsa/microchip/ksz_common.h
> +++ b/drivers/net/dsa/microchip/ksz_common.h
> @@ -110,6 +110,7 @@ struct ksz_port {
> bool remove_tag; /* Remove Tag flag set, for ksz8795 only */
> bool learning;
> int stp_state;
> + u32 mrp_ring_id;
> struct phy_device phydev;
>
> u32 fiber:1; /* port is fiber */
> --
> 2.40.1.1.g1c60b9335d
>
Could you please explain a bit the mechanics of this dummy implementation?
Don't you need to set up any packet traps for MRP PDUs, to avoid
forwarding them? What ring roles will work with the dummy implementation?
+Horatiu for an expert opinion.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: dsa: microchip: add MRP software ring support
2023-11-22 11:35 ` Vladimir Oltean
@ 2023-11-22 13:28 ` Horatiu Vultur
2023-11-24 8:28 ` Rasmus Villemoes
1 sibling, 0 replies; 4+ messages in thread
From: Horatiu Vultur @ 2023-11-22 13:28 UTC (permalink / raw)
To: Vladimir Oltean
Cc: Rasmus Villemoes, Woojung Huh, UNGLinuxDriver, Andrew Lunn,
Florian Fainelli, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, netdev, Per Noergaard Christensen
The 11/22/2023 13:35, Vladimir Oltean wrote:
Hi Rasmus,
>
> On Wed, Nov 22, 2023 at 12:20:06PM +0100, Rasmus Villemoes wrote:
> > From: Per Noergaard Christensen <per.christensen@prevas.dk>
> >
> > Add dummy functions that tells the MRP bridge instance to use
> > implemented software routines instead of hardware-offloading.
> >
> > Signed-off-by: Per Noergaard Christensen <per.christensen@prevas.dk>
> > Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
> > ---
> > drivers/net/dsa/microchip/ksz_common.c | 55 ++++++++++++++++++++++++++
> > drivers/net/dsa/microchip/ksz_common.h | 1 +
> > 2 files changed, 56 insertions(+)
> >
> > diff --git a/drivers/net/dsa/microchip/ksz_common.c b/drivers/net/dsa/microchip/ksz_common.c
> > index 3fed406fb46a..b0935997dc05 100644
> > --- a/drivers/net/dsa/microchip/ksz_common.c
> > +++ b/drivers/net/dsa/microchip/ksz_common.c
> > @@ -3566,6 +3566,57 @@ static int ksz_set_wol(struct dsa_switch *ds, int port,
> > return -EOPNOTSUPP;
> > }
> >
> > +static int ksz_port_mrp_add(struct dsa_switch *ds, int port,
> > + const struct switchdev_obj_mrp *mrp)
> > +{
> > + struct dsa_port *dp = dsa_to_port(ds, port);
> > + struct ksz_device *dev = ds->priv;
> > +
> > + /* port different from requested mrp ports */
> > + if (mrp->p_port != dp->user && mrp->s_port != dp->user)
> > + return -EOPNOTSUPP;
> > +
> > + /* save ring id */
> > + dev->ports[port].mrp_ring_id = mrp->ring_id;
> > + return 0;
> > +}
> > +
> > +static int ksz_port_mrp_del(struct dsa_switch *ds, int port,
> > + const struct switchdev_obj_mrp *mrp)
> > +{
> > + struct ksz_device *dev = ds->priv;
> > +
> > + /* check if port not part of ring id */
> > + if (mrp->ring_id != dev->ports[port].mrp_ring_id)
> > + return -EOPNOTSUPP;
> > +
> > + /* clear ring id */
> > + dev->ports[port].mrp_ring_id = 0;
> > + return 0;
> > +}
> > +
> > +static int ksz_port_mrp_add_ring_role(struct dsa_switch *ds, int port,
> > + const struct switchdev_obj_ring_role_mrp *mrp)
> > +{
> > + struct ksz_device *dev = ds->priv;
> > +
> > + if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
> > + return 0;
As Vladimir mentioned, you should add some rules to trap all MRP frames.
Otherwise, if you configure as MRC then you need to foward the TEST
frames and copy to CPU the CONTROL frames. And if you start to have more
than 2 ports under the bridge, then the traffic will be flooded on the
other ports that are not part of the MRP ring.
If you configure as MRM then you will never terminate the frames
otherwise the HW will just forward them. And of course you will have the
same issue if there are more than 2 ports under the bridge.
I hope I didn't forget everything (as I didn't look into this for some
time). But willing to look more into if it is needed.
> > +
> > + return -EOPNOTSUPP;
> > +}
> > +
> > +static int ksz_port_mrp_del_ring_role(struct dsa_switch *ds, int port,
> > + const struct switchdev_obj_ring_role_mrp *mrp)
> > +{
> > + struct ksz_device *dev = ds->priv;
> > +
> > + if (mrp->sw_backup && dev->ports[port].mrp_ring_id == mrp->ring_id)
> > + return 0;
> > +
> > + return -EOPNOTSUPP;
> > +}
> > +
> > static int ksz_port_set_mac_address(struct dsa_switch *ds, int port,
> > const unsigned char *addr)
> > {
> > @@ -3799,6 +3850,10 @@ static const struct dsa_switch_ops ksz_switch_ops = {
> > .port_fdb_del = ksz_port_fdb_del,
> > .port_mdb_add = ksz_port_mdb_add,
> > .port_mdb_del = ksz_port_mdb_del,
> > + .port_mrp_add = ksz_port_mrp_add,
> > + .port_mrp_del = ksz_port_mrp_del,
> > + .port_mrp_add_ring_role = ksz_port_mrp_add_ring_role,
> > + .port_mrp_del_ring_role = ksz_port_mrp_del_ring_role,
> > .port_mirror_add = ksz_port_mirror_add,
> > .port_mirror_del = ksz_port_mirror_del,
> > .get_stats64 = ksz_get_stats64,
> > diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/microchip/ksz_common.h
> > index b7e8a403a132..24015f0a9c98 100644
> > --- a/drivers/net/dsa/microchip/ksz_common.h
> > +++ b/drivers/net/dsa/microchip/ksz_common.h
> > @@ -110,6 +110,7 @@ struct ksz_port {
> > bool remove_tag; /* Remove Tag flag set, for ksz8795 only */
> > bool learning;
> > int stp_state;
> > + u32 mrp_ring_id;
> > struct phy_device phydev;
> >
> > u32 fiber:1; /* port is fiber */
> > --
> > 2.40.1.1.g1c60b9335d
> >
>
> Could you please explain a bit the mechanics of this dummy implementation?
> Don't you need to set up any packet traps for MRP PDUs, to avoid
> forwarding them? What ring roles will work with the dummy implementation?
>
> +Horatiu for an expert opinion.
>
--
/Horatiu
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] net: dsa: microchip: add MRP software ring support
2023-11-22 11:35 ` Vladimir Oltean
2023-11-22 13:28 ` Horatiu Vultur
@ 2023-11-24 8:28 ` Rasmus Villemoes
1 sibling, 0 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2023-11-24 8:28 UTC (permalink / raw)
To: Vladimir Oltean, Horatiu Vultur
Cc: Woojung Huh, UNGLinuxDriver, Andrew Lunn, Florian Fainelli,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, Per Noergaard Christensen
On 22/11/2023 12.35, Vladimir Oltean wrote:
> On Wed, Nov 22, 2023 at 12:20:06PM +0100, Rasmus Villemoes wrote:
>> From: Per Noergaard Christensen <per.christensen@prevas.dk>
>>
>> Add dummy functions that tells the MRP bridge instance to use
>> implemented software routines instead of hardware-offloading.
>>
>
> Could you please explain a bit the mechanics of this dummy implementation?
> Don't you need to set up any packet traps for MRP PDUs, to avoid
> forwarding them? What ring roles will work with the dummy implementation?
Hm, you're right, of course. We will have to check what went wrong in
our testing, we did believe we had it working, but that can't really be
true. So please ignore this for now, sorry for the noise.
Rasmus
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-11-24 8:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-22 11:20 [PATCH net-next] net: dsa: microchip: add MRP software ring support Rasmus Villemoes
2023-11-22 11:35 ` Vladimir Oltean
2023-11-22 13:28 ` Horatiu Vultur
2023-11-24 8:28 ` Rasmus Villemoes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).