BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: <bpf@vger.kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>, <kernel-team@fb.com>
Subject: [PATCH bpf-next v3 11/11] docs/bpf: add documentation for BTF_KIND_TAG
Date: Tue, 14 Sep 2021 15:31:03 -0700	[thread overview]
Message-ID: <20210914223103.249100-1-yhs@fb.com> (raw)
In-Reply-To: <20210914223004.244411-1-yhs@fb.com>

Add BTF_KIND_TAG documentation in btf.rst.

Acked-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Yonghong Song <yhs@fb.com>
---
 Documentation/bpf/btf.rst | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/Documentation/bpf/btf.rst b/Documentation/bpf/btf.rst
index 846354cd2d69..1bfe4072f5fc 100644
--- a/Documentation/bpf/btf.rst
+++ b/Documentation/bpf/btf.rst
@@ -85,6 +85,7 @@ sequentially and type id is assigned to each recognized type starting from id
     #define BTF_KIND_VAR            14      /* Variable     */
     #define BTF_KIND_DATASEC        15      /* Section      */
     #define BTF_KIND_FLOAT          16      /* Floating point       */
+    #define BTF_KIND_TAG            17      /* Tag          */
 
 Note that the type section encodes debug info, not just pure types.
 ``BTF_KIND_FUNC`` is not a type, and it represents a defined subprogram.
@@ -106,7 +107,7 @@ Each type contains the following common data::
          * "size" tells the size of the type it is describing.
          *
          * "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
-         * FUNC and FUNC_PROTO.
+         * FUNC, FUNC_PROTO and TAG.
          * "type" is a type_id referring to another type.
          */
         union {
@@ -465,6 +466,32 @@ map definition.
 
 No additional type data follow ``btf_type``.
 
+2.2.17 BTF_KIND_TAG
+~~~~~~~~~~~~~~~~~~~
+
+``struct btf_type`` encoding requirement:
+ * ``name_off``: offset to a non-empty string
+ * ``info.kind_flag``: 0
+ * ``info.kind``: BTF_KIND_TAG
+ * ``info.vlen``: 0
+ * ``type``: ``struct``, ``union``, ``func`` or ``var``
+
+``btf_type`` is followed by ``struct btf_tag``.::
+
+    struct btf_tag {
+        __u32   component_idx;
+    };
+
+The ``name_off`` encodes btf_tag attribute string.
+The ``type`` should be ``struct``, ``union``, ``func`` or ``var``.
+For ``var`` type, ``btf_tag.component_idx`` must be ``-1``.
+For the other three types, if the btf_tag attribute is
+applied to the ``struct``, ``union`` or ``func`` itself,
+``btf_tag.component_idx`` must be ``-1``. Otherwise,
+the attribute is applied to a ``struct``/``union`` member or
+a ``func`` argument, and ``btf_tag.component_idx`` should be a
+valid index (starting from 0) pointing to a member or an argument.
+
 3. BTF Kernel API
 *****************
 
-- 
2.30.2


  parent reply	other threads:[~2021-09-14 22:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-14 22:30 [PATCH bpf-next v3 00/11] bpf: add support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 01/11] btf: change BTF_KIND_* macros to enums Yonghong Song
2021-09-15  0:13   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 02/11] bpf: support for new btf kind BTF_KIND_TAG Yonghong Song
2021-09-15  0:15   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 03/11] libbpf: rename btf_{hash,equal}_int to btf_{hash,equal}_int_tag Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 04/11] libbpf: add support for BTF_KIND_TAG Yonghong Song
2021-09-15  0:18   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 05/11] bpftool: " Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 06/11] selftests/bpf: test libbpf API function btf__add_tag() Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 07/11] selftests/bpf: change NAME_NTH/IS_NAME_NTH for BTF_KIND_TAG format Yonghong Song
2021-09-14 22:30 ` [PATCH bpf-next v3 08/11] selftests/bpf: add BTF_KIND_TAG unit tests Yonghong Song
2021-09-15  0:19   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 09/11] selftests/bpf: test BTF_KIND_TAG for deduplication Yonghong Song
2021-09-15  0:21   ` Andrii Nakryiko
2021-09-14 22:30 ` [PATCH bpf-next v3 10/11] selftests/bpf: add a test with a bpf program with btf_tag attributes Yonghong Song
2021-09-14 22:31 ` Yonghong Song [this message]
2021-09-15  0:22 ` [PATCH bpf-next v3 00/11] bpf: add support for new btf kind BTF_KIND_TAG Andrii Nakryiko
2021-09-15  1:55 ` Alexei Starovoitov
2021-09-15  5:00   ` Yonghong Song
2021-09-15  2:00 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210914223103.249100-1-yhs@fb.com \
    --to=yhs@fb.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox