mbox series

[v4,net-next,00/10] Configuring congestion watermarks on ocelot switch using devlink-sb

Message ID 20210111174316.3515736-1-olteanv@gmail.com
Headers show
Series Configuring congestion watermarks on ocelot switch using devlink-sb | expand

Message

Vladimir Oltean Jan. 11, 2021, 5:43 p.m. UTC
From: Vladimir Oltean <vladimir.oltean@nxp.com>

In some applications, it is important to create resource reservations in
the Ethernet switches, to prevent background traffic, or deliberate
attacks, from inducing denial of service into the high-priority traffic.

These patches give the user some knobs to turn. The ocelot switches
support per-port and per-port-tc reservations, on ingress and on egress.
The resources that are monitored are packet buffers (in cells of 60
bytes each) and frame references.

The frames that exceed the reservations can optionally consume from
sharing watermarks which are not per-port but global across the switch.
There are 10 sharing watermarks, 8 of them are per traffic class and 2
are per drop priority.

I am configuring the hardware using the best of my knowledge, and mostly
through trial and error. Same goes for devlink-sb integration. Feedback
is welcome.

Vladimir Oltean (10):
  net: mscc: ocelot: auto-detect packet buffer size and number of frame
    references
  net: mscc: ocelot: add ops for decoding watermark threshold and
    occupancy
  net: dsa: add ops for devlink-sb
  net: dsa: felix: reindent struct dsa_switch_ops
  net: dsa: felix: perform teardown in reverse order of setup
  net: mscc: ocelot: export NUM_TC constant from felix to common switch
    lib
  net: mscc: ocelot: delete unused ocelot_set_cpu_port prototype
  net: mscc: ocelot: register devlink ports
  net: mscc: ocelot: initialize watermarks to sane defaults
  net: mscc: ocelot: configure watermarks using devlink-sb

 drivers/net/dsa/ocelot/felix.c             | 209 +++--
 drivers/net/dsa/ocelot/felix.h             |   2 -
 drivers/net/dsa/ocelot/felix_vsc9959.c     |  23 +-
 drivers/net/dsa/ocelot/seville_vsc9953.c   |  20 +-
 drivers/net/ethernet/mscc/Makefile         |   3 +-
 drivers/net/ethernet/mscc/ocelot.c         |  18 +-
 drivers/net/ethernet/mscc/ocelot.h         |   9 +-
 drivers/net/ethernet/mscc/ocelot_devlink.c | 885 +++++++++++++++++++++
 drivers/net/ethernet/mscc/ocelot_net.c     | 253 +++++-
 drivers/net/ethernet/mscc/ocelot_vsc7514.c | 108 ++-
 include/net/dsa.h                          |  34 +
 include/soc/mscc/ocelot.h                  |  55 +-
 include/soc/mscc/ocelot_qsys.h             |   7 +-
 net/dsa/dsa2.c                             | 159 +++-
 14 files changed, 1684 insertions(+), 101 deletions(-)
 create mode 100644 drivers/net/ethernet/mscc/ocelot_devlink.c

Comments

Jakub Kicinski Jan. 14, 2021, 3:25 a.m. UTC | #1
On Mon, 11 Jan 2021 19:43:06 +0200 Vladimir Oltean wrote:
> In some applications, it is important to create resource reservations in

> the Ethernet switches, to prevent background traffic, or deliberate

> attacks, from inducing denial of service into the high-priority traffic.

> 

> These patches give the user some knobs to turn. The ocelot switches

> support per-port and per-port-tc reservations, on ingress and on egress.

> The resources that are monitored are packet buffers (in cells of 60

> bytes each) and frame references.

> 

> The frames that exceed the reservations can optionally consume from

> sharing watermarks which are not per-port but global across the switch.

> There are 10 sharing watermarks, 8 of them are per traffic class and 2

> are per drop priority.

> 

> I am configuring the hardware using the best of my knowledge, and mostly

> through trial and error. Same goes for devlink-sb integration. Feedback

> is welcome.


This no longer applies.
Jakub Kicinski Jan. 14, 2021, 3:30 a.m. UTC | #2
On Mon, 11 Jan 2021 19:43:14 +0200 Vladimir Oltean wrote:
> +struct ocelot_devlink_private {

> +	struct ocelot *ocelot;

> +};


I don't think you ever explained to me why you don't put struct ocelot
in the priv.

-	ocelot = devm_kzalloc(&pdev->dev, sizeof(*ocelot), GFP_KERNEL);
-	if (!ocelot)
+	devlink = devlink_alloc(&ocelot_devlink_ops, sizeof(*ocelot));
+	if (!devlink)
                 return -ENOMEM;
+	ocelot = devlink_priv(ocelot->devlink);
Vladimir Oltean Jan. 14, 2021, 8:48 a.m. UTC | #3
On Wed, Jan 13, 2021 at 07:25:52PM -0800, Jakub Kicinski wrote:
> On Mon, 11 Jan 2021 19:43:06 +0200 Vladimir Oltean wrote:

