xref: /linux-6.15/net/switchdev/switchdev.c (revision 007f790c)
1*007f790cSJiri Pirko /*
2*007f790cSJiri Pirko  * net/switchdev/switchdev.c - Switch device API
3*007f790cSJiri Pirko  * Copyright (c) 2014 Jiri Pirko <[email protected]>
4*007f790cSJiri Pirko  *
5*007f790cSJiri Pirko  * This program is free software; you can redistribute it and/or modify
6*007f790cSJiri Pirko  * it under the terms of the GNU General Public License as published by
7*007f790cSJiri Pirko  * the Free Software Foundation; either version 2 of the License, or
8*007f790cSJiri Pirko  * (at your option) any later version.
9*007f790cSJiri Pirko  */
10*007f790cSJiri Pirko 
11*007f790cSJiri Pirko #include <linux/kernel.h>
12*007f790cSJiri Pirko #include <linux/types.h>
13*007f790cSJiri Pirko #include <linux/init.h>
14*007f790cSJiri Pirko #include <linux/netdevice.h>
15*007f790cSJiri Pirko #include <net/switchdev.h>
16*007f790cSJiri Pirko 
17*007f790cSJiri Pirko /**
18*007f790cSJiri Pirko  *	netdev_switch_parent_id_get - Get ID of a switch
19*007f790cSJiri Pirko  *	@dev: port device
20*007f790cSJiri Pirko  *	@psid: switch ID
21*007f790cSJiri Pirko  *
22*007f790cSJiri Pirko  *	Get ID of a switch this port is part of.
23*007f790cSJiri Pirko  */
24*007f790cSJiri Pirko int netdev_switch_parent_id_get(struct net_device *dev,
25*007f790cSJiri Pirko 				struct netdev_phys_item_id *psid)
26*007f790cSJiri Pirko {
27*007f790cSJiri Pirko 	const struct net_device_ops *ops = dev->netdev_ops;
28*007f790cSJiri Pirko 
29*007f790cSJiri Pirko 	if (!ops->ndo_switch_parent_id_get)
30*007f790cSJiri Pirko 		return -EOPNOTSUPP;
31*007f790cSJiri Pirko 	return ops->ndo_switch_parent_id_get(dev, psid);
32*007f790cSJiri Pirko }
33*007f790cSJiri Pirko EXPORT_SYMBOL(netdev_switch_parent_id_get);
34