diff mbox series

[bpf-next,3/3] bpf: Add rst docs for libbpf

Message ID 20210429054734.53264-4-grantseltzer@gmail.com (mailing list archive)
State Changes Requested
Delegated to: BPF
Headers show
Series Autogenerating API documentation | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 7 maintainers not CCed: netdev@vger.kernel.org yhs@fb.com kpsingh@kernel.org kafai@fb.com ast@kernel.org john.fastabend@gmail.com songliubraving@fb.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Grant Seltzer Richman April 29, 2021, 5:47 a.m. UTC
This adds rst files containg documentation files relevant for
libbpf development. naming_convention.rst is pulled from the
previous README.rst file. api.rst is an index page that links
to the api documentation generationg from doxygen+breathe.

Signed-off-by: grantseltzer <grantseltzer@gmail.com>
---
 tools/lib/bpf/docs/api.rst                    | 60 +++++++++++++++++++
 tools/lib/bpf/docs/build.rst                  | 39 ++++++++++++
 tools/lib/bpf/docs/index.rst                  |  6 ++
 .../naming_convention.rst}                    | 18 +++---
 4 files changed, 116 insertions(+), 7 deletions(-)
 create mode 100644 tools/lib/bpf/docs/api.rst
 create mode 100644 tools/lib/bpf/docs/build.rst
 rename tools/lib/bpf/{README.rst => docs/naming_convention.rst} (97%)
diff mbox series

Patch

diff --git a/tools/lib/bpf/docs/api.rst b/tools/lib/bpf/docs/api.rst
new file mode 100644
index 000000000..36bac417b
--- /dev/null
+++ b/tools/lib/bpf/docs/api.rst
@@ -0,0 +1,60 @@ 
+.. SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+.. _api:
+
+.. contents:: Table of Contents
+   :local:
+   :depth: 1
+
+LIBBPF API
+==================
+
+
+libbpf.h
+------------------
+
+.. doxygenfile:: libbpf.h
+   :project: libbpf
+
+bpf_core_read.h
+------------------
+
+.. doxygenfile:: bpf_core_read.h
+   :project: libbpf
+
+btf.h
+------------------
+
+.. doxygenfile:: btf.h
+   :project: libbpf
+
+bpf_endian.h
+------------------
+
+.. doxygenfile:: bpf_endian.h
+   :project: libbpf
+
+libbpf_common.h
+------------------
+
+.. doxygenfile:: libbpf_common.h
+   :project: libbpf
+
+hashmap.h
+------------------
+
+.. doxygenfile:: hashmap.h
+   :project: libbpf
+
+
+bpf_helpers.h
+------------------
+
+.. doxygenfile:: bpf_helpers.h
+   :project: libbpf
+
+bpf_helper_defs.h
+------------------
+
+.. doxygenfile:: hashmap.h
+   :project: libbpf
diff --git a/tools/lib/bpf/docs/build.rst b/tools/lib/bpf/docs/build.rst
new file mode 100644
index 000000000..749f96dd2
--- /dev/null
+++ b/tools/lib/bpf/docs/build.rst
@@ -0,0 +1,39 @@ 
+.. SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+.. _build:
+
+Building libbpf
+=======================================
+
+libelf is an internal dependency of libbpf and thus it is required to link
+against and must be installed on the system for applications to work.
+pkg-config is used by default to find libelf, and the program called
+can be overridden with PKG_CONFIG.
+
+If using pkg-config at build time is not desired, it can be disabled by
+setting NO_PKG_CONFIG=1 when calling make.
+
+To build both static libbpf.a and shared libbpf.so:
+
+.. code-block:: bash
+
+    $ cd src
+    $ make
+
+To build only static libbpf.a library in directory build/ and install them
+together with libbpf headers in a staging directory root/:
+
+.. code-block:: bash
+
+    $ cd src
+    $ mkdir build root
+    $ BUILD_STATIC_ONLY=y OBJDIR=build DESTDIR=root make install
+
+To build both static libbpf.a and shared libbpf.so against a custom libelf
+dependency installed in /build/root/ and install them together with libbpf
+headers in a build directory /build/root/:
+
+.. code-block:: bash
+
+    $ cd src
+    $ PKG_CONFIG_PATH=/build/root/lib64/pkgconfig DESTDIR=/build/root make
\ No newline at end of file
diff --git a/tools/lib/bpf/docs/index.rst b/tools/lib/bpf/docs/index.rst
index 31a6ecfab..76bb93580 100644
--- a/tools/lib/bpf/docs/index.rst
+++ b/tools/lib/bpf/docs/index.rst
@@ -1,3 +1,5 @@ 
+.. SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
 libbpf documentation
 =======================================
 
@@ -13,3 +15,7 @@  be that this was already addressed or answered before.
 
 .. toctree::
    :caption: Documentation:
+
+   api
+   naming_convention
+   build
\ No newline at end of file
diff --git a/tools/lib/bpf/README.rst b/tools/lib/bpf/docs/naming_convention.rst
similarity index 97%
rename from tools/lib/bpf/README.rst
rename to tools/lib/bpf/docs/naming_convention.rst
index 8928f7787..6b9ae9701 100644
--- a/tools/lib/bpf/README.rst
+++ b/tools/lib/bpf/docs/naming_convention.rst
@@ -1,6 +1,8 @@ 
 .. SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
 
-libbpf API naming convention
+.. _naming_convention:
+
+API naming convention
 ============================
 
 libbpf API provides access to a few logically separated groups of
@@ -76,7 +78,7 @@  Please take a look at Documentation/networking/af_xdp.rst in the Linux
 kernel source tree on how to use XDP sockets and for some common
 mistakes in case you do not get any traffic up to user space.
 
-libbpf ABI
+ABI
 ==========
 
 libbpf can be both linked statically or used as DSO. To avoid possible
@@ -116,7 +118,8 @@  This bump in ABI version is at most once per kernel development cycle.
 
 For example, if current state of ``libbpf.map`` is:
 
-.. code-block::
+.. code-block:: c
+
         LIBBPF_0.0.1 {
         	global:
                         bpf_func_a;
@@ -128,7 +131,8 @@  For example, if current state of ``libbpf.map`` is:
 , and a new symbol ``bpf_func_c`` is being introduced, then
 ``libbpf.map`` should be changed like this:
 
-.. code-block::
+.. code-block:: c
+
         LIBBPF_0.0.1 {
         	global:
                         bpf_func_a;
@@ -148,7 +152,7 @@  Format of version script and ways to handle ABI changes, including
 incompatible ones, described in details in [1].
 
 Stand-alone build
-=================
+-------------------
 
 Under https://github.com/libbpf/libbpf there is a (semi-)automated
 mirror of the mainline's version of libbpf for a stand-alone build.
@@ -157,12 +161,12 @@  However, all changes to libbpf's code base must be upstreamed through
 the mainline kernel tree.
 
 License
-=======
+-------------------
 
 libbpf is dual-licensed under LGPL 2.1 and BSD 2-Clause.
 
 Links
-=====
+-------------------
 
 [1] https://www.akkadia.org/drepper/dsohowto.pdf
     (Chapter 3. Maintaining APIs and ABIs).