Netdev List
 help / color / mirror / Atom feed
* [PATCH net] net: lan966x: fix disabling timestamping without PTP traps
@ 2026-11-23 14:53 Daniel Machon
  2026-11-27  9:11 ` Paolo Abeni
  0 siblings, 1 reply; 2+ messages in thread
From: Daniel Machon @ 2026-11-23 14:53 UTC (permalink / raw)
  To: Horatiu Vultur, UNGLinuxDriver, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Richard Cochran
  Cc: netdev

lan966x_ptp_del_trap() looks up a PTP trap rule with vcap_get_rule() and
removes the port from it, or deletes the rule when no other port needs
it. The traps are removed whenever timestamping is configured with
HWTSTAMP_FILTER_NONE.

Before this patch, every vcap_get_rule() error is returned as -EEXIST,
including the -ENOENT for a trap rule that does not exist, so disabling
timestamping on a port that has no traps installed fails. This breaks
moving the hardware timestamp provider of a port from its PHY to the
MAC.

Return 0 for -ENOENT, as there is nothing to remove. Pass any other
error from vcap_get_rule() on, as the rule may still be installed with
this port in its ingress port mask.

Triggered during test development, without kernel modifications, on a
lan9668 board whose LAN8814 PHYs are the default timestamp provider:
"ethtool --set-hwtimestamp-cfg <port> index <switch PHC> qualifier
precise" failed with "File exists". With the fix the same command moves
the provider to the MAC.

Fixes: 72df3489fb10 ("net: lan966x: Add ptp trap rules")
Signed-off-by: Daniel Machon <daniel.machon@microchip.com>
---
 drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
index 9be2cfe6feeb7..e3af7831a10c3 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c
@@ -110,7 +110,7 @@ static int lan966x_ptp_del_trap(struct lan966x_port *port,
 
 	vrule = vcap_get_rule(lan966x->vcap_ctrl, rule_id);
 	if (IS_ERR(vrule))
-		return -EEXIST;
+		return PTR_ERR(vrule) == -ENOENT ? 0 : PTR_ERR(vrule);
 
 	vcap_rule_get_key_u32(vrule, VCAP_KF_IF_IGR_PORT_MASK, &value, &mask);
 	mask |= BIT(port->chip_port);

---
base-commit: af6737b9066832a2017c281159950ba92385ce00
change-id: 20261123-lan966x-ptp-del-trap-98dde01c5f7b

Best regards,
-- 
Daniel Machon <daniel.machon@microchip.com>


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-27  9:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 14:53 [PATCH net] net: lan966x: fix disabling timestamping without PTP traps Daniel Machon
2026-11-27  9:11 ` Paolo Abeni

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox