1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2022 Linutronix GmbH */
3 
4 #include <linux/bpf.h>
5 #include <bpf/bpf_helpers.h>
6 
7 char _license[] SEC("license") = "GPL";
8 
9 SEC("tc")
10 int time_tai(struct __sk_buff *skb)
11 {
12 	__u64 ts1, ts2;
13 
14 	/* Get TAI timestamps */
15 	ts1 = bpf_ktime_get_tai_ns();
16 	ts2 = bpf_ktime_get_tai_ns();
17 
18 	/* Save TAI timestamps (Note: skb->hwtstamp is read-only) */
19 	skb->tstamp = ts1;
20 	skb->cb[0] = ts2 & 0xffffffff;
21 	skb->cb[1] = ts2 >> 32;
22 
23 	return 0;
24 }
25