From nobody Wed Sep 17 01:46:33 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E52FDC10F1B for ; Sat, 24 Dec 2022 11:21:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230515AbiLXLVO (ORCPT ); Sat, 24 Dec 2022 06:21:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiLXLVL (ORCPT ); Sat, 24 Dec 2022 06:21:11 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 69490208; Sat, 24 Dec 2022 03:21:10 -0800 (PST) Received: from dggpeml500010.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NfM2l6RV7zJpMx; Sat, 24 Dec 2022 19:17:19 +0800 (CST) Received: from huawei.com (10.175.101.6) by dggpeml500010.china.huawei.com (7.185.36.155) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sat, 24 Dec 2022 19:21:07 +0800 From: Xin Liu To: , , , , , , , , , , CC: , , , , , , , Subject: [PATCH] libbpf: Added the description of some API functions Date: Sat, 24 Dec 2022 19:20:58 +0800 Message-ID: <20221224112058.12038-1-liuxin350@huawei.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpeml500010.china.huawei.com (7.185.36.155) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 --- 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); =20 +/** + * @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); =20 /* Hide internal to user */ @@ -174,6 +180,14 @@ struct bpf_object_open_opts { }; #define bpf_object_open_opts__last_field kernel_log_level =20 +/** + * @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); =20 /** @@ -204,9 +218,20 @@ bpf_object__open_mem(const void *obj_buf, size_t obj_b= uf_sz, const struct bpf_object_open_opts *opts); =20 /* 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); =20 -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); =20 /* pin_maps and unpin_maps can both be called with a NULL path, in which c= ase * they will use the pin_path attribute of each map (and ignore all maps t= hat --=20 2.33.0