diff options
author | MD Danish Anwar <danishanwar@ti.com> | 2025-01-10 13:58:51 +0530 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2025-01-14 12:17:27 +0100 |
commit | 9c10dd8eed74de9e8adeb820939f8745cd566d4a (patch) | |
tree | 34e681a6ba607a182929e7d674d9b9a5cbba2acc /net/hsr/hsr_device.c | |
parent | 04508d20b017326e116c6e8ef953839507c73b6d (diff) |
net: hsr: Create and export hsr_get_port_ndev()
Create an API to get the net_device to the slave port of HSR device. The
API will take hsr net_device and enum hsr_port_type for which we want the
net_device as arguments.
This API can be used by client drivers who support HSR and want to get
the net_devcie of slave ports from the hsr device. Export this API for
the same.
This API needs the enum hsr_port_type to be accessible by the drivers using
hsr. Move the enum hsr_port_type from net/hsr/hsr_main.h to
include/linux/if_hsr.h for the same.
Signed-off-by: MD Danish Anwar <danishanwar@ti.com>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/hsr/hsr_device.c')
-rw-r--r-- | net/hsr/hsr_device.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 03eadd6c51fd..b6fb18469439 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -663,6 +663,19 @@ bool is_hsr_master(struct net_device *dev) } EXPORT_SYMBOL(is_hsr_master); +struct net_device *hsr_get_port_ndev(struct net_device *ndev, + enum hsr_port_type pt) +{ + struct hsr_priv *hsr = netdev_priv(ndev); + struct hsr_port *port; + + hsr_for_each_port(hsr, port) + if (port->type == pt) + return port->dev; + return NULL; +} +EXPORT_SYMBOL(hsr_get_port_ndev); + /* Default multicast address for HSR Supervision frames */ static const unsigned char def_multicast_addr[ETH_ALEN] __aligned(2) = { 0x01, 0x15, 0x4e, 0x00, 0x01, 0x00 |