aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorAndrew Lunn <andrew@lunn.ch>2020-10-04 18:12:56 +0200
committerDavid S. Miller <davem@davemloft.net>2020-10-04 14:38:53 -0700
commit7d1e2a10681d3b6eeaace68885ef5de88ce03efe (patch)
tree6ac4295287475a82c0562a5ee7a0b708ed1852ad /include
parentnet: dsa: Add devlink port regions support to DSA (diff)
downloadlinux-dev-7d1e2a10681d3b6eeaace68885ef5de88ce03efe.tar.xz
linux-dev-7d1e2a10681d3b6eeaace68885ef5de88ce03efe.zip
net: dsa: Add helper for converting devlink port to ds and port
Hide away from DSA drivers how devlink works. Signed-off-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/dsa.h14
1 files changed, 14 insertions, 0 deletions
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;