1 /* SPDX-License-Identifier: GPL-2.0 */
3 * PHY device list allow maintaining a list of PHY devices that are
4 * part of a netdevice's link topology. PHYs can for example be chained,
5 * as is the case when using a PHY that exposes an SFP module, on which an
6 * SFP transceiver that embeds a PHY is connected.
8 * This list can then be used by userspace to leverage individual PHY
11 #ifndef __PHY_LINK_TOPOLOGY_H
12 #define __PHY_LINK_TOPOLOGY_H
14 #include <linux/ethtool.h>
15 #include <linux/netdevice.h>
21 struct phy_link_topology {
26 struct phy_device_node {
27 enum phy_upstream upstream_type;
30 struct net_device *netdev;
31 struct phy_device *phydev;
34 struct sfp_bus *parent_sfp_bus;
36 struct phy_device *phy;
39 #if IS_ENABLED(CONFIG_PHYLIB)
40 int phy_link_topo_add_phy(struct net_device *dev,
41 struct phy_device *phy,
42 enum phy_upstream upt, void *upstream);
44 void phy_link_topo_del_phy(struct net_device *dev, struct phy_device *phy);
46 static inline struct phy_device *
47 phy_link_topo_get_phy(struct net_device *dev, u32 phyindex)
49 struct phy_link_topology *topo = dev->link_topo;
50 struct phy_device_node *pdn;
55 pdn = xa_load(&topo->phys, phyindex);
63 static inline int phy_link_topo_add_phy(struct net_device *dev,
64 struct phy_device *phy,
65 enum phy_upstream upt, void *upstream)
70 static inline void phy_link_topo_del_phy(struct net_device *dev,
71 struct phy_device *phy)
75 static inline struct phy_device *
76 phy_link_topo_get_phy(struct net_device *dev, u32 phyindex)
82 #endif /* __PHY_LINK_TOPOLOGY_H */