我的以太网接口驱动程序是“igc”。如何在ebpf-XDP程序中获取时间戳?

问题描述 投票:0回答:1

事实是我是此类编程的初学者。如何在 xdp 程序中获取时间戳。详细的分步说明对我很有帮助。现在,即使我使用 -l 标志链接了 makefile 中的头库,但它也不起作用。 Echoing the path

接收每个 rx 数据包的 nic rx 时间戳。

timestamp driver ebpf xdp-pdf
1个回答
0
投票

在内核 v6.3 中添加了

bpf_xdp_metadata_rx_timestamp
kfunc,这正是添加了此功能。

在kernek v6.5中添加了对igc驱动程序的支持。

根据内核自测试中找到的示例代码,这应该可以工作(免责声明:尚未亲自测试过):

#include <vmlinux.h>
#include <bpf/bpf_helpers.h>

extern int bpf_xdp_metadata_rx_timestamp(const struct xdp_md *ctx,
                     __u64 *timestamp) __ksym;

SEC("xdp")
int rx(struct xdp_md *ctx)
{
    __u64 rx_timestamp;
    int err;

    err = bpf_xdp_metadata_rx_timestamp(ctx, &rx_timestamp);
    if (err)
        return XDP_ABORTED;
    
    return XDP_PASS;
}

char _license[] SEC("license") = "GPL";

请注意,在添加此 kfunc 之前,此信息也可用,但仅在使用 __sk_buff 上下文的程序中,所以不是 XDP。

© www.soinside.com 2019 - 2024. All rights reserved.