diff mbox series

[net-next,1/6] net: dsa: export dsa_slave_dev_check and dsa_slave_to_port

Message ID 20200503211035.19363-2-olteanv@gmail.com
State Changes Requested
Delegated to: David Miller
Headers show
Series tc-gate offload for SJA1105 DSA switch | expand

Commit Message

Vladimir Oltean May 3, 2020, 9:10 p.m. UTC
From: Vladimir Oltean <vladimir.oltean@nxp.com>

To be able to perform mirroring and redirection through tc-flower
offloads (the implementation of which is given raw access to the
flow_cls_offload structure), switch drivers need to be able to call
these functions on act->dev.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Changes from RFC:
None.

 include/net/dsa.h  | 2 ++
 net/dsa/dsa_priv.h | 8 --------
 net/dsa/slave.c    | 9 +++++++++
 3 files changed, 11 insertions(+), 8 deletions(-)

Comments

Florian Fainelli May 3, 2020, 10:45 p.m. UTC | #1
On 5/3/2020 2:10 PM, Vladimir Oltean wrote:
> From: Vladimir Oltean <vladimir.oltean@nxp.com>
> 
> To be able to perform mirroring and redirection through tc-flower
> offloads (the implementation of which is given raw access to the
> flow_cls_offload structure), switch drivers need to be able to call
> these functions on act->dev.
> 
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
> Changes from RFC:
> None.
> 
>  include/net/dsa.h  | 2 ++
>  net/dsa/dsa_priv.h | 8 --------
>  net/dsa/slave.c    | 9 +++++++++
>  3 files changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index fb3f9222f2a1..62beaa4c234e 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
>  int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
>  int dsa_port_get_phy_sset_count(struct dsa_port *dp);
>  void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
> +bool dsa_slave_dev_check(const struct net_device *dev);
> +struct dsa_port *dsa_slave_to_port(const struct net_device *dev);
>  
>  struct dsa_tag_driver {
>  	const struct dsa_device_ops *ops;
> diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
> index 6d9a1ef65fa0..32bf570fd71c 100644
> --- a/net/dsa/dsa_priv.h
> +++ b/net/dsa/dsa_priv.h
> @@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;
>  void dsa_slave_mii_bus_init(struct dsa_switch *ds);
>  int dsa_slave_create(struct dsa_port *dp);
>  void dsa_slave_destroy(struct net_device *slave_dev);
> -bool dsa_slave_dev_check(const struct net_device *dev);
>  int dsa_slave_suspend(struct net_device *slave_dev);
>  int dsa_slave_resume(struct net_device *slave_dev);
>  int dsa_slave_register_notifier(void);
>  void dsa_slave_unregister_notifier(void);
>  
> -static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
> -{
> -	struct dsa_slave_priv *p = netdev_priv(dev);
> -
> -	return p->dp;
> -}
> -
>  static inline struct net_device *
>  dsa_slave_to_master(const struct net_device *dev)
>  {
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index ba8bf90dc0cc..4eeb5b47ef99 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
>  	return dsa_slave_to_master(dev)->ifindex;
>  }
>  
> +struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
> +{
> +	struct dsa_slave_priv *p = netdev_priv(dev);
> +
> +	return p->dp;
> +}
> +EXPORT_SYMBOL_GPL(dsa_slave_to_port);

You could probably make this a static inline in net/dsa.h, too. With or
without doing that:

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Vladimir Oltean May 3, 2020, 10:47 p.m. UTC | #2
Hi Florian,

On Mon, 4 May 2020 at 01:45, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>
>
> On 5/3/2020 2:10 PM, Vladimir Oltean wrote:
> > From: Vladimir Oltean <vladimir.oltean@nxp.com>
> >
> > To be able to perform mirroring and redirection through tc-flower
> > offloads (the implementation of which is given raw access to the
> > flow_cls_offload structure), switch drivers need to be able to call
> > these functions on act->dev.
> >
> > Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> > ---
> > Changes from RFC:
> > None.
> >
> >  include/net/dsa.h  | 2 ++
> >  net/dsa/dsa_priv.h | 8 --------
> >  net/dsa/slave.c    | 9 +++++++++
> >  3 files changed, 11 insertions(+), 8 deletions(-)
> >
> > diff --git a/include/net/dsa.h b/include/net/dsa.h
> > index fb3f9222f2a1..62beaa4c234e 100644
> > --- a/include/net/dsa.h
> > +++ b/include/net/dsa.h
> > @@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
> >  int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
> >  int dsa_port_get_phy_sset_count(struct dsa_port *dp);
> >  void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
> > +bool dsa_slave_dev_check(const struct net_device *dev);
> > +struct dsa_port *dsa_slave_to_port(const struct net_device *dev);
> >
> >  struct dsa_tag_driver {
> >       const struct dsa_device_ops *ops;
> > diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
> > index 6d9a1ef65fa0..32bf570fd71c 100644
> > --- a/net/dsa/dsa_priv.h
> > +++ b/net/dsa/dsa_priv.h
> > @@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;
> >  void dsa_slave_mii_bus_init(struct dsa_switch *ds);
> >  int dsa_slave_create(struct dsa_port *dp);
> >  void dsa_slave_destroy(struct net_device *slave_dev);
> > -bool dsa_slave_dev_check(const struct net_device *dev);
> >  int dsa_slave_suspend(struct net_device *slave_dev);
> >  int dsa_slave_resume(struct net_device *slave_dev);
> >  int dsa_slave_register_notifier(void);
> >  void dsa_slave_unregister_notifier(void);
> >
> > -static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
> > -{
> > -     struct dsa_slave_priv *p = netdev_priv(dev);
> > -
> > -     return p->dp;
> > -}
> > -
> >  static inline struct net_device *
> >  dsa_slave_to_master(const struct net_device *dev)
> >  {
> > diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> > index ba8bf90dc0cc..4eeb5b47ef99 100644
> > --- a/net/dsa/slave.c
> > +++ b/net/dsa/slave.c
> > @@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
> >       return dsa_slave_to_master(dev)->ifindex;
> >  }
> >
> > +struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
> > +{
> > +     struct dsa_slave_priv *p = netdev_priv(dev);
> > +
> > +     return p->dp;
> > +}
> > +EXPORT_SYMBOL_GPL(dsa_slave_to_port);
>
> You could probably make this a static inline in net/dsa.h, too. With or
> without doing that:

With dereferencing dsa_slave_priv, I don't think so.

>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> --
> Florian

Thanks,
-Vladimir
Florian Fainelli May 3, 2020, 10:56 p.m. UTC | #3
On 5/3/2020 3:47 PM, Vladimir Oltean wrote:
> Hi Florian,
> 
> On Mon, 4 May 2020 at 01:45, Florian Fainelli <f.fainelli@gmail.com> wrote:
>>
>>
>>
>> On 5/3/2020 2:10 PM, Vladimir Oltean wrote:
>>> From: Vladimir Oltean <vladimir.oltean@nxp.com>
>>>
>>> To be able to perform mirroring and redirection through tc-flower
>>> offloads (the implementation of which is given raw access to the
>>> flow_cls_offload structure), switch drivers need to be able to call
>>> these functions on act->dev.
>>>
>>> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
>>> ---
>>> Changes from RFC:
>>> None.
>>>
>>>  include/net/dsa.h  | 2 ++
>>>  net/dsa/dsa_priv.h | 8 --------
>>>  net/dsa/slave.c    | 9 +++++++++
>>>  3 files changed, 11 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/include/net/dsa.h b/include/net/dsa.h
>>> index fb3f9222f2a1..62beaa4c234e 100644
>>> --- a/include/net/dsa.h
>>> +++ b/include/net/dsa.h
>>> @@ -739,6 +739,8 @@ int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
>>>  int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
>>>  int dsa_port_get_phy_sset_count(struct dsa_port *dp);
>>>  void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
>>> +bool dsa_slave_dev_check(const struct net_device *dev);
>>> +struct dsa_port *dsa_slave_to_port(const struct net_device *dev);
>>>
>>>  struct dsa_tag_driver {
>>>       const struct dsa_device_ops *ops;
>>> diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
>>> index 6d9a1ef65fa0..32bf570fd71c 100644
>>> --- a/net/dsa/dsa_priv.h
>>> +++ b/net/dsa/dsa_priv.h
>>> @@ -173,19 +173,11 @@ extern const struct dsa_device_ops notag_netdev_ops;
>>>  void dsa_slave_mii_bus_init(struct dsa_switch *ds);
>>>  int dsa_slave_create(struct dsa_port *dp);
>>>  void dsa_slave_destroy(struct net_device *slave_dev);
>>> -bool dsa_slave_dev_check(const struct net_device *dev);
>>>  int dsa_slave_suspend(struct net_device *slave_dev);
>>>  int dsa_slave_resume(struct net_device *slave_dev);
>>>  int dsa_slave_register_notifier(void);
>>>  void dsa_slave_unregister_notifier(void);
>>>
>>> -static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
>>> -{
>>> -     struct dsa_slave_priv *p = netdev_priv(dev);
>>> -
>>> -     return p->dp;
>>> -}
>>> -
>>>  static inline struct net_device *
>>>  dsa_slave_to_master(const struct net_device *dev)
>>>  {
>>> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
>>> index ba8bf90dc0cc..4eeb5b47ef99 100644
>>> --- a/net/dsa/slave.c
>>> +++ b/net/dsa/slave.c
>>> @@ -62,6 +62,14 @@ static int dsa_slave_get_iflink(const struct net_device *dev)
>>>       return dsa_slave_to_master(dev)->ifindex;
>>>  }
>>>
>>> +struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
>>> +{
>>> +     struct dsa_slave_priv *p = netdev_priv(dev);
>>> +
>>> +     return p->dp;
>>> +}
>>> +EXPORT_SYMBOL_GPL(dsa_slave_to_port);
>>
>> You could probably make this a static inline in net/dsa.h, too. With or
>> without doing that:
> 
> With dereferencing dsa_slave_priv, I don't think so.

Yes, I missed that dsa_slave_priv is not visible outside of dsa_priv.h
(on purpose). Thanks!
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index fb3f9222f2a1..62beaa4c234e 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -739,6 +739,8 @@  int dsa_port_get_phy_strings(struct dsa_port *dp, uint8_t *data);
 int dsa_port_get_ethtool_phy_stats(struct dsa_port *dp, uint64_t *data);
 int dsa_port_get_phy_sset_count(struct dsa_port *dp);
 void dsa_port_phylink_mac_change(struct dsa_switch *ds, int port, bool up);
+bool dsa_slave_dev_check(const struct net_device *dev);
+struct dsa_port *dsa_slave_to_port(const struct net_device *dev);
 
 struct dsa_tag_driver {
 	const struct dsa_device_ops *ops;
diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 6d9a1ef65fa0..32bf570fd71c 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -173,19 +173,11 @@  extern const struct dsa_device_ops notag_netdev_ops;
 void dsa_slave_mii_bus_init(struct dsa_switch *ds);
 int dsa_slave_create(struct dsa_port *dp);
 void dsa_slave_destroy(struct net_device *slave_dev);
-bool dsa_slave_dev_check(const struct net_device *dev);
 int dsa_slave_suspend(struct net_device *slave_dev);
 int dsa_slave_resume(struct net_device *slave_dev);
 int dsa_slave_register_notifier(void);
 void dsa_slave_unregister_notifier(void);
 
-static inline struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
-{
-	struct dsa_slave_priv *p = netdev_priv(dev);
-
-	return p->dp;
-}
-
 static inline struct net_device *
 dsa_slave_to_master(const struct net_device *dev)
 {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index ba8bf90dc0cc..4eeb5b47ef99 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -62,6 +62,14 @@  static int dsa_slave_get_iflink(const struct net_device *dev)
 	return dsa_slave_to_master(dev)->ifindex;
 }
 
+struct dsa_port *dsa_slave_to_port(const struct net_device *dev)
+{
+	struct dsa_slave_priv *p = netdev_priv(dev);
+
+	return p->dp;
+}
+EXPORT_SYMBOL_GPL(dsa_slave_to_port);
+
 static int dsa_slave_open(struct net_device *dev)
 {
 	struct net_device *master = dsa_slave_to_master(dev);
@@ -1836,6 +1844,7 @@  bool dsa_slave_dev_check(const struct net_device *dev)
 {
 	return dev->netdev_ops == &dsa_slave_netdev_ops;
 }
+EXPORT_SYMBOL_GPL(dsa_slave_dev_check);
 
 static int dsa_slave_changeupper(struct net_device *dev,
 				 struct netdev_notifier_changeupper_info *info)