diff options
author | Alexei Starovoitov <ast@kernel.org> | 2022-08-09 09:47:14 -0700 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2022-08-09 09:47:14 -0700 |
commit | 11b9148590146ff8a4e90c7f0186efe06009ec1b (patch) | |
tree | 50f2f527d2b291be74a67b6f1ae6c03166838e37 /kernel/bpf/helpers.c | |
parent | b2d8ef19c6e7ed71ba5092feb0710063a751834f (diff) | |
parent | 64e15820b987cc8e5864a8b907dfc17861e6ab5a (diff) |
Merge branch 'Add BPF-helper for accessing CLOCK_TAI'
Kurt Kanzenbach says:
====================
Hi,
add a BPF-helper for accessing CLOCK_TAI. Use cases for such a BPF helper
include functionalities such as Tx launch time (e.g. ETF and TAPRIO Qdiscs),
timestamping and policing.
Patch #1 - Introduce BPF helper
Patch #2 - Add test case (skb based)
Changes since v1:
* Update changelog (Alexei Starovoitov)
* Add test case (Alexei Starovoitov, Andrii Nakryiko)
* Add missing function prototype (netdev ci)
Previous versions:
* v1: https://lore.kernel.org/r/20220606103734.92423-1-kurt@linutronix.de/
Jesper Dangaard Brouer (1):
bpf: Add BPF-helper for accessing CLOCK_TAI
====================
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/helpers.c')
-rw-r--r-- | kernel/bpf/helpers.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 1f961f9982d2..a95eb9fb01ff 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -198,6 +198,18 @@ const struct bpf_func_proto bpf_ktime_get_coarse_ns_proto = { .ret_type = RET_INTEGER, }; +BPF_CALL_0(bpf_ktime_get_tai_ns) +{ + /* NMI safe access to clock tai */ + return ktime_get_tai_fast_ns(); +} + +const struct bpf_func_proto bpf_ktime_get_tai_ns_proto = { + .func = bpf_ktime_get_tai_ns, + .gpl_only = false, + .ret_type = RET_INTEGER, +}; + BPF_CALL_0(bpf_get_current_pid_tgid) { struct task_struct *task = current; @@ -1617,6 +1629,8 @@ bpf_base_func_proto(enum bpf_func_id func_id) return &bpf_ktime_get_ns_proto; case BPF_FUNC_ktime_get_boot_ns: return &bpf_ktime_get_boot_ns_proto; + case BPF_FUNC_ktime_get_tai_ns: + return &bpf_ktime_get_tai_ns_proto; case BPF_FUNC_ringbuf_output: return &bpf_ringbuf_output_proto; case BPF_FUNC_ringbuf_reserve: |