Re: [PATCH bpf-next V2 5/5] selftests/bpf: xdp_hw_metadata track more timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 18/04/2023 18.36, Stanislav Fomichev wrote:
On 04/18, Jesper Dangaard Brouer wrote:
To correlate the hardware RX timestamp with something, add tracking of
two software timestamps both clock source CLOCK_TAI (see description in
man clock_gettime(2)).

XDP metadata is extended with xdp_timestamp for capturing when XDP
received the packet. Populated with BPF helper bpf_ktime_get_tai_ns(). I
could not find a BPF helper for getting CLOCK_REALTIME, which would have
been preferred. In userspace when AF_XDP sees the packet another
software timestamp is recorded via clock_gettime() also clock source
CLOCK_TAI.

[...]

More explanation of the output and how this can be used to identify
clock drift for the HW clock can be seen here[1]:

[1]https://github.com/xdp-project/xdp-project/blob/master/areas/hints/xdp_hints_kfuncs02_driver_igc.org

Signed-off-by: Jesper Dangaard Brouer<brouer@xxxxxxxxxx>
Acked-by: Stanislav Fomichev<sdf@xxxxxxxxxx>

---
  .../testing/selftests/bpf/progs/xdp_hw_metadata.c  |    4 +-
  tools/testing/selftests/bpf/xdp_hw_metadata.c      |   47 ++++++++++++++++++--
  tools/testing/selftests/bpf/xdp_metadata.h         |    1
  3 files changed, 46 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
index e1c787815e44..b2dfd7066c6e 100644
--- a/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
+++ b/tools/testing/selftests/bpf/progs/xdp_hw_metadata.c
@@ -77,7 +77,9 @@ int rx(struct xdp_md *ctx)
  	}
err = bpf_xdp_metadata_rx_timestamp(ctx, &meta->rx_timestamp);
-	if (err)
[..]

+	if (!err)
+		meta->xdp_timestamp = bpf_ktime_get_tai_ns();
nit: why not set it unconditionally?

Because userspace application doesn't use it for anything, when
meta->rx_timestamp is zero.

--Jesper




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux