diff mbox series

net: ethernet: ti: cpsw: disable PTPv1 hw timestamping advertisement

Message ID 20201029190910.30789-1-grygorii.strashko@ti.com (mailing list archive)
State Not Applicable
Delegated to: Netdev Maintainers
Headers show
Series net: ethernet: ti: cpsw: disable PTPv1 hw timestamping advertisement | expand

Commit Message

Grygorii Strashko Oct. 29, 2020, 7:09 p.m. UTC
The TI CPTS does not natively support PTPv1, only PTPv2. But, as it
happens, the CPTS can provide HW timestamp for PTPv1 Sync messages, because
CPTS HW parser looks for PTP messageType id in PTP message octet 0 which
value is 0 for PTPv1. As result, CPTS HW can detect Sync messages for PTPv1
and PTPv2 (Sync messageType = 0 for both), but it fails for any other PTPv1
messages (Delay_req/resp) and will return PTP messageType id 0 for them.

The commit e9523a5a32a1 ("net: ethernet: ti: cpsw: enable
HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter") added PTPv1 hw timestamping
advertisement by mistake, only to make Linux Kernel "timestamping" utility
work, and this causes issues with only PTPv1 compatible HW/SW - Sync HW
timestamped, but Delay_req/resp are not.

Hence, fix it disabling PTPv1 hw timestamping advertisement, so only PTPv1
compatible HW/SW can properly roll back to SW timestamping.

Fixes: e9523a5a32a1 ("net: ethernet: ti: cpsw: enable HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter")
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/net/ethernet/ti/cpsw_ethtool.c | 1 -
 drivers/net/ethernet/ti/cpsw_priv.c    | 5 +----
 2 files changed, 1 insertion(+), 5 deletions(-)

Comments

Jakub Kicinski Oct. 31, 2020, 6:40 p.m. UTC | #1
On Thu, 29 Oct 2020 21:09:10 +0200 Grygorii Strashko wrote:
> The TI CPTS does not natively support PTPv1, only PTPv2. But, as it
> happens, the CPTS can provide HW timestamp for PTPv1 Sync messages, because
> CPTS HW parser looks for PTP messageType id in PTP message octet 0 which
> value is 0 for PTPv1. As result, CPTS HW can detect Sync messages for PTPv1
> and PTPv2 (Sync messageType = 0 for both), but it fails for any other PTPv1
> messages (Delay_req/resp) and will return PTP messageType id 0 for them.
> 
> The commit e9523a5a32a1 ("net: ethernet: ti: cpsw: enable
> HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter") added PTPv1 hw timestamping
> advertisement by mistake, only to make Linux Kernel "timestamping" utility
> work, and this causes issues with only PTPv1 compatible HW/SW - Sync HW
> timestamped, but Delay_req/resp are not.
> 
> Hence, fix it disabling PTPv1 hw timestamping advertisement, so only PTPv1
> compatible HW/SW can properly roll back to SW timestamping.
> 
> Fixes: e9523a5a32a1 ("net: ethernet: ti: cpsw: enable HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter")
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

CC: Richard

> diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c
> index 4d02c5135611..4619c3a950b0 100644
> --- a/drivers/net/ethernet/ti/cpsw_ethtool.c
> +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c
> @@ -728,7 +728,6 @@ int cpsw_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info)
>  		(1 << HWTSTAMP_TX_ON);
>  	info->rx_filters =
>  		(1 << HWTSTAMP_FILTER_NONE) |
> -		(1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
>  		(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
>  	return 0;
>  }
> diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
> index 51cc29f39038..31c5e36ff706 100644
> --- a/drivers/net/ethernet/ti/cpsw_priv.c
> +++ b/drivers/net/ethernet/ti/cpsw_priv.c
> @@ -639,13 +639,10 @@ static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
>  		break;
>  	case HWTSTAMP_FILTER_ALL:
>  	case HWTSTAMP_FILTER_NTP_ALL:
> -		return -ERANGE;
>  	case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
>  	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
>  	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
> -		priv->rx_ts_enabled = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
> -		cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
> -		break;
> +		return -ERANGE;
>  	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
>  	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
>  	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
Richard Cochran Nov. 1, 2020, 2:02 a.m. UTC | #2
On Sat, Oct 31, 2020 at 11:40:42AM -0700, Jakub Kicinski wrote:
> On Thu, 29 Oct 2020 21:09:10 +0200 Grygorii Strashko wrote:
> > The TI CPTS does not natively support PTPv1, only PTPv2. But, as it
> > happens, the CPTS can provide HW timestamp for PTPv1 Sync messages, because
> > CPTS HW parser looks for PTP messageType id in PTP message octet 0 which
> > value is 0 for PTPv1. As result, CPTS HW can detect Sync messages for PTPv1
> > and PTPv2 (Sync messageType = 0 for both), but it fails for any other PTPv1
> > messages (Delay_req/resp) and will return PTP messageType id 0 for them.
> > 
> > The commit e9523a5a32a1 ("net: ethernet: ti: cpsw: enable
> > HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter") added PTPv1 hw timestamping
> > advertisement by mistake, only to make Linux Kernel "timestamping" utility
> > work, and this causes issues with only PTPv1 compatible HW/SW - Sync HW
> > timestamped, but Delay_req/resp are not.
> > 
> > Hence, fix it disabling PTPv1 hw timestamping advertisement, so only PTPv1
> > compatible HW/SW can properly roll back to SW timestamping.
> > 
> > Fixes: e9523a5a32a1 ("net: ethernet: ti: cpsw: enable HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter")
> > Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
> 
> CC: Richard

Acked-by: Richard Cochran <richardcochran@gmail.com>
Jakub Kicinski Nov. 2, 2020, 10:20 p.m. UTC | #3
On Sat, 31 Oct 2020 19:02:27 -0700 Richard Cochran wrote:
> On Sat, Oct 31, 2020 at 11:40:42AM -0700, Jakub Kicinski wrote:
> > On Thu, 29 Oct 2020 21:09:10 +0200 Grygorii Strashko wrote:  
> > > The TI CPTS does not natively support PTPv1, only PTPv2. But, as it
> > > happens, the CPTS can provide HW timestamp for PTPv1 Sync messages, because
> > > CPTS HW parser looks for PTP messageType id in PTP message octet 0 which
> > > value is 0 for PTPv1. As result, CPTS HW can detect Sync messages for PTPv1
> > > and PTPv2 (Sync messageType = 0 for both), but it fails for any other PTPv1
> > > messages (Delay_req/resp) and will return PTP messageType id 0 for them.
> > > 
> > > The commit e9523a5a32a1 ("net: ethernet: ti: cpsw: enable
> > > HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter") added PTPv1 hw timestamping
> > > advertisement by mistake, only to make Linux Kernel "timestamping" utility
> > > work, and this causes issues with only PTPv1 compatible HW/SW - Sync HW
> > > timestamped, but Delay_req/resp are not.
> > > 
> > > Hence, fix it disabling PTPv1 hw timestamping advertisement, so only PTPv1
> > > compatible HW/SW can properly roll back to SW timestamping.
> > > 
> > > Fixes: e9523a5a32a1 ("net: ethernet: ti: cpsw: enable HWTSTAMP_FILTER_PTP_V1_L4_EVENT filter")
> > > Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>  
> > 
> > CC: Richard  
> 
> Acked-by: Richard Cochran <richardcochran@gmail.com>

Applied, thanks!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c
index 4d02c5135611..4619c3a950b0 100644
--- a/drivers/net/ethernet/ti/cpsw_ethtool.c
+++ b/drivers/net/ethernet/ti/cpsw_ethtool.c
@@ -728,7 +728,6 @@  int cpsw_get_ts_info(struct net_device *ndev, struct ethtool_ts_info *info)
 		(1 << HWTSTAMP_TX_ON);
 	info->rx_filters =
 		(1 << HWTSTAMP_FILTER_NONE) |
-		(1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) |
 		(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);
 	return 0;
 }
diff --git a/drivers/net/ethernet/ti/cpsw_priv.c b/drivers/net/ethernet/ti/cpsw_priv.c
index 51cc29f39038..31c5e36ff706 100644
--- a/drivers/net/ethernet/ti/cpsw_priv.c
+++ b/drivers/net/ethernet/ti/cpsw_priv.c
@@ -639,13 +639,10 @@  static int cpsw_hwtstamp_set(struct net_device *dev, struct ifreq *ifr)
 		break;
 	case HWTSTAMP_FILTER_ALL:
 	case HWTSTAMP_FILTER_NTP_ALL:
-		return -ERANGE;
 	case HWTSTAMP_FILTER_PTP_V1_L4_EVENT:
 	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:
 	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:
-		priv->rx_ts_enabled = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
-		cfg.rx_filter = HWTSTAMP_FILTER_PTP_V1_L4_EVENT;
-		break;
+		return -ERANGE;
 	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
 	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
 	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: