Skip to content

Commit 7d1e2a1

Browse files
lunndavem330
authored andcommitted
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 <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Vladimir Oltean <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 08156ba commit 7d1e2a1

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

include/net/dsa.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,20 @@ static inline struct dsa_switch *dsa_devlink_to_ds(struct devlink *dl)
701701
return dl_priv->ds;
702702
}
703703

704+
static inline
705+
struct dsa_switch *dsa_devlink_port_to_ds(struct devlink_port *port)
706+
{
707+
struct devlink *dl = port->devlink;
708+
struct dsa_devlink_priv *dl_priv = devlink_priv(dl);
709+
710+
return dl_priv->ds;
711+
}
712+
713+
static inline int dsa_devlink_port_to_port(struct devlink_port *port)
714+
{
715+
return port->index;
716+
}
717+
704718
struct dsa_switch_driver {
705719
struct list_head list;
706720
const struct dsa_switch_ops *ops;

0 commit comments

Comments
 (0)