aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2023-11-06 19:59:51 +0100
committerAleksandr Nogikh <nogikh@google.com>2023-11-09 18:26:45 +0000
commit24206adf8c2510ab24ff5391c676da047e2523d0 (patch)
tree40f2299354dc4ca0b40055a84574ae8ba747658f /sys/linux
parentdb8894c2e1eb547c641b57d2dcfd61109d5af28a (diff)
sys/linux: describe ringbuf map creation
The corresponding test does the same as this map declaration: struct { __uint(type, BPF_MAP_TYPE_RINGBUF); __uint(max_entries, 256 * 1024); } rb SEC(".maps"); Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'sys/linux')
-rw-r--r--sys/linux/bpf.txt3
-rw-r--r--sys/linux/test/bpf_helpers4
2 files changed, 7 insertions, 0 deletions
diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt
index bfb62a629..974106867 100644
--- a/sys/linux/bpf.txt
+++ b/sys/linux/bpf.txt
@@ -24,6 +24,7 @@ resource fd_bpf_const_str[fd_bpf_const_str_map]
resource bpf_frozen_const_str[fd_bpf_const_str]
resource tail_call_map_fd[fd_bpf_map]
resource tail_call_map[tail_call_map_fd]
+resource ringbuf_map_fd[fd_bpf_map]
# NEED: this is a random index in btf_header:types. We can't express this, so we just use a small index.
type btf_type_id int32[1:5]
@@ -38,6 +39,7 @@ type btf_opt_name_off int32[0:16]
type map_fd_id int32[0:16]
bpf$MAP_CREATE(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg], size len[arg]) fd_bpf_map
+bpf$MAP_CREATE_RINGBUF(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg_ringbuf], size len[arg]) ringbuf_map_fd
bpf$MAP_CREATE_CONST_STR(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg_const_str], size len[arg]) fd_bpf_const_str_map
bpf$MAP_CREATE_TAIL_CALL(cmd const[BPF_MAP_CREATE], arg ptr[in, bpf_map_create_arg_tail_call], size len[arg]) tail_call_map_fd
bpf$MAP_LOOKUP_ELEM(cmd const[BPF_MAP_LOOKUP_ELEM], arg ptr[in, bpf_map_lookup_arg], size len[arg])
@@ -119,6 +121,7 @@ type bpf_map_create_arg_t[TYPE, KSIZE, VSIZE, MAX, FLAGS, MAP_EXTRA] {
type bpf_map_create_arg_base bpf_map_create_arg_t[flags[bpf_map_type, int32], int32, int32, int32, flags[map_flags, int32], const[0, int64]]
type bpf_map_create_arg_bf bpf_map_create_arg_t[const[BPF_MAP_TYPE_BLOOM_FILTER, int32], int32, int32, int32, flags[map_flags, int32], int64[0:15]]
+type bpf_map_create_arg_ringbuf bpf_map_create_arg_t[const[BPF_MAP_TYPE_RINGBUF, int32], const[0, int32], const[0, int32], int32, const[0, int32], const[0, int64]]
type bpf_map_create_arg_const_str bpf_map_create_arg_t[const[BPF_MAP_TYPE_ARRAY, int32], const[4, int32], const[8, int32], const[1, int32], const[BPF_F_RDONLY_PROG, int32], const[0, int64]]
type bpf_map_create_arg_tail_call bpf_map_create_arg_t[const[BPF_MAP_TYPE_PROG_ARRAY, int32], const[4, int32], const[4, int32], const[10, int32], const[0, int32], const[0, int64]]
diff --git a/sys/linux/test/bpf_helpers b/sys/linux/test/bpf_helpers
index b625b68a2..246e903b0 100644
--- a/sys/linux/test/bpf_helpers
+++ b/sys/linux/test/bpf_helpers
@@ -20,3 +20,7 @@ r10 = bpf$MAP_CREATE_TAIL_CALL(AUTO, &AUTO={AUTO, AUTO, AUTO, AUTO, AUTO, 0x0, 0
r11 = bpf$MAP_UPDATE_ELEM_TAIL_CALL(AUTO, &AUTO={{r10, r10}, &AUTO=0x0, &AUTO=r4, AUTO}, 0x1c)
r4 = bpf$PROG_LOAD(AUTO, &AUTO={0x3, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [@tail_call={{AUTO, AUTO, AUTO, AUTO, r10, AUTO, AUTO, AUTO, AUTO}, {AUTO, AUTO, AUTO, AUTO, AUTO, AUTO, AUTO}, {AUTO, AUTO, AUTO, AUTO}, {AUTO, AUTO, AUTO, AUTO, AUTO, AUTO, AUTO}}], {AUTO, AUTO, AUTO, AUTO}}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0xa0)
+
+# Prepare, load, and execute a BPF program that calls ringbuf helpers
+
+r1 = bpf$MAP_CREATE_RINGBUF(AUTO, &AUTO={AUTO, AUTO, AUTO, 0x40000, AUTO, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x0, 0x0, 0x0, 0x0, AUTO}, 0x48)