History

xsk: add sock_diag interface for AF_XDP

This patch adds the sock_diag interface for querying sockets from user space. Tools like iproute2 ss(8) can use this interface to list open AF_XDP sockets. The user-space ABI is defined in linux/xdp_diag.h and includes netlink request and response structs. The request can query sockets and the response contains socket information about the rings, umems, inode and more.

Björn Töpel committed 7 years ago

Commit a36b38a1 parent 50e74c06 files · +285 −5Browse files

Showing the changes to include/uapi/linux (1 of 6 files). Show all

Unified · Split

include/uapi/linux/xdp_diag.h+72−0
@@ -0,0 +1,72 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+/*
3+ * xdp_diag: interface for query/monitor XDP sockets
4+ * Copyright(c) 2019 Intel Corporation.
5+ */
6+
7+#ifndef _LINUX_XDP_DIAG_H
8+#define _LINUX_XDP_DIAG_H
9+
10+#include <linux/types.h>
11+
12+struct xdp_diag_req {
13+ __u8 sdiag_family;
14+ __u8 sdiag_protocol;
15+ __u16 pad;
16+ __u32 xdiag_ino;
17+ __u32 xdiag_show;
18+ __u32 xdiag_cookie[2];
19+};
20+
21+struct xdp_diag_msg {
22+ __u8 xdiag_family;
23+ __u8 xdiag_type;
24+ __u16 pad;
25+ __u32 xdiag_ino;
26+ __u32 xdiag_cookie[2];
27+};
28+
29+#define XDP_SHOW_INFO (1 << 0) /* Basic information */
30+#define XDP_SHOW_RING_CFG (1 << 1)
31+#define XDP_SHOW_UMEM (1 << 2)
32+#define XDP_SHOW_MEMINFO (1 << 3)
33+
34+enum {
35+ XDP_DIAG_NONE,
36+ XDP_DIAG_INFO,
37+ XDP_DIAG_UID,
38+ XDP_DIAG_RX_RING,
39+ XDP_DIAG_TX_RING,
40+ XDP_DIAG_UMEM,
41+ XDP_DIAG_UMEM_FILL_RING,
42+ XDP_DIAG_UMEM_COMPLETION_RING,
43+ XDP_DIAG_MEMINFO,
44+ __XDP_DIAG_MAX,
45+};
46+
47+#define XDP_DIAG_MAX (__XDP_DIAG_MAX - 1)
48+
49+struct xdp_diag_info {
50+ __u32 ifindex;
51+ __u32 queue_id;
52+};
53+
54+struct xdp_diag_ring {
55+ __u32 entries; /*num descs */
56+};
57+
58+#define XDP_DU_F_ZEROCOPY (1 << 0)
59+
60+struct xdp_diag_umem {
61+ __u64 size;
62+ __u32 id;
63+ __u32 num_pages;
64+ __u32 chunk_size;
65+ __u32 headroom;
66+ __u32 ifindex;
67+ __u32 queue_id;
68+ __u32 flags;
69+ __u32 refs;
70+};
71+
72+#endif /* _LINUX_XDP_DIAG_H */