diff mbox series

[v2,net-next,2/7] net: dsa: Pass ndo_setup_tc slave callback to drivers

Message ID 20190914011802.1602-3-olteanv@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series tc-taprio offload for SJA1105 DSA | expand

Commit Message

Vladimir Oltean Sept. 14, 2019, 1:17 a.m. UTC
DSA currently handles shared block filters (for the classifier-action
qdisc) in the core due to what I believe are simply pragmatic reasons -
hiding the complexity from drivers and offerring a simple API for port
mirroring.

Extend the dsa_slave_setup_tc function by passing all other qdisc
offloads to the driver layer, where the driver may choose what it
implements and how. DSA is simply a pass-through in this case.

Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
---
Changes since v1:
- Added Kurt Kanzenbach's Acked-by.

Changes since RFC:
- Removed the unused declaration of struct tc_taprio_qopt_offload.

 include/net/dsa.h |  2 ++
 net/dsa/slave.c   | 12 ++++++++----
 2 files changed, 10 insertions(+), 4 deletions(-)

Comments

Florian Fainelli Sept. 14, 2019, 2:59 a.m. UTC | #1
On 9/13/2019 6:17 PM, Vladimir Oltean wrote:
> DSA currently handles shared block filters (for the classifier-action
> qdisc) in the core due to what I believe are simply pragmatic reasons -
> hiding the complexity from drivers and offerring a simple API for port
> mirroring.
> 
> Extend the dsa_slave_setup_tc function by passing all other qdisc
> offloads to the driver layer, where the driver may choose what it
> implements and how. DSA is simply a pass-through in this case.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> Acked-by: Kurt Kanzenbach <kurt@linutronix.de>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Ilias Apalodimas Sept. 16, 2019, 9:31 a.m. UTC | #2
Hi Vladimir,

Yes fixes my request on the initial RFC. Sorry for the delayed response.

On Sat, Sep 14, 2019 at 04:17:57AM +0300, Vladimir Oltean wrote:
> DSA currently handles shared block filters (for the classifier-action
> qdisc) in the core due to what I believe are simply pragmatic reasons -
> hiding the complexity from drivers and offerring a simple API for port
> mirroring.
> 
> Extend the dsa_slave_setup_tc function by passing all other qdisc
> offloads to the driver layer, where the driver may choose what it
> implements and how. DSA is simply a pass-through in this case.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
> Changes since v1:
> - Added Kurt Kanzenbach's Acked-by.
> 
> Changes since RFC:
> - Removed the unused declaration of struct tc_taprio_qopt_offload.
> 
>  include/net/dsa.h |  2 ++
>  net/dsa/slave.c   | 12 ++++++++----
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 96acb14ec1a8..541fb514e31d 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -515,6 +515,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_tc)(struct dsa_switch *ds, int port,
> +				 enum tc_setup_type type, void *type_data);
>  
>  	/*
>  	 * Cross-chip operations
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 9a88035517a6..75d58229a4bd 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1035,12 +1035,16 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
>  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
>  			      void *type_data)
>  {
> -	switch (type) {
> -	case TC_SETUP_BLOCK:
> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (type == TC_SETUP_BLOCK)
>  		return dsa_slave_setup_tc_block(dev, type_data);
> -	default:
> +
> +	if (!ds->ops->port_setup_tc)
>  		return -EOPNOTSUPP;
> -	}
> +
> +	return ds->ops->port_setup_tc(ds, dp->index, type, type_data);
>  }
>  
>  static void dsa_slave_get_stats64(struct net_device *dev,
> -- 
> 2.17.1
> 

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Vladimir Oltean Sept. 16, 2019, 9:53 a.m. UTC | #3
Hi Ilias,

On Mon, 16 Sep 2019 at 12:31, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> Hi Vladimir,
>
> Yes fixes my request on the initial RFC. Sorry for the delayed response.
>
> On Sat, Sep 14, 2019 at 04:17:57AM +0300, Vladimir Oltean wrote:
> > DSA currently handles shared block filters (for the classifier-action
> > qdisc) in the core due to what I believe are simply pragmatic reasons -
> > hiding the complexity from drivers and offerring a simple API for port
> > mirroring.
> >
> > Extend the dsa_slave_setup_tc function by passing all other qdisc
> > offloads to the driver layer, where the driver may choose what it
> > implements and how. DSA is simply a pass-through in this case.
> >
> > Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> > Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
> > ---
> > Changes since v1:
> > - Added Kurt Kanzenbach's Acked-by.
> >
> > Changes since RFC:
> > - Removed the unused declaration of struct tc_taprio_qopt_offload.
> >
> >  include/net/dsa.h |  2 ++
> >  net/dsa/slave.c   | 12 ++++++++----
> >  2 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/net/dsa.h b/include/net/dsa.h
> > index 96acb14ec1a8..541fb514e31d 100644
> > --- a/include/net/dsa.h
> > +++ b/include/net/dsa.h
> > @@ -515,6 +515,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_tc)(struct dsa_switch *ds, int port,
> > +                              enum tc_setup_type type, void *type_data);
> >
> >       /*
> >        * Cross-chip operations
> > diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> > index 9a88035517a6..75d58229a4bd 100644
> > --- a/net/dsa/slave.c
> > +++ b/net/dsa/slave.c
> > @@ -1035,12 +1035,16 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
> >  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
> >                             void *type_data)
> >  {
> > -     switch (type) {
> > -     case TC_SETUP_BLOCK:
> > +     struct dsa_port *dp = dsa_slave_to_port(dev);
> > +     struct dsa_switch *ds = dp->ds;
> > +
> > +     if (type == TC_SETUP_BLOCK)
> >               return dsa_slave_setup_tc_block(dev, type_data);
> > -     default:
> > +
> > +     if (!ds->ops->port_setup_tc)
> >               return -EOPNOTSUPP;
> > -     }
> > +
> > +     return ds->ops->port_setup_tc(ds, dp->index, type, type_data);
> >  }
> >
> >  static void dsa_slave_get_stats64(struct net_device *dev,
> > --
> > 2.17.1
> >
>
> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Thanks. Could you add this Acked-by to the v4 email, just so we keep
the discussion on the latest submitted version?

-Vladimir
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index 96acb14ec1a8..541fb514e31d 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -515,6 +515,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_tc)(struct dsa_switch *ds, int port,
+				 enum tc_setup_type type, void *type_data);
 
 	/*
 	 * Cross-chip operations
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 9a88035517a6..75d58229a4bd 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1035,12 +1035,16 @@  static int dsa_slave_setup_tc_block(struct net_device *dev,
 static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
 			      void *type_data)
 {
-	switch (type) {
-	case TC_SETUP_BLOCK:
+	struct dsa_port *dp = dsa_slave_to_port(dev);
+	struct dsa_switch *ds = dp->ds;
+
+	if (type == TC_SETUP_BLOCK)
 		return dsa_slave_setup_tc_block(dev, type_data);
-	default:
+
+	if (!ds->ops->port_setup_tc)
 		return -EOPNOTSUPP;
-	}
+
+	return ds->ops->port_setup_tc(ds, dp->index, type, type_data);
 }
 
 static void dsa_slave_get_stats64(struct net_device *dev,