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