diff mbox series

libbpf: Added the description of some API functions

Message ID 20221224112058.12038-1-liuxin350@huawei.com (mailing list archive)
State Accepted
Commit 678a1c036199011e65b203367900f002a28da004
Delegated to: BPF
Headers show
Series libbpf: Added the description of some API functions | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-16 success Logs for test_progs on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for test_maps on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-next-VM_Test-8 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-2 success Logs for build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-3 success Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-4 success Logs for build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-5 success Logs for build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-9 success Logs for test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-10 success Logs for test_maps on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-12 success Logs for test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for test_maps on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-17 success Logs for test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-18 success Logs for test_progs on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-19 success Logs for test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for test_progs_no_alu32 on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-24 success Logs for test_progs_no_alu32_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for test_progs_no_alu32_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-27 success Logs for test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-28 success Logs for test_progs_no_alu32_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-29 success Logs for test_progs_parallel on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-32 success Logs for test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-33 success Logs for test_progs_parallel on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-34 success Logs for test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-35 success Logs for test_verifier on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-37 success Logs for test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-38 success Logs for test_verifier on x86_64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-14 success Logs for test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-15 success Logs for test_progs on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-20 success Logs for test_progs_no_alu32 on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-30 success Logs for test_progs_parallel on aarch64 with llvm-16
bpf/vmtest-bpf-next-VM_Test-36 success Logs for test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-31 success Logs for test_progs_parallel on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for test_progs_no_alu32_parallel on s390x with gcc
bpf/vmtest-bpf-PR success PR summary
bpf/vmtest-bpf-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-VM_Test-2 pending Logs for build for aarch64 with gcc
bpf/vmtest-bpf-VM_Test-3 pending Logs for build for aarch64 with llvm-16
bpf/vmtest-bpf-VM_Test-4 pending Logs for build for s390x with gcc
bpf/vmtest-bpf-VM_Test-5 pending Logs for build for x86_64 with gcc
bpf/vmtest-bpf-VM_Test-6 pending Logs for build for x86_64 with llvm-16
bpf/vmtest-bpf-VM_Test-7 success Logs for llvm-toolchain
bpf/vmtest-bpf-VM_Test-8 success Logs for set-matrix

Commit Message

Xin Liu Dec. 24, 2022, 11:20 a.m. UTC
Currently, many API functions are not described in the document.
I have tried to add the API description of the following four API
functions:
 libbpf_set_print
 bpf_object__open
 bpf_object__load
 bpf_object__close

Signed-off-by: Xin Liu <liuxin350@huawei.com>
---
 tools/lib/bpf/libbpf.h | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

Comments

Andrii Nakryiko Dec. 29, 2022, 10:33 p.m. UTC | #1
On Sat, Dec 24, 2022 at 3:21 AM Xin Liu <liuxin350@huawei.com> wrote:
>
> Currently, many API functions are not described in the document.
> I have tried to add the API description of the following four API
> functions:
>  libbpf_set_print
>  bpf_object__open
>  bpf_object__load
>  bpf_object__close
>
> Signed-off-by: Xin Liu <liuxin350@huawei.com>
> ---

I've tweaked descriptions a bit to match the overall style and fixed
few typos. Pushed to bpf-next, thanks!

