blob: f41619e312ace5ae12d58beaeb4484a482d7c362 [file] [log] [blame]
Christoph Hellwigbc84e952021-11-19 17:32:14 +01001
Dave Tucker5931d9a2021-11-12 21:17:24 +00002=========
Christoph Hellwigbc84e952021-11-19 17:32:14 +01003eBPF maps
4=========
5
6'maps' is a generic storage of different types for sharing data between kernel
7and userspace.
8
9The maps are accessed from user space via BPF syscall, which has commands:
10
11- create a map with given type and attributes
12 ``map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size)``
13 using attr->map_type, attr->key_size, attr->value_size, attr->max_entries
14 returns process-local file descriptor or negative error
15
16- lookup key in a given map
17 ``err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size)``
18 using attr->map_fd, attr->key, attr->value
19 returns zero and stores found elem into value or negative error
20
21- create or update key/value pair in a given map
22 ``err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)``
23 using attr->map_fd, attr->key, attr->value
24 returns zero or negative error
25
26- find and delete element by key in a given map
27 ``err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)``
28 using attr->map_fd, attr->key
29
30- to delete map: close(fd)
31 Exiting process will delete maps automatically
32
33userspace programs use this syscall to create/access maps that eBPF programs
34are concurrently updating.
35
36maps can have different types: hash, array, bloom filter, radix-tree, etc.
37
38The map is defined by:
39
40 - type
41 - max number of elements
42 - key size in bytes
43 - value size in bytes
44
Dave Tucker5931d9a2021-11-12 21:17:24 +000045Map Types
46=========
47
48.. toctree::
49 :maxdepth: 1
50 :glob:
51
52 map_*