Debian Codegraph @

src/xdp_metadata.c

raw symbols SCIP
1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2 /*
3 * Copyright (C) Intel Corporation
4 * Author Faizal Abdul Rahim <[email protected]>
5 */
6
7 #include "xdp_metadata.h"
8 #include "app_config.h"
9
10 extern int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx, __u64 *timestamp) __ksym;
11
12 void populate_rx_timestamp(struct xdp_md *ctx)
13 {
14 #ifdef RX_TIMESTAMP
15 struct xdp_meta *meta;
16 void *data;
17 int err;
18
19 err = bpf_xdp_adjust_meta(ctx, -(int)sizeof(struct xdp_meta));
20 if (err)
21 return;
22
23 data = (void *)(long)ctx->data;
24 meta = (struct xdp_meta *)(long)ctx->data_meta;
25 /* Bounds check */
26 if ((void *)(meta + 1) > data)
27 return;
28
29 err = bpf_xdp_metadata_rx_timestamp(ctx, &meta->rx_hw_timestamp);
30 meta->rx_sw_timestamp = bpf_ktime_get_tai_ns();
31 if (err) {
32 meta->rx_hw_timestamp_err = err;
33 meta->hint_valid = 0;
34 } else {
35 meta->hint_valid |= XDP_META_FIELD_TS;
36 }
37 #endif
38 }