diff mbox series

[RFC,net-next,3/6] net: dsa: Pass tc-taprio offload to drivers

Message ID 20190707172921.17731-4-olteanv@gmail.com
State RFC
Delegated to: David Miller
Headers show
Series tc-taprio offload for SJA1105 DSA | expand

Commit Message

Vladimir Oltean July 7, 2019, 5:29 p.m. UTC
tc-taprio is a qdisc based on the enhancements for scheduled traffic
specified in IEEE 802.1Qbv (later merged in 802.1Q).  This qdisc has
a software implementation and an optional offload through which
compatible Ethernet ports may configure their egress 802.1Qbv
schedulers.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
---
 include/net/dsa.h |  3 +++
 net/dsa/slave.c   | 14 ++++++++++++++
 2 files changed, 17 insertions(+)

Comments

Ilias Apalodimas July 8, 2019, 11:23 a.m. UTC | #1
Hi Vladimir,

> tc-taprio is a qdisc based on the enhancements for scheduled traffic
> specified in IEEE 802.1Qbv (later merged in 802.1Q).  This qdisc has
> a software implementation and an optional offload through which
> compatible Ethernet ports may configure their egress 802.1Qbv
> schedulers.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> ---
>  include/net/dsa.h |  3 +++
>  net/dsa/slave.c   | 14 ++++++++++++++
>  2 files changed, 17 insertions(+)
> 
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 1e8650fa8acc..e7ee6ac8ce6b 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -152,6 +152,7 @@ struct dsa_mall_tc_entry {
>  	};
>  };
>  
> +struct tc_taprio_qopt_offload;
>  
>  struct dsa_port {
>  	/* A CPU port is physically connected to a master device.
> @@ -516,6 +517,8 @@ struct dsa_switch_ops {
>  				   bool ingress);
>  	void	(*port_mirror_del)(struct dsa_switch *ds, int port,
>  				   struct dsa_mall_mirror_tc_entry *mirror);
> +	int	(*port_setup_taprio)(struct dsa_switch *ds, int port,
> +				     struct tc_taprio_qopt_offload *qopt);

Is there any way to make this more generic? 802.1Qbv are not the only hardware
schedulers. CBS and ETF are examples that first come to mind. Maybe having
something more generic than tc_taprio_qopt_offload as an option could host
future schedulers?

>  
>  	/*
>  	 * Cross-chip operations
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 99673f6b07f6..2bae33788708 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -965,12 +965,26 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
>  	}
>  }
>  
> +static int dsa_slave_setup_tc_taprio(struct net_device *dev,
> +				     struct tc_taprio_qopt_offload *f)
> +{
> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (!ds->ops->port_setup_taprio)
> +		return -EOPNOTSUPP;
> +
> +	return ds->ops->port_setup_taprio(ds, dp->index, f);
> +}
> +
>  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
>  			      void *type_data)
>  {
>  	switch (type) {
>  	case TC_SETUP_BLOCK:
>  		return dsa_slave_setup_tc_block(dev, type_data);
> +	case TC_SETUP_QDISC_TAPRIO:
> +		return dsa_slave_setup_tc_taprio(dev, type_data);
>  	default:
>  		return -EOPNOTSUPP;
>  	}
> -- 
> 2.17.1
> 
Thanks
/Ilias
Vladimir Oltean July 13, 2019, 12:48 p.m. UTC | #2
Hi Ilias,

On Mon, 8 Jul 2019 at 14:23, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> Hi Vladimir,
>
> > tc-taprio is a qdisc based on the enhancements for scheduled traffic
> > specified in IEEE 802.1Qbv (later merged in 802.1Q).  This qdisc has
> > a software implementation and an optional offload through which
> > compatible Ethernet ports may configure their egress 802.1Qbv
> > schedulers.
> >
> > Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> > ---
> >  include/net/dsa.h |  3 +++
> >  net/dsa/slave.c   | 14 ++++++++++++++
> >  2 files changed, 17 insertions(+)
> >
> > diff --git a/include/net/dsa.h b/include/net/dsa.h
> > index 1e8650fa8acc..e7ee6ac8ce6b 100644
> > --- a/include/net/dsa.h
> > +++ b/include/net/dsa.h
> > @@ -152,6 +152,7 @@ struct dsa_mall_tc_entry {
> >       };
> >  };
> >
> > +struct tc_taprio_qopt_offload;
> >
> >  struct dsa_port {
> >       /* A CPU port is physically connected to a master device.
> > @@ -516,6 +517,8 @@ struct dsa_switch_ops {
> >                                  bool ingress);
> >       void    (*port_mirror_del)(struct dsa_switch *ds, int port,
> >                                  struct dsa_mall_mirror_tc_entry *mirror);
> > +     int     (*port_setup_taprio)(struct dsa_switch *ds, int port,
> > +                                  struct tc_taprio_qopt_offload *qopt);
>
> Is there any way to make this more generic? 802.1Qbv are not the only hardware
> schedulers. CBS and ETF are examples that first come to mind. Maybe having
> something more generic than tc_taprio_qopt_offload as an option could host
> future schedulers?
>

Good point. I'll see what I can do to make DSA more qdisc-agnostic
when I gather enough feedback to mandate a v2.

> >
> >       /*
> >        * Cross-chip operations
> > diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> > index 99673f6b07f6..2bae33788708 100644
> > --- a/net/dsa/slave.c
> > +++ b/net/dsa/slave.c
> > @@ -965,12 +965,26 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
> >       }
> >  }
> >
> > +static int dsa_slave_setup_tc_taprio(struct net_device *dev,
> > +                                  struct tc_taprio_qopt_offload *f)
> > +{
> > +     struct dsa_port *dp = dsa_slave_to_port(dev);
> > +     struct dsa_switch *ds = dp->ds;
> > +
> > +     if (!ds->ops->port_setup_taprio)
> > +             return -EOPNOTSUPP;
> > +
> > +     return ds->ops->port_setup_taprio(ds, dp->index, f);
> > +}
> > +
> >  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
> >                             void *type_data)
> >  {
> >       switch (type) {
> >       case TC_SETUP_BLOCK:
> >               return dsa_slave_setup_tc_block(dev, type_data);
> > +     case TC_SETUP_QDISC_TAPRIO:
> > +             return dsa_slave_setup_tc_taprio(dev, type_data);
> >       default:
> >               return -EOPNOTSUPP;
> >       }
> > --
> > 2.17.1
> >
> Thanks
> /Ilias

Thanks,
-Vladimir
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 1e8650fa8acc..e7ee6ac8ce6b 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -152,6 +152,7 @@  struct dsa_mall_tc_entry {
 	};
 };
 
+struct tc_taprio_qopt_offload;
 
 struct dsa_port {
 	/* A CPU port is physically connected to a master device.
@@ -516,6 +517,8 @@  struct dsa_switch_ops {
 				   bool ingress);
 	void	(*port_mirror_del)(struct dsa_switch *ds, int port,
 				   struct dsa_mall_mirror_tc_entry *mirror);
+	int	(*port_setup_taprio)(struct dsa_switch *ds, int port,
+				     struct tc_taprio_qopt_offload *qopt);
 
 	/*
 	 * Cross-chip operations
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 99673f6b07f6..2bae33788708 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -965,12 +965,26 @@  static int dsa_slave_setup_tc_block(struct net_device *dev,
 	}
 }
 
+static int dsa_slave_setup_tc_taprio(struct net_device *dev,
+				     struct tc_taprio_qopt_offload *f)
+{
+	struct dsa_port *dp = dsa_slave_to_port(dev);
+	struct dsa_switch *ds = dp->ds;
+
+	if (!ds->ops->port_setup_taprio)
+		return -EOPNOTSUPP;
+
+	return ds->ops->port_setup_taprio(ds, dp->index, f);
+}
+
 static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
 			      void *type_data)
 {
 	switch (type) {
 	case TC_SETUP_BLOCK:
 		return dsa_slave_setup_tc_block(dev, type_data);
+	case TC_SETUP_QDISC_TAPRIO:
+		return dsa_slave_setup_tc_taprio(dev, type_data);
 	default:
 		return -EOPNOTSUPP;
 	}