diff mbox series

net: sparx5: Fix invalid timestamps

Message ID 20240913193357.21899-1-aakash.menon@protempis.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: sparx5: Fix invalid timestamps | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 11 of 11 maintainers
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch warning WARNING: From:/Signed-off-by: email address mismatch: 'From: Aakash Menon <aakash.r.menon@gmail.com>' != 'Signed-off-by: Aakash Menon <aakash.menon@protempis.com>'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-09-14--09-00 (tests: 764)

Commit Message

Aakash Menon Sept. 13, 2024, 7:33 p.m. UTC
Bit 270-271 are occasionally unexpectedly set by the hardware.

This issue was observed with 10G SFPs causing huge time errors (> 30ms) in PTP.

Only 30 bits are needed for the nanosecond part of the timestamp, clear 2 most significant bits before extracting timestamp from the internal frame header.

Signed-off-by: Aakash Menon <aakash.menon@protempis.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Simon Horman Sept. 14, 2024, 8:38 a.m. UTC | #1
On Fri, Sep 13, 2024 at 12:33:57PM -0700, Aakash Menon wrote:
> Bit 270-271 are occasionally unexpectedly set by the hardware.
> 
> This issue was observed with 10G SFPs causing huge time errors (> 30ms) in PTP.
> 
> Only 30 bits are needed for the nanosecond part of the timestamp, clear 2 most significant bits before extracting timestamp from the internal frame header.

Hi Aakash,

Thanks for your patch.

I'll leave the review of the code change itself to others,
but here is some feedback on process.

Please line-wrap patch descriptions at 75 columns wide.

Link: https://docs.kernel.org/process/submitting-patches.html#the-canonical-patch-format

Assuming this is a bug fix, a Fixes tag should be present.
It should go just before the signed-off-by line (or other tags),
with no blank lines in between.

I'm wondering if this Fixes tag is appropriate:

Fixes: 70dfe25cd866 ("net: sparx5: Update extraction/injection for timestamping")
> Signed-off-by: Aakash Menon <aakash.menon@protempis.com>

Also, for reference, fixes for Networking should, in general,
be targeted at the net tree.

	Subject: [PATCH net] ...

And lastly, if you do post a new patch, be sure to wait 24h since
the original patch posting before doing so.

Link: https://docs.kernel.org/process/maintainer-netdev.html

...
Daniel Machon Sept. 14, 2024, 7:03 p.m. UTC | #2
> Bit 270-271 are occasionally unexpectedly set by the hardware.
> 
> This issue was observed with 10G SFPs causing huge time errors (> 30ms) in PTP.
> 
> Only 30 bits are needed for the nanosecond part of the timestamp, clear 2 most significant bits before extracting timestamp from the internal frame header.
> 
> Signed-off-by: Aakash Menon <aakash.menon@protempis.com>
> ---
>  drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> index f3f5fb420468..a05263488851 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> @@ -45,8 +45,12 @@ void sparx5_ifh_parse(u32 *ifh, struct frame_info *info)
>         fwd = (fwd >> 5);
>         info->src_port = FIELD_GET(GENMASK(7, 1), fwd);
> 
> +       /*
> +        * Bit 270-271 are occasionally unexpectedly set by the hardware,
> +        * clear bits before extracting timestamp
> +        */
>         info->timestamp =
> -               ((u64)xtr_hdr[2] << 24) |
> +               ((u64)(xtr_hdr[2] & 0x3F) << 24) |
>                 ((u64)xtr_hdr[3] << 16) |
>                 ((u64)xtr_hdr[4] <<  8) |
>                 ((u64)xtr_hdr[5] <<  0);
> --
> 2.46.0
>

Hi Aakash,

I will (or somebody else) try to reproduce and test this at the
beginning of the next week.

Meanwhile, you can address the issues that Simon mentioned.

Thanks.

/Daniel
diff mbox series

Patch

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
index f3f5fb420468..a05263488851 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
@@ -45,8 +45,12 @@  void sparx5_ifh_parse(u32 *ifh, struct frame_info *info)
 	fwd = (fwd >> 5);
 	info->src_port = FIELD_GET(GENMASK(7, 1), fwd);
 
+	/*
+	 * Bit 270-271 are occasionally unexpectedly set by the hardware,
+	 * clear bits before extracting timestamp
+	 */
 	info->timestamp =
-		((u64)xtr_hdr[2] << 24) |
+		((u64)(xtr_hdr[2] & 0x3F) << 24) |
 		((u64)xtr_hdr[3] << 16) |
 		((u64)xtr_hdr[4] <<  8) |
 		((u64)xtr_hdr[5] <<  0);