Fix PHY delay compensation math in igb_ptp_tx_hwtstamp() and
igb_ptp_rx_rgtstamp. Add PHY delay compensation in
igb_ptp_rx_pktstamp().
In the IGB driver, there are two functions that retrieve timestamps
received by the PHY - igb_ptp_rx_rgtstamp() and igb_ptp_rx_pktstamp().
The previous commit only changed igb_ptp_rx_rgtstamp(), and the change
was incorrect.
There are two instances in which PHY delay compensations should be
made:
- Before the packet transmission over the PHY, the latency between
when the packet is timestamped and transmission of the packets,
should be an add operation, but it is currently a subtract.
- After the packets are received from the PHY, the latency between
the receiving and timestamping of the packets should be a subtract
operation, but it is currently an add.
Signed-off-by: Kshitiz Gupta <redacted>
Fixes: 3f544d2 (igb: adjust ptp timestamps for tx/rx latency)
---
drivers/net/ethernet/intel/igb/igb_ptp.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
@@ -766,13 +766,30 @@ void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,structsk_buff*skb){__le64*regval=(__le64*)va;+structigb_adapter*adapter=q_vector->adapter;+intadjust=0;/* The timestamp is recorded in little endian format.*DWORD:0123*Field:ReservedReservedSYSTIMLSYSTIMH*/-igb_ptp_systim_to_hwtstamp(q_vector->adapter,skb_hwtstamps(skb),+igb_ptp_systim_to_hwtstamp(adapter,skb_hwtstamps(skb),le64_to_cpu(regval[1]));++/* adjust timestamp for the RX latency based on link speed */+switch(adapter->link_speed){+caseSPEED_10:+adjust=IGB_RX_LATENCY_10;+break;+caseSPEED_100:+adjust=IGB_RX_LATENCY_100;+break;+caseSPEED_1000:+adjust=IGB_RX_LATENCY_1000;+break;+}+skb_hwtstamps(skb)->hwtstamp=+ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp,adjust);}/**
@@ -824,7 +841,7 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,}}skb_hwtstamps(skb)->hwtstamp=-ktime_add_ns(skb_hwtstamps(skb)->hwtstamp,adjust);+ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp,adjust);/* Update the last_rx_timestamp timer in order to enable watchdog check*forerrorcaseoflatchedtimestamponadroppedpacket.
drivers/net/ethernet/intel/igb/igb_ptp.c:783:12: error: 'IGB_RX_LATENCY_10' undeclared (first use in this function)
adjust = IGB_RX_LATENCY_10;
^
drivers/net/ethernet/intel/igb/igb_ptp.c:783:12: note: each undeclared identifier is reported only once for each function it appears in
quoted
drivers/net/ethernet/intel/igb/igb_ptp.c:786:12: error: 'IGB_RX_LATENCY_100' undeclared (first use in this function)
adjust = IGB_RX_LATENCY_100;
^
quoted
drivers/net/ethernet/intel/igb/igb_ptp.c:789:12: error: 'IGB_RX_LATENCY_1000' undeclared (first use in this function)
adjust = IGB_RX_LATENCY_1000;
^
vim +/IGB_RX_LATENCY_10 +783 drivers/net/ethernet/intel/igb/igb_ptp.c
777 igb_ptp_systim_to_hwtstamp(adapter, skb_hwtstamps(skb),
778 le64_to_cpu(regval[1]));
779
780 /* adjust timestamp for the RX latency based on link speed */
781 switch (adapter->link_speed) {
782 case SPEED_10:
> 783 adjust = IGB_RX_LATENCY_10;
784 break;
785 case SPEED_100:
> 786 adjust = IGB_RX_LATENCY_100;
787 break;
788 case SPEED_1000:
> 789 adjust = IGB_RX_LATENCY_1000;
790 break;
791 }
792 skb_hwtstamps(skb)->hwtstamp =
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Fix PHY delay compensation math in igb_ptp_tx_hwtstamp() and
igb_ptp_rx_rgtstamp. Add PHY delay compensation in
igb_ptp_rx_pktstamp().
In the IGB driver, there are two functions that retrieve timestamps
received by the PHY - igb_ptp_rx_rgtstamp() and igb_ptp_rx_pktstamp().
The previous commit only changed igb_ptp_rx_rgtstamp(), and the change
was incorrect.
There are two instances in which PHY delay compensations should be
made:
- Before the packet transmission over the PHY, the latency between
when the packet is timestamped and transmission of the packets,
should be an add operation, but it is currently a subtract.
- After the packets are received from the PHY, the latency between
the receiving and timestamping of the packets should be a subtract
operation, but it is currently an add.
Signed-off-by: Kshitiz Gupta <redacted>
Fixes: 3f544d2 (igb: adjust ptp timestamps for tx/rx latency)
---
drivers/net/ethernet/intel/igb/igb_ptp.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
@@ -766,13 +767,32 @@ void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,structsk_buff*skb){__le64*regval=(__le64*)va;+structigb_adapter*adapter=q_vector->adapter;+intadjust=0;/* The timestamp is recorded in little endian format.*DWORD:0123*Field:ReservedReservedSYSTIMLSYSTIMH*/-igb_ptp_systim_to_hwtstamp(q_vector->adapter,skb_hwtstamps(skb),+igb_ptp_systim_to_hwtstamp(adapter,skb_hwtstamps(skb),le64_to_cpu(regval[1]));++/* adjust timestamp for the RX latency based on link speed */+if(adapter->hw.mac.type==e1000_i210){+switch(adapter->link_speed){+caseSPEED_10:+adjust=IGB_I210_RX_LATENCY_10;+break;+caseSPEED_100:+adjust=IGB_I210_RX_LATENCY_100;+break;+caseSPEED_1000:+adjust=IGB_I210_RX_LATENCY_1000;+break;+}+}+skb_hwtstamps(skb)->hwtstamp=+ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp,adjust);}/**
@@ -824,7 +844,7 @@ void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,}}skb_hwtstamps(skb)->hwtstamp=-ktime_add_ns(skb_hwtstamps(skb)->hwtstamp,adjust);+ktime_sub_ns(skb_hwtstamps(skb)->hwtstamp,adjust);/* Update the last_rx_timestamp timer in order to enable watchdog check*forerrorcaseoflatchedtimestamponadroppedpacket.
From: Brown, Aaron F <hidden> Date: 2016-07-21 00:50:34
From: netdev-owner@vger.kernel.org [mailto:netdev-
owner@vger.kernel.org] On Behalf Of Kshitiz Gupta
Sent: Saturday, July 16, 2016 12:24 AM
To: Kirsher, Jeffrey T <redacted>; Nathan Sullivan
[off-list ref]; Brown, Aaron F [off-list ref]
Cc: intel-wired-lan@lists.osuosl.org; netdev@vger.kernel.org; Kshitiz Gupta
[off-list ref]
Subject: [PATCH] igb: fix adjusting ptp timestamps for tx/rx latency
Fix PHY delay compensation math in igb_ptp_tx_hwtstamp() and
igb_ptp_rx_rgtstamp. Add PHY delay compensation in
igb_ptp_rx_pktstamp().
In the IGB driver, there are two functions that retrieve timestamps
received by the PHY - igb_ptp_rx_rgtstamp() and igb_ptp_rx_pktstamp().
The previous commit only changed igb_ptp_rx_rgtstamp(), and the change
was incorrect.
There are two instances in which PHY delay compensations should be
made:
- Before the packet transmission over the PHY, the latency between
when the packet is timestamped and transmission of the packets,
should be an add operation, but it is currently a subtract.
- After the packets are received from the PHY, the latency between
the receiving and timestamping of the packets should be a subtract
operation, but it is currently an add.
Signed-off-by: Kshitiz Gupta <redacted>
Fixes: 3f544d2 (igb: adjust ptp timestamps for tx/rx latency)
---
drivers/net/ethernet/intel/igb/igb_ptp.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
I think I was so engrossed in checking the values for 10 / 100 / 1000 delays that I completely missed the reversed add / subtract when looking at 3f544d2. Thanks for catching that.
Tested-by: Aaron Brown <redacted>