diff mbox series

[4/5] bpf, docs: move handling of maps to Documentation/bpf/maps.rst

Message ID 20211119163215.971383-5-hch@lst.de (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [1/5] x86, bpf: cleanup the top of file header in bpf_jit_comp.c | expand

Checks

Context Check Description
bpf/vmtest-bpf-PR fail merge-conflict
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next success VM_Test
netdev/tree_selection success Guessing tree name failed - patch did not apply, async

Commit Message

Christoph Hellwig Nov. 19, 2021, 4:32 p.m. UTC
Move the general maps documentation into the maps.rst file from the
overall networking filter documentation and add a link instead.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 Documentation/bpf/maps.rst          | 43 ++++++++++++++++++++++++++
 Documentation/networking/filter.rst | 47 ++---------------------------
 2 files changed, 46 insertions(+), 44 deletions(-)

Comments

Song Liu Nov. 26, 2021, 6:40 a.m. UTC | #1
On Fri, Nov 19, 2021 at 8:32 AM Christoph Hellwig <hch@lst.de> wrote:
>
> Move the general maps documentation into the maps.rst file from the
> overall networking filter documentation and add a link instead.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Acked-by: Song Liu <songliubraving@fb.com>
diff mbox series

Patch

diff --git a/Documentation/bpf/maps.rst b/Documentation/bpf/maps.rst
index 2084b0e7cde88..f41619e312ace 100644
--- a/Documentation/bpf/maps.rst
+++ b/Documentation/bpf/maps.rst
@@ -1,4 +1,47 @@ 
+
+=========
+eBPF maps
 =========
+
+'maps' is a generic storage of different types for sharing data between kernel
+and userspace.
+
+The maps are accessed from user space via BPF syscall, which has commands:
+
+- create a map with given type and attributes
+  ``map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size)``
+  using attr->map_type, attr->key_size, attr->value_size, attr->max_entries
+  returns process-local file descriptor or negative error
+
+- lookup key in a given map
+  ``err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size)``
+  using attr->map_fd, attr->key, attr->value
+  returns zero and stores found elem into value or negative error
+
+- create or update key/value pair in a given map
+  ``err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)``
+  using attr->map_fd, attr->key, attr->value
+  returns zero or negative error
+
+- find and delete element by key in a given map
+  ``err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)``
+  using attr->map_fd, attr->key
+
+- to delete map: close(fd)
+  Exiting process will delete maps automatically
+
+userspace programs use this syscall to create/access maps that eBPF programs
+are concurrently updating.
+
+maps can have different types: hash, array, bloom filter, radix-tree, etc.
+
+The map is defined by:
+
+  - type
+  - max number of elements
+  - key size in bytes
+  - value size in bytes
+
 Map Types
 =========
 
diff --git a/Documentation/networking/filter.rst b/Documentation/networking/filter.rst
index 83ffcaa5b91aa..43ef05b91f986 100644
--- a/Documentation/networking/filter.rst
+++ b/Documentation/networking/filter.rst
@@ -1232,9 +1232,9 @@  pointer type.  The types of pointers describe their base, as follows:
 			Pointer to the value stored in a map element.
     PTR_TO_MAP_VALUE_OR_NULL
 			Either a pointer to a map value, or NULL; map accesses
-			(see section 'eBPF maps', below) return this type,
-			which becomes a PTR_TO_MAP_VALUE when checked != NULL.
-			Arithmetic on these pointers is forbidden.
+			(see maps.rst) return this type, which becomes a
+			a PTR_TO_MAP_VALUE when checked != NULL. Arithmetic on
+			these pointers is forbidden.
     PTR_TO_STACK
 			Frame pointer.
     PTR_TO_PACKET
@@ -1402,47 +1402,6 @@  using normal C code as::
 which makes such programs easier to write comparing to LD_ABS insn
 and significantly faster.
 
-eBPF maps
----------
-'maps' is a generic storage of different types for sharing data between kernel
-and userspace.
-
-The maps are accessed from user space via BPF syscall, which has commands:
-
-- create a map with given type and attributes
-  ``map_fd = bpf(BPF_MAP_CREATE, union bpf_attr *attr, u32 size)``
-  using attr->map_type, attr->key_size, attr->value_size, attr->max_entries
-  returns process-local file descriptor or negative error
-
-- lookup key in a given map
-  ``err = bpf(BPF_MAP_LOOKUP_ELEM, union bpf_attr *attr, u32 size)``
-  using attr->map_fd, attr->key, attr->value
-  returns zero and stores found elem into value or negative error
-
-- create or update key/value pair in a given map
-  ``err = bpf(BPF_MAP_UPDATE_ELEM, union bpf_attr *attr, u32 size)``
-  using attr->map_fd, attr->key, attr->value
-  returns zero or negative error
-
-- find and delete element by key in a given map
-  ``err = bpf(BPF_MAP_DELETE_ELEM, union bpf_attr *attr, u32 size)``
-  using attr->map_fd, attr->key
-
-- to delete map: close(fd)
-  Exiting process will delete maps automatically
-
-userspace programs use this syscall to create/access maps that eBPF programs
-are concurrently updating.
-
-maps can have different types: hash, array, bloom filter, radix-tree, etc.
-
-The map is defined by:
-
-  - type
-  - max number of elements
-  - key size in bytes
-  - value size in bytes
-
 Pruning
 -------
 The verifier does not actually walk all possible paths through the program.  For