>  tools/lib/bpf/libbpf.h | 27 ++++++++++++++++++++++++++-
>  1 file changed, 26 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
> index eee883f007f9..bf3af52d42be 100644
> --- a/tools/lib/bpf/libbpf.h
> +++ b/tools/lib/bpf/libbpf.h
> @@ -96,6 +96,12 @@ enum libbpf_print_level {
>  typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level,
>                                  const char *, va_list ap);
>
> +/**
> + * @brief **libbpf_set_print()** use the user-provided log print function.
> + * @param fn the log print function. Disable all print if the parameter
> + * is NULL.
> + * @return Pointer to old print function.
> + */
>  LIBBPF_API libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn);
>
>  /* Hide internal to user */
> @@ -174,6 +180,14 @@ struct bpf_object_open_opts {
>  };
>  #define bpf_object_open_opts__last_field kernel_log_level
>
> +/**
> + * @brief **bpf_object__open()** creates a bpf_object by opening
> + * the BPF ELF object file pointed to by the passed path and loading it
> + * into memory.
> + * @param path BPF object file path.
> + * @return pointer to the new bpf_object; or NULL is returned on error,
> + * error code is stored in errno
> + */
>  LIBBPF_API struct bpf_object *bpf_object__open(const char *path);
>
>  /**
> @@ -204,9 +218,20 @@ bpf_object__open_mem(const void *obj_buf, size_t obj_buf_sz,
>                      const struct bpf_object_open_opts *opts);
>
>  /* Load/unload object into/from kernel */
> +/**
> + * @brief **bpf_object__load()** load bpf_object into kernel
> + * @param obj pointer to a valid bpf_object
> + * @return 0, on success; negative error code, otherwise, error code is
> + * stored in errno
> + */
>  LIBBPF_API int bpf_object__load(struct bpf_object *obj);
>
> -LIBBPF_API void bpf_object__close(struct bpf_object *object);
> +/**
> + * @brief **bpf_object__close()** close a bpf_object and release all
> + * resources.
> + * @param obj pointer to a valid bpf_object
> + */
> +LIBBPF_API void bpf_object__close(struct bpf_object *obj);
>
>  /* pin_maps and unpin_maps can both be called with a NULL path, in which case
>   * they will use the pin_path attribute of each map (and ignore all maps that
> --
> 2.33.0
>
patchwork-bot+netdevbpf@kernel.org Dec. 29, 2022, 10:40 p.m. UTC | #2
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Sat, 24 Dec 2022 19:20:58 +0800 you wrote:
> Currently, many API functions are not described in the document.
> I have tried to add the API description of the following four API
> functions:
>  libbpf_set_print
>  bpf_object__open
>  bpf_object__load
>  bpf_object__close
> 
> [...]

Here is the summary with links:
  - libbpf: Added the description of some API functions
    https://git.kernel.org/bpf/bpf-next/c/678a1c036199

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index eee883f007f9..bf3af52d42be 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -96,6 +96,12 @@  enum libbpf_print_level {
 typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level,
 				 const char *, va_list ap);
 
+/**
+ * @brief **libbpf_set_print()** use the user-provided log print function.
+ * @param fn the log print function. Disable all print if the parameter
+ * is NULL.
+ * @return Pointer to old print function.
+ */
 LIBBPF_API libbpf_print_fn_t libbpf_set_print(libbpf_print_fn_t fn);
 
 /* Hide internal to user */
@@ -174,6 +180,14 @@  struct bpf_object_open_opts {
 };
 #define bpf_object_open_opts__last_field kernel_log_level
 
+/**
+ * @brief **bpf_object__open()** creates a bpf_object by opening
+ * the BPF ELF object file pointed to by the passed path and loading it
+ * into memory.
+ * @param path BPF object file path.
+ * @return pointer to the new bpf_object; or NULL is returned on error,
+ * error code is stored in errno
+ */
 LIBBPF_API struct bpf_object *bpf_object__open(const char *path);
 
 /**
@@ -204,9 +218,20 @@  bpf_object__open_mem(const void *obj_buf, size_t obj_buf_sz,
 		     const struct bpf_object_open_opts *opts);
 
 /* Load/unload object into/from kernel */
+/**
+ * @brief **bpf_object__load()** load bpf_object into kernel
+ * @param obj pointer to a valid bpf_object
+ * @return 0, on success; negative error code, otherwise, error code is
+ * stored in errno
+ */
 LIBBPF_API int bpf_object__load(struct bpf_object *obj);
 
-LIBBPF_API void bpf_object__close(struct bpf_object *object);
+/**
+ * @brief **bpf_object__close()** close a bpf_object and release all
+ * resources.
+ * @param obj pointer to a valid bpf_object
+ */
+LIBBPF_API void bpf_object__close(struct bpf_object *obj);
 
 /* pin_maps and unpin_maps can both be called with a NULL path, in which case
  * they will use the pin_path attribute of each map (and ignore all maps that