Skip to contentSkip to conversation

net: ethernet: ti: am65-cpsw-nuss: Fix rx_filter value for PTP support

PATCH Applied Chintan Vankar 3 participants 3 messages Mar 10 – Mar 12

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

PATCH v2 1/1 net: ethernet: ti: am65-cpsw-nuss: Fix rx_filter value for PTP support

The "rx_filter" member of "hwtstamp_config" structure is an enum field and does not support bitwise OR combination of multiple filter values. It causes error while linuxptp application tries to match rx filter version. Fix this by storing the requested filter type in a new port field.

Fixes 97248adb5a3b ("net: ti: am65-cpsw: Update hw timestamping filter for PTPv1 RX packets")

---

This patch is based on commit '0d9a60a0618d' of origin/main branch of Linux net repo.

Link to v2:
https://lore.kernel.org/r/[email protected]/

Changes from v1 to v2:
- Updated variable name to enum to avoid creating new redundant variable as suggested by Jakub Kicinski.

 drivers/net/ethernet/ti/am65-cpsw-nuss.c | 16 +++++++++-------
 drivers/net/ethernet/ti/am65-cpsw-nuss.h |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)
drivers/net/ethernet/ti/am65-cpsw-nuss.c +9 -7
index 967918050433..265ce5479915 100644
@@ -1351,7 +1351,7 @@ static int am65_cpsw_nuss_rx_packets(struct am65_cpsw_rx_flow *flow,
 	ndev_priv = netdev_priv(ndev);
 	am65_cpsw_nuss_set_offload_fwd_mark(skb, ndev_priv->offload_fwd_mark);
 	skb_put(skb, pkt_len);
-	if (port->rx_ts_enabled)
+	if (port->rx_ts_filter)
 		am65_cpts_rx_timestamp(common->cpts, skb);
 	skb_mark_for_recycle(skb);
 	skb->protocol = eth_type_trans(skb, ndev);
@@ -1811,11 +1811,14 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
 
 	switch (cfg->rx_filter) {
 	case HWTSTAMP_FILTER_NONE:
-		port->rx_ts_enabled = false;
+		port->rx_ts_filter = HWTSTAMP_FILTER_NONE;
 		break;
 	case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
 	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
 	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
+		port->rx_ts_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
+		cfg->rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
+		break;
 	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
 	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
 	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
@@ -1825,8 +1828,8 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
 	case HWTSTAMP_FILTER_PTP_V2_EVENT:
 	case HWTSTAMP_FILTER_PTP_V2_SYNC:
 	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
-		port->rx_ts_enabled = true;
-		cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT | HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
+		port->rx_ts_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
+		cfg->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
 		break;
 	case HWTSTAMP_FILTER_ALL:
 	case HWTSTAMP_FILTER_SOME:
@@ -1863,7 +1866,7 @@ static int am65_cpsw_nuss_hwtstamp_set(struct net_device *ndev,
 		ts_ctrl |= AM65_CPSW_TS_TX_ANX_ALL_EN |
 			   AM65_CPSW_PN_TS_CTL_TX_VLAN_LT1_EN;
 
-	if (port->rx_ts_enabled)
+	if (port->rx_ts_filter)
 		ts_ctrl |= AM65_CPSW_TS_RX_ANX_ALL_EN |
 			   AM65_CPSW_PN_TS_CTL_RX_VLAN_LT1_EN;
 
@@ -1888,8 +1891,7 @@ static int am65_cpsw_nuss_hwtstamp_get(struct net_device *ndev,
 	cfg->flags = 0;
 	cfg->tx_type = port->tx_ts_enabled ?
 		      HWTSTAMP_TX_ON : HWTSTAMP_TX_OFF;
-	cfg->rx_filter = port->rx_ts_enabled ? HWTSTAMP_FILTER_PTP_V2_EVENT |
-			HWTSTAMP_FILTER_PTP_V1_L4_EVENT : HWTSTAMP_FILTER_NONE;
+	cfg->rx_filter = port->rx_ts_filter;
 
 	return 0;
 }
drivers/net/ethernet/ti/am65-cpsw-nuss.h +1 -1
index 917c37e4e89b..7750448e4746 100644
@@ -52,7 +52,7 @@ struct am65_cpsw_port {
 	bool				disabled;
 	struct am65_cpsw_slave_data	slave;
 	bool				tx_ts_enabled;
-	bool				rx_ts_enabled;
+	enum hwtstamp_rx_filters	rx_ts_filter;
 	struct am65_cpsw_qos		qos;
 	struct devlink_port		devlink_port;
 	struct bpf_prog			*xdp_prog;
Signature · 1 line
2.34.1
#1 lore raw
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Tue, 10 Mar 2026 21:39:40 +0530 you wrote:

The "rx_filter" member of "hwtstamp_config" structure is an enum field and does not support bitwise OR combination of multiple filter values. It causes error while linuxptp application tries to match rx filter version. Fix this by storing the requested filter type in a new port field.

Fixes 97248adb5a3b ("net: ti: am65-cpsw: Update hw timestamping filter for PTPv1 RX packets")

[...]

Here is the summary with links:
- [net,v2] net: ethernet: ti: am65-cpsw-nuss: Fix rx_filter value for PTP support

    https://git.kernel.org/netdev/net/c/840c9d13cb1c

You are awesome, thank you!

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

Re: [PATCH net v2] net: ethernet: ti: am65-cpsw-nuss: Fix rx_filter value for PTP support: manual merge

In reply to Chintan Vankar

Hi Chintan,

+cc linux-next

Quoted 4 lines · Chintan Vankar

The "rx_filter" member of "hwtstamp_config" structure is an enum field and does not support bitwise OR combination of multiple filter values. It causes error while linuxptp application tries to match rx filter version. Fix this by storing the requested filter type in a new port field.

FYI, we got a small conflict when merging 'net' in 'net-next' in the MPTCP tree due to this patch applied in 'net':

840c9d13cb1c ("net: ethernet: ti: am65-cpsw-nuss: Fix rx_filter value for PTP support")

and this one from 'net-next':

a23c657e332f ("net: ethernet: ti: am65-cpsw: Use also port number to identify timestamps")

----- Generic Message -----
The best is to avoid conflicts between 'net' and 'net-next' trees but if they cannot be avoided when preparing patches, a note about how to fix them is much appreciated.

The conflict has been resolved on our side [1] and the resolution we suggest is attached to this email. Please report any issues linked to this conflict resolution as it might be used by others. If you worked on the mentioned patches, don't hesitate to ACK this conflict resolution.
---------------------------

Rerere cache is available in [2].

The conflict was in the context: this patch here in 'net' modified the if condition, while the one in 'net-next' modified the line below.

----------- 8< -----------

drivers/net/ethernet/ti/am65-cpsw-nuss.c +0 -0
diff --cc drivers/net/ethernet/ti/am65-cpsw-nuss.c
index a38bf7f4f434,265ce5479915..d9400599e80a
@@@ -1351,8 -1351,8 +1351,8 @@@ static int am65_cpsw_nuss_rx_packets(st
        ndev_priv = netdev_priv(ndev);
        am65_cpsw_nuss_set_offload_fwd_mark(skb, ndev_priv->offload_fwd_mark);
        skb_put(skb, pkt_len);
-       if (port->rx_ts_enabled)
+       if (port->rx_ts_filter)
 -              am65_cpts_rx_timestamp(common->cpts, skb);
 +              am65_cpts_rx_timestamp(common->cpts, port_id, skb);
        skb_mark_for_recycle(skb);
        skb->protocol = eth_type_trans(skb, ndev);
        am65_cpsw_nuss_rx_csum(skb, csum_info);
----------- 8< -----------

1: https://github.com/multipath-tcp/mptcp_net-next/commit/e9021220744d
2: https://github.com/multipath-tcp/mptcp-upstream-rr-cache/commit/c39c9fa

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.