Skip to contentSkip to conversation

net: lan966x: fix disabling timestamping without PTP traps

PATCH Applied Daniel Machon 3 participants 5 messages Nov 23 – Nov 27

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: lan966x: fix disabling timestamping without PTP traps

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")
---
 drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/lan966x/lan966x_ptp.c +1 -1
index 9be2cfe6feeb7..e3af7831a10c3 100644
@@ -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,

Signature · 1 line
Daniel Machon <[email protected]>
maintainer
#1 lore raw
Quoted 15 lines · Daniel Machon

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.

Quoted 8 lines

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")

IMHO this is borderline for net at this point of the cycle. Any strong objection to move this one to net-next?

Thanks,

Paolo

#2 lore raw
Quoted 22 lines · Daniel Machon
Quoted 21 lines

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.

Quoted 4 lines
Quoted 2 lines
Fixes 72df3489fb10 ("net: lan966x: Add ptp trap rules")

IMHO this is borderline for net at this point of the cycle. Any strong objection to move this one to net-next?

net-next is fine. Does that require a repost without a fixes tag, or can you apply it directly as-is?

Quoted 5 lines

Thanks,

Paolo

/Daniel

maintainer
#3 lore raw
Quoted 22 lines · Daniel Machon
Quoted 22 lines · Daniel Machon
Quoted 21 lines

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.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Fixes 72df3489fb10 ("net: lan966x: Add ptp trap rules")

IMHO this is borderline for net at this point of the cycle. Any strong objection to move this one to net-next?

net-next is fine. Does that require a repost without a fixes tag, or can you apply it directly as-is?

No repost needed, thanks!

Paolo

#4 lore raw
In reply to Daniel Machon
This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Paolo Abeni <[email protected]>:

Quoted 5 lines · On Mon, 23 Nov 2026 15:53:54 +0100 you wrote:

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.

Quoted 7 lines

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.

[...]

Here is the summary with links:
- [net] net: lan966x: fix disabling timestamping without PTP traps

    https://git.kernel.org/netdev/net-next/c/e20a00eb02ca

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html