Skip to content

Commit ec3a25b

Browse files
yonghong-songKernel Patches Daemon
authored and
Kernel Patches Daemon
committed
docs/bpf: Update documentation for BTF_KIND_ENUM64 support
Add BTF_KIND_ENUM64 documentation in btf.rst. Also fixed a typo for section number for BTF_KIND_TYPE_TAG from 2.2.17 to 2.2.18. Signed-off-by: Yonghong Song <[email protected]>
1 parent b35dc5e commit ec3a25b

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

Documentation/bpf/btf.rst

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ sequentially and type id is assigned to each recognized type starting from id
7474
#define BTF_KIND_ARRAY 3 /* Array */
7575
#define BTF_KIND_STRUCT 4 /* Struct */
7676
#define BTF_KIND_UNION 5 /* Union */
77-
#define BTF_KIND_ENUM 6 /* Enumeration */
77+
#define BTF_KIND_ENUM 6 /* Enumeration for int/unsigned int values */
7878
#define BTF_KIND_FWD 7 /* Forward */
7979
#define BTF_KIND_TYPEDEF 8 /* Typedef */
8080
#define BTF_KIND_VOLATILE 9 /* Volatile */
@@ -87,6 +87,7 @@ sequentially and type id is assigned to each recognized type starting from id
8787
#define BTF_KIND_FLOAT 16 /* Floating point */
8888
#define BTF_KIND_DECL_TAG 17 /* Decl Tag */
8989
#define BTF_KIND_TYPE_TAG 18 /* Type Tag */
90+
#define BTF_KIND_ENUM64 19 /* Enumeration for long/unsigned long values */
9091

9192
Note that the type section encodes debug info, not just pure types.
9293
``BTF_KIND_FUNC`` is not a type, and it represents a defined subprogram.
@@ -101,10 +102,10 @@ Each type contains the following common data::
101102
* bits 24-28: kind (e.g. int, ptr, array...etc)
102103
* bits 29-30: unused
103104
* bit 31: kind_flag, currently used by
104-
* struct, union and fwd
105+
* struct, union, fwd, enum and enum64.
105106
*/
106107
__u32 info;
107-
/* "size" is used by INT, ENUM, STRUCT and UNION.
108+
/* "size" is used by INT, ENUM, STRUCT, UNION and ENUM64.
108109
* "size" tells the size of the type it is describing.
109110
*
110111
* "type" is used by PTR, TYPEDEF, VOLATILE, CONST, RESTRICT,
@@ -281,7 +282,7 @@ modes exist:
281282

282283
``struct btf_type`` encoding requirement:
283284
* ``name_off``: 0 or offset to a valid C identifier
284-
* ``info.kind_flag``: 0
285+
* ``info.kind_flag``: 0 for signed, 1 for unsigned
285286
* ``info.kind``: BTF_KIND_ENUM
286287
* ``info.vlen``: number of enum values
287288
* ``size``: 4
@@ -493,7 +494,7 @@ the attribute is applied to a ``struct``/``union`` member or
493494
a ``func`` argument, and ``btf_decl_tag.component_idx`` should be a
494495
valid index (starting from 0) pointing to a member or an argument.
495496

496-
2.2.17 BTF_KIND_TYPE_TAG
497+
2.2.18 BTF_KIND_TYPE_TAG
497498
~~~~~~~~~~~~~~~~~~~~~~~~
498499

499500
``struct btf_type`` encoding requirement:
@@ -516,6 +517,29 @@ type_tag, then zero or more const/volatile/restrict/typedef
516517
and finally the base type. The base type is one of
517518
int, ptr, array, struct, union, enum, func_proto and float types.
518519

520+
2.2.19 BTF_KIND_ENUM64
521+
~~~~~~~~~~~~~~~~~~~~~~
522+
523+
``struct btf_type`` encoding requirement:
524+
* ``name_off``: 0 or offset to a valid C identifier
525+
* ``info.kind_flag``: 0 for signed, 1 for unsigned
526+
* ``info.kind``: BTF_KIND_ENUM64
527+
* ``info.vlen``: number of enum values
528+
* ``size``: 8
529+
530+
``btf_type`` is followed by ``info.vlen`` number of ``struct btf_enum64``.::
531+
532+
struct btf_enum64 {
533+
__u32 name_off;
534+
__u32 hi32;
535+
__u32 lo32;
536+
};
537+
538+
The ``btf_enum64`` encoding:
539+
* ``name_off``: offset to a valid C identifier
540+
* ``hi32``: high 32-bit value for a 64-bit value
541+
* ``lo32``: lower 32-bit value for a 64-bit value
542+
519543
3. BTF Kernel API
520544
=================
521545

0 commit comments

Comments
 (0)