Skip to contentSkip to conversation

igc: Fix wrong timestamp latency numbers

PATCH New Vinicius Costa Gomes 2 participants 4 messages Aug 18, 2020 – Aug 26, 2020

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

PATCH v2 1/2 igc: Fix wrong timestamp latency numbers

Changes from v1:
- Added Fixes tag

The previous timestamping latency numbers were obtained by interpolating the i210 numbers with the i225 crystal clock value. That calculation was wrong.

Use the correct values from real measurements.

Fixes 81b055205e8b ("igc: Add support for RX timestamping")
---
 drivers/net/ethernet/intel/igc/igc.h | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/ethernet/intel/igc/igc.h +8 -12
index 3070dfdb7eb4..2d566f3c827b 100644
@@ -299,18 +299,14 @@ extern char igc_driver_name[];
 #define IGC_RX_HDR_LEN			IGC_RXBUFFER_256
 
 /* Transmit and receive latency (for PTP timestamps) */
-/* FIXME: These values were estimated using the ones that i225 has as
- * basis, they seem to provide good numbers with ptp4l/phc2sys, but we
- * need to confirm them.
- */
-#define IGC_I225_TX_LATENCY_10		9542
-#define IGC_I225_TX_LATENCY_100		1024
-#define IGC_I225_TX_LATENCY_1000	178
-#define IGC_I225_TX_LATENCY_2500	64
-#define IGC_I225_RX_LATENCY_10		20662
-#define IGC_I225_RX_LATENCY_100		2213
-#define IGC_I225_RX_LATENCY_1000	448
-#define IGC_I225_RX_LATENCY_2500	160
+#define IGC_I225_TX_LATENCY_10		240
+#define IGC_I225_TX_LATENCY_100		58
+#define IGC_I225_TX_LATENCY_1000	80
+#define IGC_I225_TX_LATENCY_2500	1325
+#define IGC_I225_RX_LATENCY_10		6450
+#define IGC_I225_RX_LATENCY_100		185
+#define IGC_I225_RX_LATENCY_1000	300
+#define IGC_I225_RX_LATENCY_2500	1485
 
 /* RX and TX descriptor control thresholds.
  * PTHRESH - MAC will consider prefetch if it has fewer than this number of
Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 2/2 igc: Fix not considering the TX delay for timestamps

Changes from v1:
- Added Fixes tag

When timestamping a packet there's a delay between the start of the packet and the point where the hardware actually captures the timestamp. This difference needs to be considered if we want accurate timestamps.

This was done on the RX side, but not on the TX side.

Fixes 2c344ae24501 ("igc: Add support for TX timestamping")
---
 drivers/net/ethernet/intel/igc/igc_ptp.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
drivers/net/ethernet/intel/igc/igc_ptp.c +19 -0
index 36c999250fcc..6a9b5102aa55 100644
@@ -364,6 +364,7 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
 	struct sk_buff *skb = adapter->ptp_tx_skb;
 	struct skb_shared_hwtstamps shhwtstamps;
 	struct igc_hw *hw = &adapter->hw;
+	int adjust = 0;
 	u64 regval;
 
 	if (WARN_ON_ONCE(!skb))
@@ -373,6 +374,24 @@ static void igc_ptp_tx_hwtstamp(struct igc_adapter *adapter)
 	regval |= (u64)rd32(IGC_TXSTMPH) << 32;
 	igc_ptp_systim_to_hwtstamp(adapter, &shhwtstamps, regval);
 
+	switch (adapter->link_speed) {
+	case SPEED_10:
+		adjust = IGC_I225_TX_LATENCY_10;
+		break;
+	case SPEED_100:
+		adjust = IGC_I225_TX_LATENCY_100;
+		break;
+	case SPEED_1000:
+		adjust = IGC_I225_TX_LATENCY_1000;
+		break;
+	case SPEED_2500:
+		adjust = IGC_I225_TX_LATENCY_2500;
+		break;
+	}
+
+	shhwtstamps.hwtstamp =
+		ktime_add_ns(shhwtstamps.hwtstamp, adjust);
+
 	/* Clear the lock early before calling skb_tstamp_tx so that
 	 * applications are not woken up before the lock bit is clear. We use
 	 * a copy of the skb pointer to ensure other threads can't change it
Signature · 1 line
2.28.0
#2 lore raw

PATCH v2 2/2 igc: Fix not considering the TX delay for timestamps

Quoted 16 lines

From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Tuesday, August 18, 2020 4:40 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Guedes, Andre <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 2/2] igc: Fix not considering the TX delay for timestamps

Changes from v1:
- Added Fixes tag

When timestamping a packet there's a delay between the start of the packet and the point where the hardware actually captures the timestamp. This difference needs to be considered if we want accurate timestamps.

Quoted 8 lines

This was done on the RX side, but not on the TX side.

Fixes 2c344ae24501 ("igc: Add support for TX timestamping")
---
 drivers/net/ethernet/intel/igc/igc_ptp.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
#3 lore raw

PATCH v2 1/2 igc: Fix wrong timestamp latency numbers

In reply to Vinicius Costa Gomes
Quoted 15 lines

From: Intel-wired-lan <[email protected]> On Behalf Of Vinicius Costa Gomes
Sent: Tuesday, August 18, 2020 4:40 PM
To: intel-wired-lan at lists.osuosl.org
Cc: Guedes, Andre <[email protected]>
Subject: [Intel-wired-lan] [PATCH net v2 1/2] igc: Fix wrong timestamp latency numbers

Changes from v1:
- Added Fixes tag

The previous timestamping latency numbers were obtained by interpolating the i210 numbers with the i225 crystal clock value. That calculation was wrong.

Quoted 8 lines

Use the correct values from real measurements.

Fixes 81b055205e8b ("igc: Add support for RX timestamping")
---
 drivers/net/ethernet/intel/igc/igc.h | 20 ++++++++------------
 1 file changed, 8 insertions(+), 12 deletions(-)