> > In some applications, it is important to create resource reservations in

> > the Ethernet switches, to prevent background traffic, or deliberate

> > attacks, from inducing denial of service into the high-priority traffic.

> >

> > These patches give the user some knobs to turn. The ocelot switches

> > support per-port and per-port-tc reservations, on ingress and on egress.

> > The resources that are monitored are packet buffers (in cells of 60

> > bytes each) and frame references.

> >

> > The frames that exceed the reservations can optionally consume from

> > sharing watermarks which are not per-port but global across the switch.

> > There are 10 sharing watermarks, 8 of them are per traffic class and 2

> > are per drop priority.

> >

> > I am configuring the hardware using the best of my knowledge, and mostly

> > through trial and error. Same goes for devlink-sb integration. Feedback

> > is welcome.

>

> This no longer applies.


I was not expecting you to apply it, giving the feedback.
Vladimir Oltean Jan. 14, 2021, 10:27 a.m. UTC | #4
On Wed, Jan 13, 2021 at 07:30:33PM -0800, Jakub Kicinski wrote:
> On Mon, 11 Jan 2021 19:43:14 +0200 Vladimir Oltean wrote:

> > +struct ocelot_devlink_private {

> > +	struct ocelot *ocelot;

> > +};

> 

> I don't think you ever explained to me why you don't put struct ocelot

> in the priv.

> 

> -	ocelot = devm_kzalloc(&pdev->dev, sizeof(*ocelot), GFP_KERNEL);

> -	if (!ocelot)

> +	devlink = devlink_alloc(&ocelot_devlink_ops, sizeof(*ocelot));

> +	if (!devlink)

>                  return -ENOMEM;

> +	ocelot = devlink_priv(ocelot->devlink);


Because that's not going to be all? The error path handling and teardown
all need to change, because I no longer use device-managed allocation,
and I wanted to avoid that.
Jakub Kicinski Jan. 14, 2021, 5:19 p.m. UTC | #5
On Thu, 14 Jan 2021 12:27:43 +0200 Vladimir Oltean wrote:
> On Wed, Jan 13, 2021 at 07:30:33PM -0800, Jakub Kicinski wrote:

> > On Mon, 11 Jan 2021 19:43:14 +0200 Vladimir Oltean wrote:  

> > > +struct ocelot_devlink_private {

> > > +	struct ocelot *ocelot;

> > > +};  

> > 

> > I don't think you ever explained to me why you don't put struct ocelot

> > in the priv.

> > 

> > -	ocelot = devm_kzalloc(&pdev->dev, sizeof(*ocelot), GFP_KERNEL);

> > -	if (!ocelot)

> > +	devlink = devlink_alloc(&ocelot_devlink_ops, sizeof(*ocelot));

> > +	if (!devlink)

> >                  return -ENOMEM;

> > +	ocelot = devlink_priv(ocelot->devlink);  

> 

> Because that's not going to be all? The error path handling and teardown

> all need to change, because I no longer use device-managed allocation,

> and I wanted to avoid that.


Come on, is it really hard enough to warrant us exchanging multiple
emails? Having driver structure in devlink priv is the standard way
of handling this, there's value in uniformity.
Vladimir Oltean Jan. 14, 2021, 5:25 p.m. UTC | #6
On Thu, Jan 14, 2021 at 09:19:43AM -0800, Jakub Kicinski wrote:
> On Thu, 14 Jan 2021 12:27:43 +0200 Vladimir Oltean wrote:

> > On Wed, Jan 13, 2021 at 07:30:33PM -0800, Jakub Kicinski wrote:

> > > On Mon, 11 Jan 2021 19:43:14 +0200 Vladimir Oltean wrote:

> > > > +struct ocelot_devlink_private {

> > > > +	struct ocelot *ocelot;

> > > > +};

> > >

> > > I don't think you ever explained to me why you don't put struct ocelot

> > > in the priv.

> > >

> > > -	ocelot = devm_kzalloc(&pdev->dev, sizeof(*ocelot), GFP_KERNEL);

> > > -	if (!ocelot)

> > > +	devlink = devlink_alloc(&ocelot_devlink_ops, sizeof(*ocelot));

> > > +	if (!devlink)

> > >                  return -ENOMEM;

> > > +	ocelot = devlink_priv(ocelot->devlink);

> >

> > Because that's not going to be all? The error path handling and teardown

> > all need to change, because I no longer use device-managed allocation,

> > and I wanted to avoid that.

>

> Come on, is it really hard enough to warrant us exchanging multiple

> emails? Having driver structure in devlink priv is the standard way

> of handling this, there's value in uniformity.


I did as you requested in v5 anyway. It does not save me of having to
keep a devlink pointer in struct ocelot though, due to the fact that the
layout with struct devlink being a container of struct ocelot is not
common between the DSA felix driver and the switchdev ocelot driver. So
much for uniformity.