Re: [PATCH net-next v2 2/5] net: rnpgbe: Report link settings through ethtool

From
Yibo Dong <dong100@mucse.com>
Date
2026-11-16 04:48:25
Also in
lkml
Reply to
Andrew Lunn, 2026-11-16
On Mon, Nov 16, 2026 at 05:19:35AM +0100, Andrew Lunn wrote:
quoted
+static int rnpgbe_get_link_ksettings(struct net_device *netdev,
+				     struct ethtool_link_ksettings *cmd)
+{
+	struct mucse *mucse = netdev_priv(netdev);
+	struct mucse_hw *hw = &mucse->hw;
+	u32 supported, advertising;
+	unsigned long flags;
+	u16 status;
+	int mode;
+
+	status = hw->link_config.status;
+	supported = hw->link_config.supported;
+	advertising = hw->link_config.advertising;
These are accessed without a lock,
The fields in link_config contain cached capabilities and configuration.
They are initialized before netdevice registration, and subsequent
configuration updates are serialized with ethtool queries by RTNL.
Firmware link events do not modify this cache.
quoted
+	ethtool_link_ksettings_zero_link_mode(cmd, supported);
+	ethtool_link_ksettings_zero_link_mode(cmd, advertising);
+	ethtool_link_ksettings_zero_link_mode(cmd, lp_advertising);
+	cmd->base.autoneg = AUTONEG_DISABLE;
+	cmd->base.speed = SPEED_UNKNOWN;
+	cmd->base.duplex = DUPLEX_UNKNOWN;
+	cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID;
+	spin_lock_irqsave(&mucse->link_lock, flags);
+	if (netif_carrier_ok(netdev) && hw->link) {
+		cmd->base.speed = hw->speed;
+		cmd->base.duplex = hw->duplex ?
+				   DUPLEX_FULL : DUPLEX_HALF;
+		if (status & MUCSE_LINK_TP)
+			cmd->base.eth_tp_mdix = hw->mdix;
Yet these need a lock?
link, speed, duplex and mdix are updated asynchronously by
the mailbox event handler, outside RTNL. link_lock protects these updates
and provides a consistent snapshot in the getter.
quoted
+	}
+	spin_unlock_irqrestore(&mucse->link_lock, flags);
+
+	if (status & MUCSE_LINK_TP) {
+		rnpgbe_link_modes(cmd->link_modes.supported, supported);
+		rnpgbe_link_modes(cmd->link_modes.advertising, advertising);
+		ethtool_link_ksettings_add_link_mode(cmd, supported, TP);
+		ethtool_link_ksettings_add_link_mode(cmd, advertising, TP);
Advertising TP? Can you point to some part of 802.3 to support
advertising TP to the link partner.
You're right. Adding TP to the advertising bitmap here was a mistake.
I will remove it from advertising in next version.
	Andrew
Thanks for your feedback.
Thread (17 messages) 17 messages, 3 authors, last reply 2d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help