diff mbox series

[net-next,v3,6/7] net: dsa: Add helper for converting devlink port to ds and port

Message ID 20201004161257.13945-7-andrew@lunn.ch
State New
Headers show
Series mv88e6xxx: Add per port devlink regions | expand

Commit Message

Andrew Lunn Oct. 4, 2020, 4:12 p.m. UTC
Hide away from DSA drivers how devlink works.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 include/net/dsa.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Comments

Florian Fainelli Oct. 4, 2020, 4:23 p.m. UTC | #1
On 10/4/2020 9:12 AM, Andrew Lunn wrote:
> Hide away from DSA drivers how devlink works.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Vladimir Oltean Oct. 4, 2020, 9:02 p.m. UTC | #2
On Sun, Oct 04, 2020 at 06:12:56PM +0200, Andrew Lunn wrote:
> Hide away from DSA drivers how devlink works.

> 

> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

> ---


Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
diff mbox series

Patch

diff --git a/include/net/dsa.h b/include/net/dsa.h
index ca426cf9927b..c0185660881c 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -701,6 +701,20 @@  static inline struct dsa_switch *dsa_devlink_to_ds(struct devlink *dl)
 	return dl_priv->ds;
 }
 
+static inline
+struct dsa_switch *dsa_devlink_port_to_ds(struct devlink_port *port)
+{
+	struct devlink *dl = port->devlink;
+	struct dsa_devlink_priv *dl_priv = devlink_priv(dl);
+
+	return dl_priv->ds;
+}
+
+static inline int dsa_devlink_port_to_port(struct devlink_port *port)
+{
+	return port->index;
+}
+
 struct dsa_switch_driver {
 	struct list_head	list;
 	const struct dsa_switch_ops *ops;