History

net: phy: Introduce ethernet link topology representation

Link topologies containing multiple network PHYs attached to the same net_device can be found when using a PHY as a media converter for use with an SFP connector, on which an SFP transceiver containing a PHY can be used. With the current model, the transceiver's PHY can't be used for operations such as cable testing, timestamping, macsec offload, etc. The reason being that most of the logic for these configuration, coming from either ethtool netlink or ioctls tend to use netdev->phydev, which in multi-phy systems will reference the PHY closest to the MAC. Introduce a numbering scheme allowing to enumerate PHY devices that belong to any netdev, which can in turn allow userspace to take more precise decisions with regard to each PHY's configuration. The numbering is maintained per-netdev, in a phy_device_list. The numbering works similarly to a netdevice's ifindex, with identifiers that are only recycled once INT_MAX has been reached. This prevents races that could occur between PHY listing and SFP transceiver removal/insertion. The identifiers are assigned at phy_attach time, as the numbering depends on the netdevice the phy is attached to. The PHY index can be re-used for PHYs that are persistent.

Maxime Chevallier committed 2 years ago

Commit 6916e461 parent d133ef110 files · +244 −2Browse files

Showing the changes to include/uapi (1 of 10 files). Show all

Unified · Split

include/uapi/linux/ethtool.h+16−0
@@ -2268,4 +2268,20 @@ struct ethtool_link_settings { · 2267 unmodified lines
22682268 * __u32 map_lp_advertising[link_mode_masks_nwords];
22692269 */
22702270 };
2271+
2272+/**
2273+ * enum phy_upstream - Represents the upstream component a given PHY device
2274+ * is connected to, as in what is on the other end of the MII bus. Most PHYs
2275+ * will be attached to an Ethernet MAC controller, but in some cases, there's
2276+ * an intermediate PHY used as a media-converter, which will driver another
2277+ * MII interface as its output.
2278+ * @PHY_UPSTREAM_MAC: Upstream component is a MAC (a switch port,
2279+ * or ethernet controller)
2280+ * @PHY_UPSTREAM_PHY: Upstream component is a PHY (likely a media converter)
2281+ */
2282+enum phy_upstream {
2283+ PHY_UPSTREAM_MAC,
2284+ PHY_UPSTREAM_PHY,
2285+};
2286+
22712287 #endif /* _UAPI_LINUX_ETHTOOL_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t