* [PATCH] igb: fix adjusting ptp timestamps for tx/rx latency
@ 2016-07-15 22:08 Kshitiz Gupta
2016-07-15 22:55 ` kbuild test robot
0 siblings, 1 reply; 2+ messages in thread
From: Kshitiz Gupta @ 2016-07-15 22:08 UTC (permalink / raw)
To: Aaron Brown, Jeff Kirsher, Nathan Sullivan
Cc: intel-wired-lan, netdev, linux-kernel, Kshitiz Gupta
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 <kshitiz.gupta@ni.com>
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(-)
diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index f097c5a..3f27f13 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -743,7 +743,7 @@ static void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter)
}
}
- shhwtstamps.hwtstamp = ktime_sub_ns(shhwtstamps.hwtstamp, adjust);
+ shhwtstamps.hwtstamp = ktime_add_ns(shhwtstamps.hwtstamp, adjust);
skb_tstamp_tx(adapter->ptp_tx_skb, &shhwtstamps);
dev_kfree_skb_any(adapter->ptp_tx_skb);
@@ -766,13 +766,30 @@ void igb_ptp_rx_pktstamp(struct igb_q_vector *q_vector,
struct sk_buff *skb)
{
__le64 *regval = (__le64 *)va;
+ struct igb_adapter *adapter = q_vector->adapter;
+ int adjust = 0;
/* The timestamp is recorded in little endian format.
* DWORD: 0 1 2 3
* Field: Reserved Reserved SYSTIML SYSTIMH
*/
- 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) {
+ case SPEED_10:
+ adjust = IGB_RX_LATENCY_10;
+ break;
+ case SPEED_100:
+ adjust = IGB_RX_LATENCY_100;
+ break;
+ case SPEED_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
* for error case of latched timestamp on a dropped packet.
--
2.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] igb: fix adjusting ptp timestamps for tx/rx latency
2016-07-15 22:08 [PATCH] igb: fix adjusting ptp timestamps for tx/rx latency Kshitiz Gupta
@ 2016-07-15 22:55 ` kbuild test robot
0 siblings, 0 replies; 2+ messages in thread
From: kbuild test robot @ 2016-07-15 22:55 UTC (permalink / raw)
To: Kshitiz Gupta
Cc: kbuild-all, Aaron Brown, Jeff Kirsher, Nathan Sullivan,
intel-wired-lan, netdev, linux-kernel, Kshitiz Gupta
[-- Attachment #1: Type: text/plain, Size: 2310 bytes --]
Hi,
[auto build test ERROR on jkirsher-next-queue/dev-queue]
[also build test ERROR on v4.7-rc7 next-20160715]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Kshitiz-Gupta/igb-fix-adjusting-ptp-timestamps-for-tx-rx-latency/20160716-062544
base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 5.3.1-8) 5.3.1 20160205
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All errors (new ones prefixed by >>):
drivers/net/ethernet/intel/igb/igb_ptp.c: In function 'igb_ptp_rx_pktstamp':
>> 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
>> 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;
^
>> 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
[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 46471 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-07-15 22:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 22:08 [PATCH] igb: fix adjusting ptp timestamps for tx/rx latency Kshitiz Gupta
2016-07-15 22:55 ` kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).