[PATCH net-next v3 7/7] net: dsa: microchip: Disable PTP function of KSZ8463

Tristram.Ha@microchip.com posted 7 patches 3 months ago
There is a newer version of this series
[PATCH net-next v3 7/7] net: dsa: microchip: Disable PTP function of KSZ8463
Posted by Tristram.Ha@microchip.com 3 months ago
From: Tristram Ha <tristram.ha@microchip.com>

The PTP function of KSZ8463 is on by default.  However, its proprietary
way of storing timestamp directly in a reserved field inside the PTP
message header is not suitable for use with the current Linux PTP stack
implementation.  It is necessary to disable the PTP function to not
interfere the normal operation of the MAC.

Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
---
 drivers/net/dsa/microchip/ksz8.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
index ddbd05c44ce5..fd4a000487d6 100644
--- a/drivers/net/dsa/microchip/ksz8.c
+++ b/drivers/net/dsa/microchip/ksz8.c
@@ -1761,6 +1761,17 @@ void ksz8_config_cpu_port(struct dsa_switch *ds)
 					   reg16(dev, KSZ8463_REG_DSP_CTRL_6),
 					   COPPER_RECEIVE_ADJUSTMENT, 0);
 		}
+
+		/* Turn off PTP function as the switch's proprietary way of
+		 * handling timestamp is not supported in current Linux PTP
+		 * stack implementation.
+		 */
+		regmap_update_bits(ksz_regmap_16(dev),
+				   reg16(dev, KSZ8463_PTP_MSG_CONF1),
+				   PTP_ENABLE, 0);
+		regmap_update_bits(ksz_regmap_16(dev),
+				   reg16(dev, KSZ8463_PTP_CLK_CTRL),
+				   PTP_CLK_ENABLE, 0);
 	}
 }
 
-- 
2.34.1
Re: [PATCH net-next v3 7/7] net: dsa: microchip: Disable PTP function of KSZ8463
Posted by Vadim Fedorenko 3 months ago
On 09/07/2025 01:32, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <tristram.ha@microchip.com>
> 
> The PTP function of KSZ8463 is on by default.  However, its proprietary
> way of storing timestamp directly in a reserved field inside the PTP
> message header is not suitable for use with the current Linux PTP stack
> implementation.  It is necessary to disable the PTP function to not
> interfere the normal operation of the MAC.

Could you please explain the "proprietary way of storing timestamps"?
Maybe you can provide some examples of headers with timestamps?
Re: [PATCH net-next v3 7/7] net: dsa: microchip: Disable PTP function of KSZ8463
Posted by Vladimir Oltean 3 months ago
On Tue, Jul 08, 2025 at 05:32:33PM -0700, Tristram.Ha@microchip.com wrote:
> From: Tristram Ha <tristram.ha@microchip.com>
> 
> The PTP function of KSZ8463 is on by default.  However, its proprietary
> way of storing timestamp directly in a reserved field inside the PTP
> message header is not suitable for use with the current Linux PTP stack
> implementation.  It is necessary to disable the PTP function to not
> interfere the normal operation of the MAC.
> 
> Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
> ---
>  drivers/net/dsa/microchip/ksz8.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/net/dsa/microchip/ksz8.c b/drivers/net/dsa/microchip/ksz8.c
> index ddbd05c44ce5..fd4a000487d6 100644
> --- a/drivers/net/dsa/microchip/ksz8.c
> +++ b/drivers/net/dsa/microchip/ksz8.c
> @@ -1761,6 +1761,17 @@ void ksz8_config_cpu_port(struct dsa_switch *ds)
>  					   reg16(dev, KSZ8463_REG_DSP_CTRL_6),
>  					   COPPER_RECEIVE_ADJUSTMENT, 0);
>  		}
> +
> +		/* Turn off PTP function as the switch's proprietary way of
> +		 * handling timestamp is not supported in current Linux PTP
> +		 * stack implementation.
> +		 */
> +		regmap_update_bits(ksz_regmap_16(dev),
> +				   reg16(dev, KSZ8463_PTP_MSG_CONF1),
> +				   PTP_ENABLE, 0);
> +		regmap_update_bits(ksz_regmap_16(dev),
> +				   reg16(dev, KSZ8463_PTP_CLK_CTRL),
> +				   PTP_CLK_ENABLE, 0);
>  	}
>  }
>  
> -- 
> 2.34.1
> 

What prevents the user from later enabling this through
ksz_set_hwtstamp_config(HWTSTAMP_TX_ONESTEP_P2P)?