bpf_def.h cleanups
cover bpf_def.h cleanups
This patch set contains two patches, first of which is a prerequisite for the second but can also be considered and applied independently.
Marat Khalili (2):
bpf: make bpf_def.h private
bpf: rename macros to match Linux kernel
app/test/test_bpf.c | 1685 +++++++++++++++--------------- app/test/test_bpf_validate.c | 268 ++--- lib/bpf/bpf_convert.c | 78 +- lib/bpf/bpf_def.h | 91 +- lib/bpf/bpf_dump.c | 45 +- lib/bpf/bpf_exec.c | 156 +-- lib/bpf/bpf_impl.h | 5 +- lib/bpf/bpf_jit_arm64.c | 218 ++-- lib/bpf/bpf_jit_x86.c | 312 +++--- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 24 +- lib/bpf/bpf_validate.c | 310 +++--- lib/bpf/bpf_validate.h | 4 +- lib/bpf/bpf_validate_debug.c | 6 +- lib/bpf/meson.build | 2 +- lib/bpf/rte_bpf.h | 35 +- lib/bpf/rte_bpf_validate_debug.h | 8 +- 17 files changed, 1623 insertions(+), 1626 deletions(-)
Signature · 1 line
2.43.0
RFC 1/2 bpf: make bpf_def.h private
Both bpf_def.h header file and the symbols it defined were not previously prefixed with rte_, creating an opportunity for name conflicts. Status of the file itself (private or public) was unclear.
Move public symbols after adding the necessary prefix (rte_ebpf_insn and RTE_EBPF_FUNC_MAX_ARGS) into the public header file rte_bpf.h, and make the rest private.
--- app/test/test_bpf.c | 79 ++++++++++++++++---------------- app/test/test_bpf_validate.c | 74 +++++++++++++++--------------- lib/bpf/bpf_convert.c | 38 +++++++-------- lib/bpf/bpf_def.h | 15 ------ lib/bpf/bpf_dump.c | 13 +++--- lib/bpf/bpf_exec.c | 8 ++-- lib/bpf/bpf_impl.h | 3 +- lib/bpf/bpf_jit_arm64.c | 4 +- lib/bpf/bpf_jit_x86.c | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 10 ++-- lib/bpf/bpf_validate.c | 44 +++++++++--------- lib/bpf/bpf_validate.h | 4 +- lib/bpf/bpf_validate_debug.c | 6 +-- lib/bpf/meson.build | 2 +- lib/bpf/rte_bpf.h | 33 +++++++++---- lib/bpf/rte_bpf_validate_debug.h | 8 ++-- 17 files changed, 174 insertions(+), 171 deletions(-)
app/test/test_bpf.c +40 -39
@@ -16,6 +16,7 @@#include <rte_byteorder.h> #include <rte_errno.h> +#include "bpf_def.h" #include "test.h" #if !defined(RTE_LIB_BPF )
@@ -52,7 +53,7 @@ test_bpf(void)* TEST_SUCCESS on success, error code on failure. */ static int -bpf_load_test (uint32_t nb_ins,const struct ebpf_insn *ins,int expected_errno) +bpf_load_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,int expected_errno) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -87,7 +88,7 @@ bpf_load_test(uint32_t nb_ins, const struct ebpf_insn *ins, int expected_errno)static int test_no_instructions (void ) { -static const struct ebpf_insn ins[] = {}; +static const struct rte_ebpf_insn ins[] = {};return bpf_load_test (RTE_DIM (ins), ins,EINVAL ); }
@@ -100,7 +101,7 @@ REGISTER_FAST_TEST(bpf_no_instructions_autotest, NOHUGE_OK, ASAN_OK, test_no_insstatic int test_exit_only (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_EXIT ), },
@@ -117,7 +118,7 @@ REGISTER_FAST_TEST(bpf_exit_only_autotest, NOHUGE_OK, ASAN_OK, test_exit_only);static int test_no_exit (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -136,7 +137,7 @@ REGISTER_FAST_TEST(bpf_no_exit_autotest, NOHUGE_OK, ASAN_OK, test_no_exit);static int test_minimal_working (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -158,7 +159,7 @@ REGISTER_FAST_TEST(bpf_minimal_working_autotest, NOHUGE_OK, ASAN_OK, test_minimastatic int test_add_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to one. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -186,7 +187,7 @@ REGISTER_FAST_TEST(bpf_add_one_autotest, NOHUGE_OK, ASAN_OK, test_add_one);static int test_subtract_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Subtract one from the program argument. */ .code = (EBPF_ALU64 |BPF_SUB |BPF_K ),
@@ -214,7 +215,7 @@ REGISTER_FAST_TEST(bpf_subtract_one_autotest, NOHUGE_OK, ASAN_OK, test_subtract_static int test_jump_over_invalid_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Jump over the next instruction for some r1. */ .code = (BPF_JMP |BPF_JEQ |BPF_K ),
@@ -251,7 +252,7 @@ REGISTER_FAST_TEST(bpf_jump_over_invalid_first_autotest, NOHUGE_OK, ASAN_OK,static int test_jump_over_invalid_non_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -401,7 +402,7 @@ dummy_prepare(void *arg) }/* store immediate test-cases */ -static const struct ebpf_insn test_store1_prog[] = { +static const struct rte_ebpf_insn test_store1_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_1 ,
@@ -464,7 +465,7 @@ test_store1_check(uint64_t rc, const void *arg) }/* store register test-cases */ -static const struct ebpf_insn test_store2_prog[] = { +static const struct rte_ebpf_insn test_store2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -507,7 +508,7 @@ static const struct ebpf_insn test_store2_prog[] = { };/* load test-cases */ -static const struct ebpf_insn test_load1_prog[] = { +static const struct rte_ebpf_insn test_load1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_B ),
@@ -584,7 +585,7 @@ test_load1_check(uint64_t rc, const void *arg) }/* load immediate test-cases */ -static const struct ebpf_insn test_ldimm1_prog[] = { +static const struct rte_ebpf_insn test_ldimm1_prog[] = { { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -672,7 +673,7 @@ test_ldimm1_check(uint64_t rc, const void *arg)/* alu mul test-cases */ -static const struct ebpf_insn test_mul1_prog[] = { +static const struct rte_ebpf_insn test_mul1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -784,7 +785,7 @@ test_mul1_check(uint64_t rc, const void *arg) }/* alu shift test-cases */ -static const struct ebpf_insn test_shift1_prog[] = { +static const struct rte_ebpf_insn test_shift1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -979,7 +980,7 @@ test_shift1_check(uint64_t rc, const void *arg) }/* jmp test-cases */ -static const struct ebpf_insn test_jump1_prog[] = { +static const struct rte_ebpf_insn test_jump1_prog[] = { [0 ] = { .code = (BPF_ALU |EBPF_MOV |BPF_K ),
@@ -1188,7 +1189,7 @@ test_jump1_check(uint64_t rc, const void *arg) }/* Jump test case - check ip4_dest in particular subnet */ -static const struct ebpf_insn test_jump2_prog[] = { +static const struct rte_ebpf_insn test_jump2_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1353,7 +1354,7 @@ test_jump2_check(uint64_t rc, const void *arg) }/* alu (add, sub, and, or, xor, neg) test-cases */ -static const struct ebpf_insn test_alu1_prog[] = { +static const struct rte_ebpf_insn test_alu1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -1535,7 +1536,7 @@ test_alu1_check(uint64_t rc, const void *arg) }/* endianness conversions (BE->LE/LE->BE) test-cases */ -static const struct ebpf_insn test_bele1_prog[] = { +static const struct rte_ebpf_insn test_bele1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_H ),
@@ -1701,7 +1702,7 @@ test_bele1_check(uint64_t rc, const void *arg) }/* atomic add test-cases */ -static const struct ebpf_insn test_xadd1_prog[] = { +static const struct rte_ebpf_insn test_xadd1_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1889,7 +1890,7 @@ test_xadd1_check(uint64_t rc, const void *arg) }/* alu div test-cases */ -static const struct ebpf_insn test_div1_prog[] = { +static const struct rte_ebpf_insn test_div1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2013,7 +2014,7 @@ test_div1_check(uint64_t rc, const void *arg) }/* call test-cases */ -static const struct ebpf_insn test_call1_prog[] = { +static const struct rte_ebpf_insn test_call1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2138,7 +2139,7 @@ static const struct rte_bpf_xsym test_call1_xsym[] = { }, }; -static const struct ebpf_insn test_call2_prog[] = { +static const struct rte_ebpf_insn test_call2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -2264,7 +2265,7 @@ static const struct rte_bpf_xsym test_call2_xsym[] = { }, }; -static const struct ebpf_insn test_call3_prog[] = { +static const struct rte_ebpf_insn test_call3_prog[] = { { .code = (BPF_JMP |EBPF_CALL ),
@@ -2377,7 +2378,7 @@ static const struct rte_bpf_xsym test_call3_xsym[] = { };/* Test for stack corruption in multiple function calls */ -static const struct ebpf_insn test_call4_prog[] = { +static const struct rte_ebpf_insn test_call4_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_10 ,
@@ -2550,7 +2551,7 @@ static const struct rte_bpf_xsym test_call4_xsym[] = { };/* string compare test case */ -static const struct ebpf_insn test_call5_prog[] = { +static const struct rte_ebpf_insn test_call5_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -2758,7 +2759,7 @@ static const struct rte_bpf_xsym test_call5_xsym[] = { };/* load mbuf (BPF_ABS/BPF_IND) test-cases */ -static const struct ebpf_insn test_ld_mbuf1_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3016,7 +3017,7 @@ test_ld_mbuf2_check(uint64_t rc, const void *arg) }/* same as test_ld_mbuf1, but now store intermediate results on the stack */ -static const struct ebpf_insn test_ld_mbuf3_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3165,7 +3166,7 @@ static const struct ebpf_insn test_ld_mbuf3_prog[] = { };/* divide INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_udiv_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3197,7 +3198,7 @@ test_int64min_udiv_uint64max_check(uint64_t rc, const void *arg) }/* modulo INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_umod_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3652,7 +3653,7 @@ REGISTER_FAST_TEST(bpf_load_null_autotest, NOHUGE_OK, ASAN_OK, test_bpf_load_nulstatic int test_bpf_exec_wrong_nb_prog_arg (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3694,7 +3695,7 @@ REGISTER_FAST_TEST(bpf_exec_wrong_nb_prog_arg_autotest, NOHUGE_OK, ASAN_OK,static int test_bpf_exec_wrong_flags (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3757,7 +3758,7 @@ typedef uint64_t (*text_xfunc_t)(uint64_t argument);static int call_from_bpf_test (text_xfunc_t xfunc) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_CALL ), .imm =0 ,/* xsym #0 */
@@ -4935,7 +4936,7 @@ static const struct xchg_arg xchg_input = {/* Run program against xchg_input and compare output value with expected. */ static int -run_xchg_test (uint32_t nb_ins,const struct ebpf_insn *ins,struct xchg_arg expected) +run_xchg_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,struct xchg_arg expected) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -5002,7 +5003,7 @@ run_xchg_test(uint32_t nb_ins, const struct ebpf_insn *ins, struct xchg_arg expestatic int test_xadd32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5082,7 +5083,7 @@ REGISTER_FAST_TEST(bpf_xadd32_autotest, NOHUGE_OK, ASAN_OK, test_xadd32);static int test_xadd64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5148,7 +5149,7 @@ REGISTER_FAST_TEST(bpf_xadd64_autotest, NOHUGE_OK, ASAN_OK, test_xadd64);static int test_xchg32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5243,7 +5244,7 @@ REGISTER_FAST_TEST(bpf_xchg32_autotest, NOHUGE_OK, ASAN_OK, test_xchg32);static int test_xchg64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5306,7 +5307,7 @@ REGISTER_FAST_TEST(bpf_xchg64_autotest, NOHUGE_OK, ASAN_OK, test_xchg64);static int test_atomic_imm (int32_t imm,bool is_valid) { -const struct ebpf_insn ins[] = { +const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
app/test/test_bpf_validate.c +37 -37
286 lines not on this page · raw message
lib/bpf/bpf_convert.c +19 -19
@@ -82,7 +82,7 @@/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ #define EBPF_ALU64_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -90,7 +90,7 @@ .imm = 0 })#define BPF_ALU32_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -100,7 +100,7 @@/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ #define BPF_ALU32_IMM (OP ,DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -110,7 +110,7 @@/* Short form of mov, dst_reg = src_reg */ #define BPF_MOV64_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -118,7 +118,7 @@ .imm = 0 })#define BPF_MOV32_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -128,7 +128,7 @@/* Short form of mov, dst_reg = imm32 */ #define BPF_MOV32_IMM (DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -138,7 +138,7 @@/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ #define BPF_MOV32_RAW (TYPE ,DST ,SRC ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_SRC(TYPE), \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -148,7 +148,7 @@/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ #define BPF_LD_ABS (SIZE ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -158,7 +158,7 @@/* Memory load, dst_reg = *(uint *) (src_reg + off16) */ #define BPF_LDX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -168,7 +168,7 @@/* Memory store, *(uint *) (dst_reg + off16) = src_reg */ #define BPF_STX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -178,7 +178,7 @@/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ #define BPF_JMP_IMM (OP ,DST ,IMM ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -188,7 +188,7 @@/* Raw code statement block */ #define BPF_RAW_INSN (CODE ,DST ,SRC ,OFF ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = CODE, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -198,7 +198,7 @@/* Program exit */ #define BPF_EXIT_INSN () \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | EBPF_EXIT, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -210,7 +210,7 @@* If and when DPDK BPF supports them. */ static bool convert_bpf_load (const struct bpf_insn *fp, - struct ebpf_insn **new_insnp __rte_unused) + struct rte_ebpf_insn **new_insnp __rte_unused) {switch (fp->k) {case SKF_AD_OFF +SKF_AD_PROTOCOL :
@@ -240,11 +240,11 @@ static bool convert_bpf_load(const struct bpf_insn *fp, }static int bpf_convert_filter (const struct bpf_insn *prog,size_t len, -struct ebpf_insn *new_prog,uint32_t *new_len) +struct rte_ebpf_insn *new_prog,uint32_t *new_len) {unsigned int pass =0 ;size_t new_flen =0 , target, i; -struct ebpf_insn *new_insn; +struct rte_ebpf_insn *new_insn;const struct bpf_insn *fp;int *addrs =NULL ;uint8_t bpf_src;
@@ -284,8 +284,8 @@ static int bpf_convert_filter(const struct bpf_insn *prog, size_t len, }for (i =0 ; i < len; fp++, i++) { -struct ebpf_insn tmp_insns[6 ] = { }; -struct ebpf_insn *insn = tmp_insns; +struct rte_ebpf_insn tmp_insns[6 ] = { }; +struct rte_ebpf_insn *insn = tmp_insns;if (addrs) addrs[i] = new_insn - new_prog;
@@ -526,7 +526,7 @@ struct rte_bpf_prm * rte_bpf_convert(const struct bpf_program *prog) {struct rte_bpf_prm *prm =NULL ; -struct ebpf_insn *ebpf =NULL ; +struct rte_ebpf_insn *ebpf =NULL ;uint32_t ebpf_len =0 ;int ret;
lib/bpf/bpf_def.h +0 -15
@@ -129,20 +129,5 @@ enum {*/ #define EBPF_PSEUDO_CALL EBPF_REG_1 -/* -* eBPF instruction format -*/ -struct ebpf_insn { -uint8_t code; -uint8_t dst_reg:4 ; -uint8_t src_reg:4 ; -int16_t off; -int32_t imm; -}; - -/* -* eBPF allows functions with R1-R5 as arguments. -*/ -#define EBPF_FUNC_MAX_ARGS (EBPF_REG_6 - EBPF_REG_1)#endif /* RTE_BPF_DEF_H_ */
lib/bpf/bpf_dump.c +7 -6
@@ -9,6 +9,7 @@#include <eal_export.h> #include "rte_bpf.h" +#include "bpf_def.h" #define BPF_OP_INDEX (x) (BPF_OP(x) >> 4)#define BPF_SIZE_INDEX (x) (BPF_SIZE(x) >> 3)
@@ -48,7 +49,7 @@ static const char *const jump_tbl[16] = { RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_insn_is_wide, 26.07)bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins) +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins) {return ins->code == (BPF_LD |BPF_IMM |EBPF_DW ); }
@@ -56,7 +57,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins)/* Format one (possibly wide) eBPF command as hexadecimal in objdump format. */ static int -format_hexadecimal (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_hexadecimal (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t flags) {const char *const b = (const char *)ins;
@@ -93,7 +94,7 @@ atomic_op(int32_t imm)/* Format one (possibly wide) eBPF command as assembler. */ static int -format_disassembly (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_disassembly (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {uint8_t cls =BPF_CLASS (ins->code);
@@ -221,7 +222,7 @@ format_disassembly(char *buffer, size_t bufsz, const struct ebpf_insn *ins, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_format, 26.07)int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {if ((flags &RTE_BPF_FORMAT_FLAG_HEXADECIMAL ) !=0 )
@@ -231,13 +232,13 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins, }RTE_EXPORT_SYMBOL (rte_bpf_dump) -void rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len) +void rte_bpf_dump(FILE *f, const struct rte_ebpf_insn *buf, uint32_t len) {uint32_t i;char buffer[256 ];for (i =0 ; i < len; ++i) { -const struct ebpf_insn *ins = buf + i; +const struct rte_ebpf_insn *ins = buf + i; format_disassembly(buffer, sizeof(buffer), ins, i, RTE_BPF_FORMAT_FLAG_DISASSEMBLY |
lib/bpf/bpf_exec.c +4 -4
@@ -108,7 +108,7 @@static inline void -bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -127,7 +127,7 @@ bpf_alu_be(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins) }static inline void -bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -147,7 +147,7 @@ bpf_alu_le(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins)static inline const void *bpf_ld_mbuf (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ], -const struct ebpf_insn *ins,uint32_t off,uint32_t len) +const struct rte_ebpf_insn *ins,uint32_t off,uint32_t len) {const struct rte_mbuf *mb;const void *p;
@@ -165,7 +165,7 @@ bpf_ld_mbuf(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM],static inline uint64_t bpf_exec (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ]) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;for (ins = bpf->prm.raw.ins; ; ins++) {switch (ins->code) {
lib/bpf/bpf_impl.h +2 -1
@@ -7,6 +7,7 @@#include <rte_bpf.h> #include <sys/mman.h> +#include "bpf_def.h" #define MAX_BPF_STACK_SIZE 0x200
@@ -22,7 +23,7 @@ struct __rte_bpf_load {struct rte_bpf_prm_ex prm;/* Conversion from cBPF. */ -struct ebpf_insn *ins; +struct rte_ebpf_insn *ins;/* Loading ELF and applying relocations. */ int elf_fd;/* ELF fd, must be negative (not zero) by default. */
lib/bpf/bpf_jit_arm64.c +2 -2
@@ -1126,7 +1126,7 @@ emit_branch(struct a64_jit_ctx *ctx, uint8_t op, uint32_t i, int16_t off)static void check_program_has_call (struct a64_jit_ctx *ctx,struct rte_bpf *bpf) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint8_t op;uint32_t i;
@@ -1150,7 +1150,7 @@ static int emit(struct a64_jit_ctx *ctx, struct rte_bpf *bpf) { uint8_t op, dst, src, tmp1, tmp2, tmp3; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint64_t u64;int16_t off;int32_t imm;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -1315,7 +1315,7 @@ static int emit(struct bpf_jit_state *st, const struct rte_bpf *bpf) { uint32_t i, dr, op, sr; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;/* reset state fields */ st->sz =0 ;
lib/bpf/bpf_load.c +1 -1
@@ -61,7 +61,7 @@ bpf_check_xsym(const struct rte_bpf_xsym *xsym)return -EINVAL ; }else if (xsym->type ==RTE_BPF_XTYPE_FUNC ) { -if (xsym->func.nb_args >EBPF_FUNC_MAX_ARGS ) +if (xsym->func.nb_args >RTE_EBPF_FUNC_MAX_ARGS )return -EINVAL ;/* check function arguments */
lib/bpf/bpf_load_elf.c +5 -5
@@ -58,7 +58,7 @@ bpf_find_xsym(const char *sn, enum rte_bpf_xtype type,* symbol *sn* */ static int -resolve_xsym (const char *sn,size_t ofs,struct ebpf_insn *ins,size_t ins_sz, +resolve_xsym (const char *sn,size_t ofs,struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {uint32_t idx, fidx;
@@ -169,7 +169,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx) sd =elf_getdata (sc,NULL );if (sd ==NULL || sd->d_size ==0 || - sd->d_size %sizeof (struct ebpf_insn ) !=0 ) { + sd->d_size %sizeof (struct rte_ebpf_insn ) !=0 ) { rc =elf_errno ();RTE_BPF_LOG_LINE (ERR ,"%s(%p, %s) error code: %d(%s)" , __func__, elf, section, rc,elf_errmsg (rc));
@@ -186,7 +186,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx)*/ static int process_reloc (Elf *elf,size_t sym_idx,Elf64_Rel *re,size_t re_sz, -struct ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) +struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {int32_t rc;uint32_t i, n;
@@ -235,7 +235,7 @@ process_reloc(Elf *elf, size_t sym_idx, Elf64_Rel *re, size_t re_sz,* and update bpf code. */ static int -elf_reloc_code (Elf *elf,struct ebpf_insn *ins,size_t ins_sz,size_t sidx, +elf_reloc_code (Elf *elf,struct rte_ebpf_insn *ins,size_t ins_sz,size_t sidx,const struct rte_bpf_prm_ex *prm) {Elf64_Rel *re;
@@ -355,7 +355,7 @@ __rte_bpf_load_elf_code(struct __rte_bpf_load *load) prm->origin =RTE_BPF_ORIGIN_RAW ; prm->raw.ins = sd->d_buf; - prm->raw.nb_ins = sd->d_size /sizeof (struct ebpf_insn ); + prm->raw.nb_ins = sd->d_size /sizeof (struct rte_ebpf_insn ); rc =elf_reloc_code (load->elf, sd->d_buf, sd->d_size, sidx, prm);if (rc <0 )
lib/bpf/bpf_validate.c +22 -22
166 lines not on this page · raw message
lib/bpf/bpf_validate.h +2 -2
@@ -32,12 +32,12 @@ __rte_bpf_validate_state_is_valid(const struct bpf_verifier *verifier);*/ int __rte_bpf_validate_can_access (const struct bpf_verifier *verifier, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/* Get possible truth values of the specified jump condition. */ int __rte_bpf_validate_may_jump (const struct bpf_verifier *verifier, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/* Format known information about the register for the user. */ int
lib/bpf/bpf_validate_debug.c +3 -3
@@ -319,7 +319,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug) RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_get_ins, 26.07)int rte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins) +const struct rte_ebpf_insn **ins,uint32_t *nb_ins) {if (debug ==NULL )return -EINVAL ;
@@ -378,7 +378,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_can_access, 26.07)int rte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64) +const struct rte_ebpf_insn *access,uint64_t off64) {if (debug ==NULL || access ==NULL )return -EINVAL ;
@@ -392,7 +392,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_may_jump, 26.07)int rte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64) +const struct rte_ebpf_insn *jump,uint64_t imm64) {if (debug ==NULL || jump ==NULL )return -EINVAL ;
lib/bpf/meson.build +1 -1
@@ -35,8 +35,8 @@ elif dpdk_conf.has('RTE_ARCH_ARM64') endif headers = files( - 'bpf_def.h', 'rte_bpf.h', + 'rte_bpf_ethdev.h', 'rte_bpf_validate_debug.h', )
lib/bpf/rte_bpf.h +24 -9
@@ -19,12 +19,27 @@#include <rte_common.h> #include <rte_mbuf.h> #include <rte_malloc.h> -#include <bpf_def.h> #ifdef __cplusplusextern "C" {#endif +/* +* eBPF instruction format +*/ +struct rte_ebpf_insn { +uint8_t code; +uint8_t dst_reg:4 ; +uint8_t src_reg:4 ; +int16_t off; +int32_t imm; +}; + +/* +* eBPF allows functions with up to 5 arguments. +*/ +#define RTE_EBPF_FUNC_MAX_ARGS 5 +#define RTE_BPF_EXEC_FLAG_JIT RTE_BIT64(0)/**< use JIT-compiled version */ /** Mask with all supported `RTE_BPF_EXEC_FLAG_*` flags set. */
@@ -96,7 +111,7 @@ struct rte_bpf_xsym {uint64_t (*val)(uint64_t ,uint64_t ,uint64_t ,uint64_t ,uint64_t );uint32_t nb_args; -struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS ]; +struct rte_bpf_arg args[RTE_EBPF_FUNC_MAX_ARGS ];/**< Function arguments descriptions. */ struct rte_bpf_arg ret;/**< function return value. */ } func;
@@ -135,7 +150,7 @@ struct rte_bpf_prm_ex {/** program origin parameters, member in use depends on origin */ union {struct { -const struct ebpf_insn *ins;/**< eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ } raw;struct {
@@ -157,7 +172,7 @@ struct rte_bpf_prm_ex {/**< array of external symbols that eBPF code is allowed to reference */ uint32_t nb_xsym;/**< number of elements in xsym */ -struct rte_bpf_arg prog_arg[EBPF_FUNC_MAX_ARGS ];/**< program arguments */ +struct rte_bpf_arg prog_arg[RTE_EBPF_FUNC_MAX_ARGS ];/**< program arguments */ uint32_t nb_prog_arg;/**< program argument count */ /* Validate debug instance. */
@@ -168,7 +183,7 @@ struct rte_bpf_prm_ex {* Input parameters for loading eBPF code, legacy version. */ struct rte_bpf_prm { -const struct ebpf_insn *ins;/**< array of eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< array of eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ const struct rte_bpf_xsym *xsym;/**< array of external symbols that eBPF code is allowed to reference */
@@ -217,7 +232,7 @@ struct rte_bpf_jit_ex {/* Tuple of eBPF program arguments. */ struct rte_bpf_prog_ctx { -union rte_bpf_func_arg arg[EBPF_FUNC_MAX_ARGS ]; +union rte_bpf_func_arg arg[RTE_EBPF_FUNC_MAX_ARGS ]; };struct rte_bpf ;
@@ -420,7 +435,7 @@ rte_bpf_get_jit_ex(const struct rte_bpf *bpf, struct rte_bpf_jit_ex *jit);*/ __rte_experimental bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins); +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins);/** * Print eBPF instruction into a buffer.
@@ -443,7 +458,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins);*/ __rte_experimental int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags);/**
@@ -457,7 +472,7 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins,* Number of BPF instructions to dump. */ void -rte_bpf_dump (FILE *f,const struct ebpf_insn *buf,uint32_t len); +rte_bpf_dump (FILE *f,const struct rte_ebpf_insn *buf,uint32_t len);struct bpf_program ;
lib/bpf/rte_bpf_validate_debug.h +4 -4
@@ -13,7 +13,7 @@* Can be used for debugging BPF validation problems as well as in tests. */ -#include <bpf_def.h> +#include <rte_bpf.h> #include <rte_compat.h> #include <stdbool.h>
@@ -181,7 +181,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug)__rte_experimental intrte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins); +const struct rte_ebpf_insn **ins,uint32_t *nb_ins);/** * Get last triggered breakpoint or catchpoint.
@@ -249,7 +249,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug__rte_experimental intrte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/** * Get possible truth values of the specified jump condition.
@@ -269,7 +269,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug,__rte_experimental intrte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/** * Format information about specified register for the user.
Signature · 1 line
2.43.0
RFC 2/2 bpf: rename macros to match Linux kernel
In reply to Marat KhaliliBPF opcode macro names had small deviations from the ones defined in Linux headers, confusing humans and AI tools during code generation and analysis, since both are mostly trained on the Linux spelling.
Rename them to match Linux counterparts.
--- app/test/test_bpf.c | 1606 +++++++++++++++++----------------- app/test/test_bpf_validate.c | 198 ++--- lib/bpf/bpf_convert.c | 40 +- lib/bpf/bpf_def.h | 76 +- lib/bpf/bpf_dump.c | 32 +- lib/bpf/bpf_exec.c | 152 ++-- lib/bpf/bpf_impl.h | 2 +- lib/bpf/bpf_jit_arm64.c | 214 ++--- lib/bpf/bpf_jit_x86.c | 310 +++---- lib/bpf/bpf_load_elf.c | 14 +- lib/bpf/bpf_validate.c | 266 +++--- lib/bpf/rte_bpf.h | 2 +- 12 files changed, 1453 insertions(+), 1459 deletions(-)
app/test/test_bpf.c +803 -803
@@ -103,7 +103,7 @@ test_exit_only(void) {static const struct rte_ebpf_insn ins[] = { { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,EINVAL );
@@ -121,9 +121,9 @@ test_no_exit(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, };return bpf_load_test (RTE_DIM (ins), ins,EINVAL );
@@ -140,12 +140,12 @@ test_minimal_working(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,0 );
@@ -162,18 +162,18 @@ test_add_one(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to one. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, {/* Add program argument to the return value. */ - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,0 );
@@ -190,18 +190,18 @@ test_subtract_one(void)static const struct rte_ebpf_insn ins[] = { {/* Subtract one from the program argument. */ - .code = (EBPF_ALU64 |BPF_SUB |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_SUB |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =1 , }, {/* Set return value to the result. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,0 );
@@ -219,25 +219,25 @@ test_jump_over_invalid_first(void) { /* Jump over the next instruction for some r1. */ .code = (BPF_JMP | BPF_JEQ | BPF_K), - .dst_reg = EBPF_REG_1, + .dst_reg = BPF_REG_1, .imm = 42, .off = 1, }, { /* Write 0xDEADBEEF to [r1 + INT16_MIN]. */ - .code = (BPF_ST | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, + .code = (BPF_ST | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, .off = INT16_MIN, .imm = 0xDEADBEEF, }, { /* Set return value to the program argument. */ - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .src_reg = EBPF_REG_1, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .src_reg = BPF_REG_1, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; return bpf_load_test(RTE_DIM(ins), ins, EINVAL);
@@ -255,32 +255,32 @@ test_jump_over_invalid_non_first(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, {/* Jump over the next instruction for some r1. */ .code = (BPF_JMP |BPF_JEQ |BPF_K ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .imm =42 , .off =1 , }, {/* Write 0xDEADBEEF to [r1 + INT16_MIN]. */ - .code = (BPF_ST |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ST |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , .off =INT16_MIN , .imm =0xDEADBEEF , }, {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,EINVAL );
@@ -405,36 +405,36 @@ dummy_prepare(void *arg)static const struct rte_ebpf_insn test_store1_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u8), .imm =TEST_FILL_1 , }, { .code = (BPF_ST |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u16), .imm =TEST_FILL_1 , }, { .code = (BPF_ST |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u32), .imm =TEST_FILL_1 , }, { - .code = (BPF_ST |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ST |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u64), .imm =TEST_FILL_1 , },/* return 1 */ { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -468,42 +468,42 @@ test_store1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_store2_prog[] = { { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =TEST_FILL_1 , }, { .code = (BPF_STX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u8), }, { .code = (BPF_STX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u16), }, { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_STX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u64), },/* return 1 */ { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -512,46 +512,46 @@ static const struct rte_ebpf_insn test_load1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_B), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u8), }, { .code = (BPF_LDX | BPF_MEM | BPF_H), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u16), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u64), }, /* return sum */ { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_4, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_4, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_2, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -588,40 +588,40 @@ test_load1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_ldimm1_prog[] = { { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (uint32_t )TEST_IMM_1 , }, { .imm =TEST_IMM_1 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_3 , .imm = (uint32_t )TEST_IMM_2 , }, { .imm =TEST_IMM_2 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_5 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_5 , .imm = (uint32_t )TEST_IMM_3 , }, { .imm =TEST_IMM_3 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_7 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_7 , .imm = (uint32_t )TEST_IMM_4 , }, { .imm =TEST_IMM_4 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_9 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_9 , .imm = (uint32_t )TEST_IMM_5 , }, {
@@ -629,27 +629,27 @@ static const struct rte_ebpf_insn test_ldimm1_prog[] = { },/* return sum */ { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_5, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_5, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_7, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_7, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_9, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_9, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -677,68 +677,68 @@ static const struct rte_ebpf_insn test_mul1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_MUL | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_MUL_1, }, { - .code = (EBPF_ALU64 | BPF_MUL | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_MUL | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_MUL_2, }, { .code = (BPF_ALU | BPF_MUL | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, { - .code = (EBPF_ALU64 | BPF_MUL | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_MUL | BPF_X), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_3, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -789,134 +789,134 @@ static const struct rte_ebpf_insn test_shift1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_LSH | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_SHIFT_1, }, { - .code = (EBPF_ALU64 | EBPF_ARSH | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ARSH | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_SHIFT_2, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_4, + .dst_reg = BPF_REG_4, .imm = TEST_SHIFT64_MASK, }, { - .code = (EBPF_ALU64 | BPF_LSH | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_4, + .code = (BPF_ALU64 | BPF_LSH | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_4, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_4, + .dst_reg = BPF_REG_4, .imm = TEST_SHIFT32_MASK, }, { .code = (BPF_ALU | BPF_RSH | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_4, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_4, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[2].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[3].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_SHIFT64_MASK, }, { - .code = (EBPF_ALU64 | EBPF_ARSH | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_ARSH | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_2, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_SHIFT32_MASK, }, { .code = (BPF_ALU | BPF_LSH | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[4].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[5].u64), }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -983,88 +983,88 @@ test_shift1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_jump1_prog[] = { [0 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0 , }, [1 ] = { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[0].u32), }, [2 ] = { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_1 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[0].u64), }, [3 ] = { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_4 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_4 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[1].u32), }, [4 ] = { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_5 , - .src_reg =EBPF_REG_1 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_5 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[1].u64), }, [5 ] = { .code = (BPF_JMP |BPF_JEQ |BPF_K ), - .dst_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_2 , .imm =TEST_JCC_1 , .off =8 , }, [6 ] = { - .code = (BPF_JMP |EBPF_JSLE |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JSLE |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =TEST_JCC_2 , .off =9 , }, [7 ] = { .code = (BPF_JMP |BPF_JGT |BPF_K ), - .dst_reg =EBPF_REG_4 , + .dst_reg =BPF_REG_4 , .imm =TEST_JCC_3 , .off =10 , }, [8 ] = { .code = (BPF_JMP |BPF_JSET |BPF_K ), - .dst_reg =EBPF_REG_5 , + .dst_reg =BPF_REG_5 , .imm =TEST_JCC_4 , .off =11 , }, [9 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JNE |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_3 , .off =12 , }, [10 ] = { - .code = (BPF_JMP |EBPF_JSGT |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_4 , + .code = (BPF_JMP |BPF_JSGT |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_4 , .off =13 , }, [11 ] = { - .code = (BPF_JMP |EBPF_JLE |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_5 , + .code = (BPF_JMP |BPF_JLE |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_5 , .off =14 , }, [12 ] = { .code = (BPF_JMP |BPF_JSET |BPF_X ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_5 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_5 , .off =15 , }, [13 ] = { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, [14 ] = { - .code = (EBPF_ALU64 |BPF_OR |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_OR |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0x1 , }, [15 ] = {
@@ -1072,8 +1072,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -10, }, [16] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x2, }, [17] = {
@@ -1081,8 +1081,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -11, }, [18] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x4, }, [19] = {
@@ -1090,8 +1090,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -12, }, [20] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x8, }, [21] = {
@@ -1099,8 +1099,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -13, }, [22] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x10, }, [23] = {
@@ -1108,8 +1108,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -14, }, [24] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x20, }, [25] = {
@@ -1117,8 +1117,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -15, }, [26] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x40, }, [27] = {
@@ -1126,8 +1126,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -16, }, [28] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x80, }, [29] = {
@@ -1192,98 +1192,98 @@ test_jump1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_jump2_prog[] = { [0 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =0xe , }, [1 ] = { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_1 , .off =12 , }, [2 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JNE |BPF_K ), + .dst_reg =BPF_REG_3 , .off =2 , .imm =0x81 , }, [3 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =0x12 , }, [4 ] = { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_1 , .off =16 , }, [5 ] = { - .code = (EBPF_ALU64 |BPF_AND |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU64 |BPF_AND |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =0xffff , }, [6 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JNE |BPF_K ), + .dst_reg =BPF_REG_3 , .off =9 , .imm =0x8 , }, [7 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , }, [8 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0 , }, [9 ] = { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_1 , .off =16 , }, [10 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =TEST_NETMASK , }, [11 ] = { - .code = (BPF_ALU |EBPF_END |EBPF_TO_BE ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_END |BPF_TO_BE ), + .dst_reg =BPF_REG_3 , .imm =sizeof (uint32_t ) *CHAR_BIT , }, [12 ] = { .code = (BPF_ALU |BPF_AND |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , }, [13 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =TEST_SUBNET , }, [14 ] = { - .code = (BPF_ALU |EBPF_END |EBPF_TO_BE ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_END |BPF_TO_BE ), + .dst_reg =BPF_REG_3 , .imm =sizeof (uint32_t ) *CHAR_BIT , }, [15 ] = { .code = (BPF_JMP |BPF_JEQ |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , .off =1 , }, [16 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =-1 , }, [17 ] = { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -1358,137 +1358,137 @@ static const struct rte_ebpf_insn test_alu1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_5, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_5, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_FILL_1, }, { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_FILL_1, }, { .code = (BPF_ALU | BPF_XOR | BPF_K), - .dst_reg = EBPF_REG_4, + .dst_reg = BPF_REG_4, .imm = TEST_FILL_1, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_K), - .dst_reg = EBPF_REG_5, + .code = (BPF_ALU64 | BPF_ADD | BPF_K), + .dst_reg = BPF_REG_5, .imm = TEST_FILL_1, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_5, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_5, .off = offsetof(struct dummy_vect8, out[3].u64), }, { .code = (BPF_ALU | BPF_OR | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_3, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_XOR | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_4, + .code = (BPF_ALU64 | BPF_XOR | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_4, }, { .code = (BPF_ALU | BPF_SUB | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_5, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_5, }, { - .code = (EBPF_ALU64 | BPF_AND | BPF_X), - .dst_reg = EBPF_REG_5, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_AND | BPF_X), + .dst_reg = BPF_REG_5, + .src_reg = BPF_REG_2, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[4].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[5].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[6].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_5, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_5, .off = offsetof(struct dummy_vect8, out[7].u64), }, /* return (-r2 + (-r3)) */ { .code = (BPF_ALU | BPF_NEG), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, }, { - .code = (EBPF_ALU64 | BPF_NEG), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_NEG), + .dst_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_2, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -1540,114 +1540,114 @@ static const struct rte_ebpf_insn test_bele1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_H), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u16), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u64), }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_BE), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU | BPF_END | BPF_TO_BE), + .dst_reg = BPF_REG_2, .imm = sizeof(uint16_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_BE), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU | BPF_END | BPF_TO_BE), + .dst_reg = BPF_REG_3, .imm = sizeof(uint32_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_BE), - .dst_reg = EBPF_REG_4, + .code = (BPF_ALU | BPF_END | BPF_TO_BE), + .dst_reg = BPF_REG_4, .imm = sizeof(uint64_t) * CHAR_BIT, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_H), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u16), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u64), }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_LE), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU | BPF_END | BPF_TO_LE), + .dst_reg = BPF_REG_2, .imm = sizeof(uint16_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_LE), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU | BPF_END | BPF_TO_LE), + .dst_reg = BPF_REG_3, .imm = sizeof(uint32_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_LE), - .dst_reg = EBPF_REG_4, + .code = (BPF_ALU | BPF_END | BPF_TO_LE), + .dst_reg = BPF_REG_4, .imm = sizeof(uint64_t) * CHAR_BIT, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[3].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[4].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[5].u64), }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -1705,132 +1705,132 @@ test_bele1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_xadd1_prog[] = { { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =-1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_4 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_4 , .imm =TEST_FILL_1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_4 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_4 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_4 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_4 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_5 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_5 , .imm =TEST_MUL_1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_5 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_5 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_5 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_5 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_6 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_6 , .imm =TEST_MUL_2 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_6 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_6 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_6 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_6 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_7 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_7 , .imm =TEST_JCC_2 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_7 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_7 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_7 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_7 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_8 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_8 , .imm =TEST_JCC_3 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_8 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_8 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_8 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_8 , .off = offsetof(struct dummy_offset , u64), },/* return 1 */ { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -1894,90 +1894,90 @@ static const struct rte_ebpf_insn test_div1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_DIV | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_MUL_1, }, { - .code = (EBPF_ALU64 | BPF_MOD | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_MOD | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_MUL_2, }, { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_2, .imm = 1, }, { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_3, .imm = 1, }, { .code = (BPF_ALU | BPF_MOD | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, { - .code = (EBPF_ALU64 | BPF_DIV | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_DIV | BPF_X), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_3, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, /* check that we can handle division by zero gracefully. */ { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[3].u32), }, { .code = (BPF_ALU | BPF_DIV | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -2018,71 +2018,71 @@ static const struct rte_ebpf_insn test_call1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u64), }, { .code = (BPF_STX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_2, .off = -4, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_3, .off = -16, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_10, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_10, }, { - .code = (EBPF_ALU64 | BPF_SUB | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_SUB | BPF_K), + .dst_reg = BPF_REG_2, .imm = 4, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_10, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_10, }, { - .code = (EBPF_ALU64 | BPF_SUB | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_SUB | BPF_K), + .dst_reg = BPF_REG_3, .imm = 16, }, { - .code = (BPF_JMP | EBPF_CALL), + .code = (BPF_JMP | BPF_CALL), .imm = 0, }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_10, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_10, .off = -4, }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_10, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_10, .off = -16 }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_2, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -2142,74 +2142,74 @@ static const struct rte_bpf_xsym test_call1_xsym[] = {static const struct rte_ebpf_insn test_call2_prog[] = { { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_1 , .imm = -(int32_t )sizeof (struct dummy_offset ), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_10 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =-2 * (int32_t )sizeof (struct dummy_offset ), }, { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u64)), }, { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u32)), }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(2 *sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u16)), }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(2 *sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u8)), }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2268,51 +2268,51 @@ static const struct rte_bpf_xsym test_call2_xsym[] = {static const struct rte_ebpf_insn test_call3_prog[] = { { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_0 , + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u8), }, { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_0 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u16), }, { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_4 , - .src_reg =EBPF_REG_0 , + .dst_reg =BPF_REG_4 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_0 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u64), },/* return sum */ { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_4 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_4 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_3 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_3 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_2 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2381,82 +2381,82 @@ static const struct rte_bpf_xsym test_call3_xsym[] = {static const struct rte_ebpf_insn test_call4_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-4 , .imm =1 , }, { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-3 , .imm =2 , }, { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-2 , .imm =3 , }, { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-1 , .imm =4 , }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =4 , }, { - .code = (EBPF_ALU64 |BPF_SUB |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_SUB |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , }, { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off =-4 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_10 , .off =-3 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_10 , .off =-2 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_4 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_4 , + .src_reg =BPF_REG_10 , .off =-1 , }, { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =1 , }, { - .code = (EBPF_ALU64 |BPF_XOR |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_XOR |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =TEST_MEMFROB , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2554,146 +2554,146 @@ static const struct rte_bpf_xsym test_call4_xsym[] = {static const struct rte_ebpf_insn test_call5_prog[] = { [0 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =STRING_GEEK , }, [1 ] = { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_1 , .off =-8 , }, [2 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_6 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_6 , .imm =0 , }, [3 ] = { .code = (BPF_STX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_6 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_6 , .off =-4 , }, [4 ] = { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_6 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_6 , .off =-12 , }, [5 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =STRING_WEEK , }, [6 ] = { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_1 , .off =-16 , }, [7 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, [8 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =-8 , }, [9 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_1 , }, [10 ] = { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, [11 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_0 , }, [12 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =-1 , }, [13 ] = { - .code = (EBPF_ALU64 |BPF_LSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_LSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [14 ] = { - .code = (EBPF_ALU64 |BPF_RSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_RSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [15 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_JMP |BPF_JNE |BPF_K ), + .dst_reg =BPF_REG_1 , .off =11 , .imm =0 , }, [16 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, [17 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =-8 , }, [18 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_10 , }, [19 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =-16 , }, [20 ] = { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, [21 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_0 , }, [22 ] = { - .code = (EBPF_ALU64 |BPF_LSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_LSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [23 ] = { - .code = (EBPF_ALU64 |BPF_RSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_RSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [24 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, [25 ] = { .code = (BPF_JMP |BPF_JEQ |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_6 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_6 , .off =1 , }, [26 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0 , }, [27 ] = { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2763,9 +2763,9 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_6, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_6, + .src_reg = BPF_REG_1, },/* load IPv4 version and IHL */ {
@@ -2774,50 +2774,50 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = { },/* check IP version */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_0, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = 0xf0, }, { .code = (BPF_JMP | BPF_JEQ | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = IPVERSION << 4, .off = 2, }, /* invalid IP version, return 0 */ { - .code = (EBPF_ALU64 | BPF_XOR | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_XOR | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, /* load 3-rd byte of IP data */ { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = RTE_IPV4_HDR_IHL_MASK, }, { .code = (BPF_ALU | BPF_LSH | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = 2, }, { .code = (BPF_LD | BPF_IND | BPF_B), - .src_reg = EBPF_REG_0, + .src_reg = BPF_REG_0, .imm = 3, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_7, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_7, + .src_reg = BPF_REG_0, }, /* load IPv4 src addr */ {
@@ -2825,9 +2825,9 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = { .imm = offsetof(struct rte_ipv4_hdr, src_addr), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_7, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_7, + .src_reg = BPF_REG_0, },/* load IPv4 total length */ {
@@ -2835,38 +2835,38 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = { .imm = offsetof(struct rte_ipv4_hdr, total_length), }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_8, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_8, + .src_reg = BPF_REG_0, }, /* load last 4 bytes of IP data */ { .code = (BPF_LD | BPF_IND | BPF_W), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, .imm = -(int32_t)sizeof(uint32_t), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_7, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_7, + .src_reg = BPF_REG_0, }, /* load 2 bytes from the middle of IP data */ { - .code = (EBPF_ALU64 | BPF_RSH | BPF_K), - .dst_reg = EBPF_REG_8, + .code = (BPF_ALU64 | BPF_RSH | BPF_K), + .dst_reg = BPF_REG_8, .imm = 1, }, { .code = (BPF_LD | BPF_IND | BPF_H), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_7, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_7, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3021,9 +3021,9 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_6, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_6, + .src_reg = BPF_REG_1, },/* load IPv4 version and IHL */ {
@@ -3032,50 +3032,50 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = { },/* check IP version */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_0, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = 0xf0, }, { .code = (BPF_JMP | BPF_JEQ | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = IPVERSION << 4, .off = 2, }, /* invalid IP version, return 0 */ { - .code = (EBPF_ALU64 | BPF_XOR | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_XOR | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, /* load 3-rd byte of IP data */ { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = RTE_IPV4_HDR_IHL_MASK, }, { .code = (BPF_ALU | BPF_LSH | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = 2, }, { .code = (BPF_LD | BPF_IND | BPF_B), - .src_reg = EBPF_REG_0, + .src_reg = BPF_REG_0, .imm = 3, }, { .code = (BPF_STX | BPF_MEM | BPF_B), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_0, + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_0, .off = (int16_t)(offsetof(struct dummy_offset, u8) - sizeof(struct dummy_offset)), },
@@ -3086,8 +3086,8 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = { }, { .code = (BPF_STX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_0, + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_0, .off = (int16_t )(offsetof(struct dummy_offset , u32) - sizeof(struct dummy_offset)), },
@@ -3097,71 +3097,71 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = { .imm = offsetof(struct rte_ipv4_hdr, total_length), }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_8, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_8, + .src_reg = BPF_REG_0, }, /* load last 4 bytes of IP data */ { .code = (BPF_LD | BPF_IND | BPF_W), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, .imm = -(int32_t)sizeof(uint32_t), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_0, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_0, .off = (int16_t)(offsetof(struct dummy_offset, u64) - sizeof(struct dummy_offset)), }, /* load 2 bytes from the middle of IP data */ { - .code = (EBPF_ALU64 | BPF_RSH | BPF_K), - .dst_reg = EBPF_REG_8, + .code = (BPF_ALU64 | BPF_RSH | BPF_K), + .dst_reg = BPF_REG_8, .imm = 1, }, { .code = (BPF_LD | BPF_IND | BPF_H), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_10, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_10, .off = (int16_t)(offsetof(struct dummy_offset, u64) - sizeof(struct dummy_offset)), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_10, + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_10, .off = (int16_t)(offsetof(struct dummy_offset, u32) - sizeof(struct dummy_offset)), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, }, { .code = (BPF_LDX | BPF_MEM | BPF_B), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_10, + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_10, .off = (int16_t)(offsetof(struct dummy_offset, u8) - sizeof(struct dummy_offset)), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3169,8 +3169,8 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (int32_t )INT64_MIN , }, {
@@ -3178,13 +3178,13 @@ static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = { },/* Divide r0 by immediate -1 */ { - .code = (EBPF_ALU64 | BPF_DIV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_DIV | BPF_K), + .dst_reg = BPF_REG_0, .imm = -1, },/* Exit for correctness otherwise */ { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3201,8 +3201,8 @@ test_int64min_udiv_uint64max_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (int32_t )INT64_MIN , }, {
@@ -3210,13 +3210,13 @@ static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = { },/* Modulo r0 by immediate -1 */ { - .code = (EBPF_ALU64 | BPF_MOD | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOD | BPF_K), + .dst_reg = BPF_REG_0, .imm = -1, },/* Exit for correctness otherwise */ { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3654,8 +3654,8 @@ static inttest_bpf_exec_wrong_nb_prog_arg (void) {static const struct rte_ebpf_insn ins[] = { - { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, - { .code = (BPF_JMP |EBPF_EXIT ), } + { .code = (BPF_ALU64 |BPF_MOV |BPF_K ), .dst_reg =BPF_REG_0 , .imm =0 }, + { .code = (BPF_JMP |BPF_EXIT ), } };static const struct rte_bpf_prm_ex prm = { .sz =sizeof (struct rte_bpf_prm_ex ),
@@ -3696,8 +3696,8 @@ static inttest_bpf_exec_wrong_flags (void) {static const struct rte_ebpf_insn ins[] = { - { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, - { .code = (BPF_JMP |EBPF_EXIT ), } + { .code = (BPF_ALU64 |BPF_MOV |BPF_K ), .dst_reg =BPF_REG_0 , .imm =0 }, + { .code = (BPF_JMP |BPF_EXIT ), } };static const struct rte_bpf_prm_ex prm = { .sz =sizeof (struct rte_bpf_prm_ex ),
@@ -3760,11 +3760,11 @@ call_from_bpf_test(text_xfunc_t xfunc) {static const struct rte_ebpf_insn ins[] = { { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 ,/* xsym #0 */ }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };const struct rte_bpf_xsym xsym[] = {
@@ -5006,8 +5006,8 @@ test_xadd32(void)static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5016,8 +5016,8 @@ test_xadd32(void) }, {/* Set r2 to XADD operand. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_2, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_2, .imm = (uint32_t)XADD_OPERAND, }, {
@@ -5026,27 +5026,27 @@ test_xadd32(void) }, { /* Atomically add r2 to value0, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { /* Negate r2. */ - .code = (EBPF_ALU64 | BPF_NEG | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_NEG | BPF_K), + .dst_reg = BPF_REG_2, }, { /* Atomically add r2 to value1, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct xchg_arg expected = {
@@ -5086,8 +5086,8 @@ test_xadd64(void)static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5096,8 +5096,8 @@ test_xadd64(void) }, {/* Set r2 to XADD operand. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_2, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_2, .imm = (uint32_t)XADD_OPERAND, }, {
@@ -5106,27 +5106,27 @@ test_xadd64(void) }, { /* Atomically add r2 to value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { /* Negate r2. */ - .code = (EBPF_ALU64 | BPF_NEG | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_NEG | BPF_K), + .dst_reg = BPF_REG_2, }, { /* Atomically add r2 to value1. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct xchg_arg expected = {
@@ -5152,8 +5152,8 @@ test_xchg32(void)static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_2 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5162,32 +5162,32 @@ test_xchg32(void) }, { /* Atomically exchange r2 with value0, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value1, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value0, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Set upper half of r0 to return value. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_0, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_0, .imm = 0, }, {
@@ -5199,12 +5199,12 @@ test_xchg32(void)* Add r2 (should have upper half cleared by this time) * to r0 to use as a return value. */ - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };struct xchg_arg expected = {
@@ -5247,8 +5247,8 @@ test_xchg64(void)static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_2 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5257,36 +5257,36 @@ test_xchg64(void) }, { /* Atomically exchange r2 with value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value1. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Copy r2 to r0 to use as a return value. */ - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct xchg_arg expected = {
@@ -5310,8 +5310,8 @@ test_atomic_imm(int32_t imm, bool is_valid) const struct rte_ebpf_insn ins[] = { { /* Set r2 to return value. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_2, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_2, .imm = (uint32_t)XCHG_RETURN_VALUE, }, {
@@ -5320,20 +5320,20 @@ test_atomic_imm(int32_t imm, bool is_valid) }, { /* Atomically exchange r2 with value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), .imm = imm, }, { /* Copy r2 to r0 to use as a return value. */ - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct rte_bpf_prm prm = {
@@ -5360,8 +5360,8 @@ static int test_atomic_imms(void) { RTE_TEST_ASSERT_SUCCESS(test_atomic_imm(INT32_MIN, false), "expect success"); - for (int32_t imm = BPF_ATOMIC_ADD - 1; imm <= BPF_ATOMIC_XCHG + 1; ++imm) { - const bool is_valid = imm == BPF_ATOMIC_ADD || imm == BPF_ATOMIC_XCHG; + for (int32_t imm = BPF_ADD - 1; imm <= BPF_XCHG + 1; ++imm) { + const bool is_valid = imm == BPF_ADD || imm == BPF_XCHG; RTE_TEST_ASSERT_SUCCESS(test_atomic_imm(imm, is_valid), "expect success"); } RTE_TEST_ASSERT_SUCCESS(test_atomic_imm(INT32_MAX, false), "expect success");
app/test/test_bpf_validate.c +99 -99
13 lines not on this page · raw message
lib/bpf/bpf_def.h +35 -41
76 lines not on this page · raw message
lib/bpf/bpf_exec.c +76 -76
152 lines not on this page · raw message
lib/bpf/bpf_jit_arm64.c +107 -107
214 lines not on this page · raw message
lib/bpf/bpf_jit_x86.c +155 -155
310 lines not on this page · raw message
lib/bpf/bpf_validate.c +133 -133
266 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
v2 cover bpf_def.h cleanups
In reply to Marat KhaliliThis patch set contains two patches, first of which is a prerequisite for the second but can also be considered and applied independently.
The goal of this patch set is to solve the following problems:
* bpf_def.h fails to follow the DPDK naming rules for public headers in the name of the file or names of the symbols it defines;
* its symbols may clash with those in Linux headers but at the same time are not interchangable with them;
* small differences in opcode names relative to Linux are confusing.
v2:
* Following the AI suggestion renamed RTE_EBPF_FUNC_MAX_ARGS to RTE_BPF_FUNC_MAX_ARGS.
* Rebased on fresh main hoping to overcome the unrelated CI issues.
* Catiously re-posting without the RFC label.
Marat Khalili (2):
bpf: make bpf_def.h private
bpf: rename macros to match Linux kernel
app/test/test_bpf.c | 1685 +++++++++++++++--------------- app/test/test_bpf_validate.c | 268 ++--- lib/bpf/bpf_convert.c | 78 +- lib/bpf/bpf_def.h | 91 +- lib/bpf/bpf_dump.c | 45 +- lib/bpf/bpf_exec.c | 156 +-- lib/bpf/bpf_impl.h | 5 +- lib/bpf/bpf_jit_arm64.c | 218 ++-- lib/bpf/bpf_jit_x86.c | 312 +++--- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 24 +- lib/bpf/bpf_validate.c | 310 +++--- lib/bpf/bpf_validate.h | 6 +- lib/bpf/bpf_validate_debug.c | 6 +- lib/bpf/meson.build | 1 - lib/bpf/rte_bpf.h | 35 +- lib/bpf/rte_bpf_validate_debug.h | 8 +- 17 files changed, 1623 insertions(+), 1627 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 bpf: make bpf_def.h private
Both bpf_def.h header file and the symbols it defined were not previously prefixed with rte_, creating an opportunity for name conflicts. Status of the file itself (private or public) was unclear.
Move public symbols after adding the necessary prefix (rte_ebpf_insn and RTE_BPF_FUNC_MAX_ARGS) into the public header file rte_bpf.h, and make the rest private.
--- app/test/test_bpf.c | 79 ++++++++++++++++---------------- app/test/test_bpf_validate.c | 74 +++++++++++++++--------------- lib/bpf/bpf_convert.c | 38 +++++++-------- lib/bpf/bpf_def.h | 15 ------ lib/bpf/bpf_dump.c | 13 +++--- lib/bpf/bpf_exec.c | 8 ++-- lib/bpf/bpf_impl.h | 3 +- lib/bpf/bpf_jit_arm64.c | 4 +- lib/bpf/bpf_jit_x86.c | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 10 ++-- lib/bpf/bpf_validate.c | 44 +++++++++--------- lib/bpf/bpf_validate.h | 6 +-- lib/bpf/bpf_validate_debug.c | 6 +-- lib/bpf/meson.build | 1 - lib/bpf/rte_bpf.h | 33 +++++++++---- lib/bpf/rte_bpf_validate_debug.h | 8 ++-- 17 files changed, 174 insertions(+), 172 deletions(-)
app/test/test_bpf.c +40 -39
@@ -16,6 +16,7 @@#include <rte_byteorder.h> #include <rte_errno.h> +#include "bpf_def.h" #include "test.h" #if !defined(RTE_LIB_BPF )
@@ -52,7 +53,7 @@ test_bpf(void)* TEST_SUCCESS on success, error code on failure. */ static int -bpf_load_test (uint32_t nb_ins,const struct ebpf_insn *ins,int expected_errno) +bpf_load_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,int expected_errno) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -87,7 +88,7 @@ bpf_load_test(uint32_t nb_ins, const struct ebpf_insn *ins, int expected_errno)static int test_no_instructions (void ) { -static const struct ebpf_insn ins[] = {}; +static const struct rte_ebpf_insn ins[] = {};return bpf_load_test (RTE_DIM (ins), ins,EINVAL ); }
@@ -100,7 +101,7 @@ REGISTER_FAST_TEST(bpf_no_instructions_autotest, NOHUGE_OK, ASAN_OK, test_no_insstatic int test_exit_only (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_EXIT ), },
@@ -117,7 +118,7 @@ REGISTER_FAST_TEST(bpf_exit_only_autotest, NOHUGE_OK, ASAN_OK, test_exit_only);static int test_no_exit (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -136,7 +137,7 @@ REGISTER_FAST_TEST(bpf_no_exit_autotest, NOHUGE_OK, ASAN_OK, test_no_exit);static int test_minimal_working (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -158,7 +159,7 @@ REGISTER_FAST_TEST(bpf_minimal_working_autotest, NOHUGE_OK, ASAN_OK, test_minimastatic int test_add_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to one. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -186,7 +187,7 @@ REGISTER_FAST_TEST(bpf_add_one_autotest, NOHUGE_OK, ASAN_OK, test_add_one);static int test_subtract_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Subtract one from the program argument. */ .code = (EBPF_ALU64 |BPF_SUB |BPF_K ),
@@ -214,7 +215,7 @@ REGISTER_FAST_TEST(bpf_subtract_one_autotest, NOHUGE_OK, ASAN_OK, test_subtract_static int test_jump_over_invalid_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Jump over the next instruction for some r1. */ .code = (BPF_JMP |BPF_JEQ |BPF_K ),
@@ -251,7 +252,7 @@ REGISTER_FAST_TEST(bpf_jump_over_invalid_first_autotest, NOHUGE_OK, ASAN_OK,static int test_jump_over_invalid_non_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -401,7 +402,7 @@ dummy_prepare(void *arg) }/* store immediate test-cases */ -static const struct ebpf_insn test_store1_prog[] = { +static const struct rte_ebpf_insn test_store1_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_1 ,
@@ -464,7 +465,7 @@ test_store1_check(uint64_t rc, const void *arg) }/* store register test-cases */ -static const struct ebpf_insn test_store2_prog[] = { +static const struct rte_ebpf_insn test_store2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -507,7 +508,7 @@ static const struct ebpf_insn test_store2_prog[] = { };/* load test-cases */ -static const struct ebpf_insn test_load1_prog[] = { +static const struct rte_ebpf_insn test_load1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_B ),
@@ -584,7 +585,7 @@ test_load1_check(uint64_t rc, const void *arg) }/* load immediate test-cases */ -static const struct ebpf_insn test_ldimm1_prog[] = { +static const struct rte_ebpf_insn test_ldimm1_prog[] = { { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -672,7 +673,7 @@ test_ldimm1_check(uint64_t rc, const void *arg)/* alu mul test-cases */ -static const struct ebpf_insn test_mul1_prog[] = { +static const struct rte_ebpf_insn test_mul1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -784,7 +785,7 @@ test_mul1_check(uint64_t rc, const void *arg) }/* alu shift test-cases */ -static const struct ebpf_insn test_shift1_prog[] = { +static const struct rte_ebpf_insn test_shift1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -979,7 +980,7 @@ test_shift1_check(uint64_t rc, const void *arg) }/* jmp test-cases */ -static const struct ebpf_insn test_jump1_prog[] = { +static const struct rte_ebpf_insn test_jump1_prog[] = { [0 ] = { .code = (BPF_ALU |EBPF_MOV |BPF_K ),
@@ -1188,7 +1189,7 @@ test_jump1_check(uint64_t rc, const void *arg) }/* Jump test case - check ip4_dest in particular subnet */ -static const struct ebpf_insn test_jump2_prog[] = { +static const struct rte_ebpf_insn test_jump2_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1353,7 +1354,7 @@ test_jump2_check(uint64_t rc, const void *arg) }/* alu (add, sub, and, or, xor, neg) test-cases */ -static const struct ebpf_insn test_alu1_prog[] = { +static const struct rte_ebpf_insn test_alu1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -1535,7 +1536,7 @@ test_alu1_check(uint64_t rc, const void *arg) }/* endianness conversions (BE->LE/LE->BE) test-cases */ -static const struct ebpf_insn test_bele1_prog[] = { +static const struct rte_ebpf_insn test_bele1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_H ),
@@ -1701,7 +1702,7 @@ test_bele1_check(uint64_t rc, const void *arg) }/* atomic add test-cases */ -static const struct ebpf_insn test_xadd1_prog[] = { +static const struct rte_ebpf_insn test_xadd1_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1889,7 +1890,7 @@ test_xadd1_check(uint64_t rc, const void *arg) }/* alu div test-cases */ -static const struct ebpf_insn test_div1_prog[] = { +static const struct rte_ebpf_insn test_div1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2013,7 +2014,7 @@ test_div1_check(uint64_t rc, const void *arg) }/* call test-cases */ -static const struct ebpf_insn test_call1_prog[] = { +static const struct rte_ebpf_insn test_call1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2138,7 +2139,7 @@ static const struct rte_bpf_xsym test_call1_xsym[] = { }, }; -static const struct ebpf_insn test_call2_prog[] = { +static const struct rte_ebpf_insn test_call2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -2264,7 +2265,7 @@ static const struct rte_bpf_xsym test_call2_xsym[] = { }, }; -static const struct ebpf_insn test_call3_prog[] = { +static const struct rte_ebpf_insn test_call3_prog[] = { { .code = (BPF_JMP |EBPF_CALL ),
@@ -2377,7 +2378,7 @@ static const struct rte_bpf_xsym test_call3_xsym[] = { };/* Test for stack corruption in multiple function calls */ -static const struct ebpf_insn test_call4_prog[] = { +static const struct rte_ebpf_insn test_call4_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_10 ,
@@ -2550,7 +2551,7 @@ static const struct rte_bpf_xsym test_call4_xsym[] = { };/* string compare test case */ -static const struct ebpf_insn test_call5_prog[] = { +static const struct rte_ebpf_insn test_call5_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -2758,7 +2759,7 @@ static const struct rte_bpf_xsym test_call5_xsym[] = { };/* load mbuf (BPF_ABS/BPF_IND) test-cases */ -static const struct ebpf_insn test_ld_mbuf1_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3016,7 +3017,7 @@ test_ld_mbuf2_check(uint64_t rc, const void *arg) }/* same as test_ld_mbuf1, but now store intermediate results on the stack */ -static const struct ebpf_insn test_ld_mbuf3_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3165,7 +3166,7 @@ static const struct ebpf_insn test_ld_mbuf3_prog[] = { };/* divide INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_udiv_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3197,7 +3198,7 @@ test_int64min_udiv_uint64max_check(uint64_t rc, const void *arg) }/* modulo INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_umod_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3652,7 +3653,7 @@ REGISTER_FAST_TEST(bpf_load_null_autotest, NOHUGE_OK, ASAN_OK, test_bpf_load_nulstatic int test_bpf_exec_wrong_nb_prog_arg (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3694,7 +3695,7 @@ REGISTER_FAST_TEST(bpf_exec_wrong_nb_prog_arg_autotest, NOHUGE_OK, ASAN_OK,static int test_bpf_exec_wrong_flags (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3757,7 +3758,7 @@ typedef uint64_t (*text_xfunc_t)(uint64_t argument);static int call_from_bpf_test (text_xfunc_t xfunc) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_CALL ), .imm =0 ,/* xsym #0 */
@@ -4935,7 +4936,7 @@ static const struct xchg_arg xchg_input = {/* Run program against xchg_input and compare output value with expected. */ static int -run_xchg_test (uint32_t nb_ins,const struct ebpf_insn *ins,struct xchg_arg expected) +run_xchg_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,struct xchg_arg expected) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -5002,7 +5003,7 @@ run_xchg_test(uint32_t nb_ins, const struct ebpf_insn *ins, struct xchg_arg expestatic int test_xadd32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5082,7 +5083,7 @@ REGISTER_FAST_TEST(bpf_xadd32_autotest, NOHUGE_OK, ASAN_OK, test_xadd32);static int test_xadd64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5148,7 +5149,7 @@ REGISTER_FAST_TEST(bpf_xadd64_autotest, NOHUGE_OK, ASAN_OK, test_xadd64);static int test_xchg32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5243,7 +5244,7 @@ REGISTER_FAST_TEST(bpf_xchg32_autotest, NOHUGE_OK, ASAN_OK, test_xchg32);static int test_xchg64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5306,7 +5307,7 @@ REGISTER_FAST_TEST(bpf_xchg64_autotest, NOHUGE_OK, ASAN_OK, test_xchg64);static int test_atomic_imm (int32_t imm,bool is_valid) { -const struct ebpf_insn ins[] = { +const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
app/test/test_bpf_validate.c +37 -37
286 lines not on this page · raw message
lib/bpf/bpf_convert.c +19 -19
@@ -82,7 +82,7 @@/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ #define EBPF_ALU64_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -90,7 +90,7 @@ .imm = 0 })#define BPF_ALU32_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -100,7 +100,7 @@/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ #define BPF_ALU32_IMM (OP ,DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -110,7 +110,7 @@/* Short form of mov, dst_reg = src_reg */ #define BPF_MOV64_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -118,7 +118,7 @@ .imm = 0 })#define BPF_MOV32_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -128,7 +128,7 @@/* Short form of mov, dst_reg = imm32 */ #define BPF_MOV32_IMM (DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -138,7 +138,7 @@/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ #define BPF_MOV32_RAW (TYPE ,DST ,SRC ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_SRC(TYPE), \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -148,7 +148,7 @@/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ #define BPF_LD_ABS (SIZE ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -158,7 +158,7 @@/* Memory load, dst_reg = *(uint *) (src_reg + off16) */ #define BPF_LDX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -168,7 +168,7 @@/* Memory store, *(uint *) (dst_reg + off16) = src_reg */ #define BPF_STX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -178,7 +178,7 @@/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ #define BPF_JMP_IMM (OP ,DST ,IMM ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -188,7 +188,7 @@/* Raw code statement block */ #define BPF_RAW_INSN (CODE ,DST ,SRC ,OFF ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = CODE, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -198,7 +198,7 @@/* Program exit */ #define BPF_EXIT_INSN () \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | EBPF_EXIT, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -210,7 +210,7 @@* If and when DPDK BPF supports them. */ static bool convert_bpf_load (const struct bpf_insn *fp, - struct ebpf_insn **new_insnp __rte_unused) + struct rte_ebpf_insn **new_insnp __rte_unused) {switch (fp->k) {case SKF_AD_OFF +SKF_AD_PROTOCOL :
@@ -240,11 +240,11 @@ static bool convert_bpf_load(const struct bpf_insn *fp, }static int bpf_convert_filter (const struct bpf_insn *prog,size_t len, -struct ebpf_insn *new_prog,uint32_t *new_len) +struct rte_ebpf_insn *new_prog,uint32_t *new_len) {unsigned int pass =0 ;size_t new_flen =0 , target, i; -struct ebpf_insn *new_insn; +struct rte_ebpf_insn *new_insn;const struct bpf_insn *fp;int *addrs =NULL ;uint8_t bpf_src;
@@ -284,8 +284,8 @@ static int bpf_convert_filter(const struct bpf_insn *prog, size_t len, }for (i =0 ; i < len; fp++, i++) { -struct ebpf_insn tmp_insns[6 ] = { }; -struct ebpf_insn *insn = tmp_insns; +struct rte_ebpf_insn tmp_insns[6 ] = { }; +struct rte_ebpf_insn *insn = tmp_insns;if (addrs) addrs[i] = new_insn - new_prog;
@@ -526,7 +526,7 @@ struct rte_bpf_prm * rte_bpf_convert(const struct bpf_program *prog) {struct rte_bpf_prm *prm =NULL ; -struct ebpf_insn *ebpf =NULL ; +struct rte_ebpf_insn *ebpf =NULL ;uint32_t ebpf_len =0 ;int ret;
lib/bpf/bpf_def.h +0 -15
@@ -129,20 +129,5 @@ enum {*/ #define EBPF_PSEUDO_CALL EBPF_REG_1 -/* -* eBPF instruction format -*/ -struct ebpf_insn { -uint8_t code; -uint8_t dst_reg:4 ; -uint8_t src_reg:4 ; -int16_t off; -int32_t imm; -}; - -/* -* eBPF allows functions with R1-R5 as arguments. -*/ -#define EBPF_FUNC_MAX_ARGS (EBPF_REG_6 - EBPF_REG_1)#endif /* RTE_BPF_DEF_H_ */
lib/bpf/bpf_dump.c +7 -6
@@ -9,6 +9,7 @@#include <eal_export.h> #include "rte_bpf.h" +#include "bpf_def.h" #define BPF_OP_INDEX (x) (BPF_OP(x) >> 4)#define BPF_SIZE_INDEX (x) (BPF_SIZE(x) >> 3)
@@ -48,7 +49,7 @@ static const char *const jump_tbl[16] = { RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_insn_is_wide, 26.07)bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins) +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins) {return ins->code == (BPF_LD |BPF_IMM |EBPF_DW ); }
@@ -56,7 +57,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins)/* Format one (possibly wide) eBPF command as hexadecimal in objdump format. */ static int -format_hexadecimal (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_hexadecimal (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t flags) {const char *const b = (const char *)ins;
@@ -93,7 +94,7 @@ atomic_op(int32_t imm)/* Format one (possibly wide) eBPF command as assembler. */ static int -format_disassembly (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_disassembly (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {uint8_t cls =BPF_CLASS (ins->code);
@@ -221,7 +222,7 @@ format_disassembly(char *buffer, size_t bufsz, const struct ebpf_insn *ins, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_format, 26.07)int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {if ((flags &RTE_BPF_FORMAT_FLAG_HEXADECIMAL ) !=0 )
@@ -231,13 +232,13 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins, }RTE_EXPORT_SYMBOL (rte_bpf_dump) -void rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len) +void rte_bpf_dump(FILE *f, const struct rte_ebpf_insn *buf, uint32_t len) {uint32_t i;char buffer[256 ];for (i =0 ; i < len; ++i) { -const struct ebpf_insn *ins = buf + i; +const struct rte_ebpf_insn *ins = buf + i; format_disassembly(buffer, sizeof(buffer), ins, i, RTE_BPF_FORMAT_FLAG_DISASSEMBLY |
lib/bpf/bpf_exec.c +4 -4
@@ -108,7 +108,7 @@static inline void -bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -127,7 +127,7 @@ bpf_alu_be(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins) }static inline void -bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -147,7 +147,7 @@ bpf_alu_le(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins)static inline const void *bpf_ld_mbuf (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ], -const struct ebpf_insn *ins,uint32_t off,uint32_t len) +const struct rte_ebpf_insn *ins,uint32_t off,uint32_t len) {const struct rte_mbuf *mb;const void *p;
@@ -165,7 +165,7 @@ bpf_ld_mbuf(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM],static inline uint64_t bpf_exec (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ]) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;for (ins = bpf->prm.raw.ins; ; ins++) {switch (ins->code) {
lib/bpf/bpf_impl.h +2 -1
@@ -7,6 +7,7 @@#include <rte_bpf.h> #include <sys/mman.h> +#include "bpf_def.h" #define MAX_BPF_STACK_SIZE 0x200
@@ -22,7 +23,7 @@ struct __rte_bpf_load {struct rte_bpf_prm_ex prm;/* Conversion from cBPF. */ -struct ebpf_insn *ins; +struct rte_ebpf_insn *ins;/* Loading ELF and applying relocations. */ int elf_fd;/* ELF fd, must be negative (not zero) by default. */
lib/bpf/bpf_jit_arm64.c +2 -2
@@ -1126,7 +1126,7 @@ emit_branch(struct a64_jit_ctx *ctx, uint8_t op, uint32_t i, int16_t off)static void check_program_has_call (struct a64_jit_ctx *ctx,struct rte_bpf *bpf) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint8_t op;uint32_t i;
@@ -1150,7 +1150,7 @@ static int emit(struct a64_jit_ctx *ctx, struct rte_bpf *bpf) { uint8_t op, dst, src, tmp1, tmp2, tmp3; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint64_t u64;int16_t off;int32_t imm;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -1315,7 +1315,7 @@ static int emit(struct bpf_jit_state *st, const struct rte_bpf *bpf) { uint32_t i, dr, op, sr; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;/* reset state fields */ st->sz =0 ;
lib/bpf/bpf_load.c +1 -1
@@ -61,7 +61,7 @@ bpf_check_xsym(const struct rte_bpf_xsym *xsym)return -EINVAL ; }else if (xsym->type ==RTE_BPF_XTYPE_FUNC ) { -if (xsym->func.nb_args >EBPF_FUNC_MAX_ARGS ) +if (xsym->func.nb_args >RTE_BPF_FUNC_MAX_ARGS )return -EINVAL ;/* check function arguments */
lib/bpf/bpf_load_elf.c +5 -5
@@ -58,7 +58,7 @@ bpf_find_xsym(const char *sn, enum rte_bpf_xtype type,* symbol *sn* */ static int -resolve_xsym (const char *sn,size_t ofs,struct ebpf_insn *ins,size_t ins_sz, +resolve_xsym (const char *sn,size_t ofs,struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {uint32_t idx, fidx;
@@ -169,7 +169,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx) sd =elf_getdata (sc,NULL );if (sd ==NULL || sd->d_size ==0 || - sd->d_size %sizeof (struct ebpf_insn ) !=0 ) { + sd->d_size %sizeof (struct rte_ebpf_insn ) !=0 ) { rc =elf_errno ();RTE_BPF_LOG_LINE (ERR ,"%s(%p, %s) error code: %d(%s)" , __func__, elf, section, rc,elf_errmsg (rc));
@@ -186,7 +186,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx)*/ static int process_reloc (Elf *elf,size_t sym_idx,Elf64_Rel *re,size_t re_sz, -struct ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) +struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {int32_t rc;uint32_t i, n;
@@ -235,7 +235,7 @@ process_reloc(Elf *elf, size_t sym_idx, Elf64_Rel *re, size_t re_sz,* and update bpf code. */ static int -elf_reloc_code (Elf *elf,struct ebpf_insn *ins,size_t ins_sz,size_t sidx, +elf_reloc_code (Elf *elf,struct rte_ebpf_insn *ins,size_t ins_sz,size_t sidx,const struct rte_bpf_prm_ex *prm) {Elf64_Rel *re;
@@ -355,7 +355,7 @@ __rte_bpf_load_elf_code(struct __rte_bpf_load *load) prm->origin =RTE_BPF_ORIGIN_RAW ; prm->raw.ins = sd->d_buf; - prm->raw.nb_ins = sd->d_size /sizeof (struct ebpf_insn ); + prm->raw.nb_ins = sd->d_size /sizeof (struct rte_ebpf_insn ); rc =elf_reloc_code (load->elf, sd->d_buf, sd->d_size, sidx, prm);if (rc <0 )
lib/bpf/bpf_validate.c +22 -22
166 lines not on this page · raw message
lib/bpf/bpf_validate.h +3 -3
@@ -11,7 +11,7 @@* Internal-use headers for eBPF validation observability. */ -#include <bpf_def.h> +#include <rte_bpf.h> #ifdef __cplusplusextern "C" {
@@ -32,12 +32,12 @@ __rte_bpf_validate_state_is_valid(const struct bpf_verifier *verifier);*/ int __rte_bpf_validate_can_access (const struct bpf_verifier *verifier, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/* Get possible truth values of the specified jump condition. */ int __rte_bpf_validate_may_jump (const struct bpf_verifier *verifier, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/* Format known information about the register for the user. */ int
lib/bpf/bpf_validate_debug.c +3 -3
@@ -319,7 +319,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug) RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_get_ins, 26.07)int rte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins) +const struct rte_ebpf_insn **ins,uint32_t *nb_ins) {if (debug ==NULL )return -EINVAL ;
@@ -378,7 +378,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_can_access, 26.07)int rte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64) +const struct rte_ebpf_insn *access,uint64_t off64) {if (debug ==NULL || access ==NULL )return -EINVAL ;
@@ -392,7 +392,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_may_jump, 26.07)int rte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64) +const struct rte_ebpf_insn *jump,uint64_t imm64) {if (debug ==NULL || jump ==NULL )return -EINVAL ;
lib/bpf/meson.build +0 -1
@@ -35,7 +35,6 @@ elif dpdk_conf.has('RTE_ARCH_ARM64') endif headers = files( - 'bpf_def.h', 'rte_bpf.h', 'rte_bpf_ethdev.h', 'rte_bpf_validate_debug.h',
lib/bpf/rte_bpf.h +24 -9
@@ -19,12 +19,27 @@#include <rte_common.h> #include <rte_mbuf.h> #include <rte_malloc.h> -#include <bpf_def.h> #ifdef __cplusplusextern "C" {#endif +/* +* eBPF instruction format +*/ +struct rte_ebpf_insn { +uint8_t code; +uint8_t dst_reg:4 ; +uint8_t src_reg:4 ; +int16_t off; +int32_t imm; +}; + +/* +* eBPF allows functions with up to 5 arguments. +*/ +#define RTE_BPF_FUNC_MAX_ARGS 5 +#define RTE_BPF_EXEC_FLAG_JIT RTE_BIT64(0)/**< use JIT-compiled version */ /** Mask with all supported `RTE_BPF_EXEC_FLAG_*` flags set. */
@@ -96,7 +111,7 @@ struct rte_bpf_xsym {uint64_t (*val)(uint64_t ,uint64_t ,uint64_t ,uint64_t ,uint64_t );uint32_t nb_args; -struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS ]; +struct rte_bpf_arg args[RTE_BPF_FUNC_MAX_ARGS ];/**< Function arguments descriptions. */ struct rte_bpf_arg ret;/**< function return value. */ } func;
@@ -135,7 +150,7 @@ struct rte_bpf_prm_ex {/** program origin parameters, member in use depends on origin */ union {struct { -const struct ebpf_insn *ins;/**< eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ } raw;struct {
@@ -157,7 +172,7 @@ struct rte_bpf_prm_ex {/**< array of external symbols that eBPF code is allowed to reference */ uint32_t nb_xsym;/**< number of elements in xsym */ -struct rte_bpf_arg prog_arg[EBPF_FUNC_MAX_ARGS ];/**< program arguments */ +struct rte_bpf_arg prog_arg[RTE_BPF_FUNC_MAX_ARGS ];/**< program arguments */ uint32_t nb_prog_arg;/**< program argument count */ /* Validate debug instance. */
@@ -168,7 +183,7 @@ struct rte_bpf_prm_ex {* Input parameters for loading eBPF code, legacy version. */ struct rte_bpf_prm { -const struct ebpf_insn *ins;/**< array of eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< array of eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ const struct rte_bpf_xsym *xsym;/**< array of external symbols that eBPF code is allowed to reference */
@@ -217,7 +232,7 @@ struct rte_bpf_jit_ex {/* Tuple of eBPF program arguments. */ struct rte_bpf_prog_ctx { -union rte_bpf_func_arg arg[EBPF_FUNC_MAX_ARGS ]; +union rte_bpf_func_arg arg[RTE_BPF_FUNC_MAX_ARGS ]; };struct rte_bpf ;
@@ -420,7 +435,7 @@ rte_bpf_get_jit_ex(const struct rte_bpf *bpf, struct rte_bpf_jit_ex *jit);*/ __rte_experimental bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins); +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins);/** * Print eBPF instruction into a buffer.
@@ -443,7 +458,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins);*/ __rte_experimental int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags);/**
@@ -457,7 +472,7 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins,* Number of BPF instructions to dump. */ void -rte_bpf_dump (FILE *f,const struct ebpf_insn *buf,uint32_t len); +rte_bpf_dump (FILE *f,const struct rte_ebpf_insn *buf,uint32_t len);struct bpf_program ;
lib/bpf/rte_bpf_validate_debug.h +4 -4
@@ -13,7 +13,7 @@* Can be used for debugging BPF validation problems as well as in tests. */ -#include <bpf_def.h> +#include <rte_bpf.h> #include <rte_compat.h> #include <stdbool.h>
@@ -181,7 +181,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug)__rte_experimental intrte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins); +const struct rte_ebpf_insn **ins,uint32_t *nb_ins);/** * Get last triggered breakpoint or catchpoint.
@@ -249,7 +249,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug__rte_experimental intrte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/** * Get possible truth values of the specified jump condition.
@@ -269,7 +269,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug,__rte_experimental intrte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/** * Format information about specified register for the user.
Signature · 1 line
2.43.0
RE: [PATCH v2 1/2] bpf: make bpf_def.h private
Quoted 6 lines
Both
bpf_def.hheader file and the symbols it defined were not previously prefixed withrte_, creating an opportunity for name conflicts. Status of the file itself (private or public) was unclear.
Quoted 6 lines
Move public symbols after adding the necessary prefix (
rte_ebpf_insnandRTE_BPF_FUNC_MAX_ARGS) into the public header filerte_bpf.h, and make the rest private.Signed-off-by Marat Khalili <[email protected]>---
As it is a public API change - It is probably worth a line or two in official RN for 26.11
Quoted 2 lines
--
2.43.0
PATCH v2 2/2 bpf: rename macros to match Linux kernel
In reply to Marat KhaliliBPF opcode macro names had small deviations from the ones defined in Linux headers, confusing humans and AI tools during code generation and analysis, since both are mostly trained on the Linux spelling.
Rename them to match Linux counterparts.
--- app/test/test_bpf.c | 1606 +++++++++++++++++----------------- app/test/test_bpf_validate.c | 198 ++--- lib/bpf/bpf_convert.c | 40 +- lib/bpf/bpf_def.h | 76 +- lib/bpf/bpf_dump.c | 32 +- lib/bpf/bpf_exec.c | 152 ++-- lib/bpf/bpf_impl.h | 2 +- lib/bpf/bpf_jit_arm64.c | 214 ++--- lib/bpf/bpf_jit_x86.c | 310 +++---- lib/bpf/bpf_load_elf.c | 14 +- lib/bpf/bpf_validate.c | 266 +++--- lib/bpf/rte_bpf.h | 2 +- 12 files changed, 1453 insertions(+), 1459 deletions(-)
app/test/test_bpf.c +803 -803
@@ -103,7 +103,7 @@ test_exit_only(void) {static const struct rte_ebpf_insn ins[] = { { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,EINVAL );
@@ -121,9 +121,9 @@ test_no_exit(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, };return bpf_load_test (RTE_DIM (ins), ins,EINVAL );
@@ -140,12 +140,12 @@ test_minimal_working(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,0 );
@@ -162,18 +162,18 @@ test_add_one(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to one. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, {/* Add program argument to the return value. */ - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,0 );
@@ -190,18 +190,18 @@ test_subtract_one(void)static const struct rte_ebpf_insn ins[] = { {/* Subtract one from the program argument. */ - .code = (EBPF_ALU64 |BPF_SUB |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_SUB |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =1 , }, {/* Set return value to the result. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,0 );
@@ -219,25 +219,25 @@ test_jump_over_invalid_first(void) { /* Jump over the next instruction for some r1. */ .code = (BPF_JMP | BPF_JEQ | BPF_K), - .dst_reg = EBPF_REG_1, + .dst_reg = BPF_REG_1, .imm = 42, .off = 1, }, { /* Write 0xDEADBEEF to [r1 + INT16_MIN]. */ - .code = (BPF_ST | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, + .code = (BPF_ST | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, .off = INT16_MIN, .imm = 0xDEADBEEF, }, { /* Set return value to the program argument. */ - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .src_reg = EBPF_REG_1, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .src_reg = BPF_REG_1, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; return bpf_load_test(RTE_DIM(ins), ins, EINVAL);
@@ -255,32 +255,32 @@ test_jump_over_invalid_non_first(void)static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, {/* Jump over the next instruction for some r1. */ .code = (BPF_JMP |BPF_JEQ |BPF_K ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .imm =42 , .off =1 , }, {/* Write 0xDEADBEEF to [r1 + INT16_MIN]. */ - .code = (BPF_ST |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ST |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , .off =INT16_MIN , .imm =0xDEADBEEF , }, {/* Set return value to the program argument. */ - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .src_reg =EBPF_REG_1 , - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .src_reg =BPF_REG_1 , + .dst_reg =BPF_REG_0 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };return bpf_load_test (RTE_DIM (ins), ins,EINVAL );
@@ -405,36 +405,36 @@ dummy_prepare(void *arg)static const struct rte_ebpf_insn test_store1_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u8), .imm =TEST_FILL_1 , }, { .code = (BPF_ST |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u16), .imm =TEST_FILL_1 , }, { .code = (BPF_ST |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u32), .imm =TEST_FILL_1 , }, { - .code = (BPF_ST |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ST |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , .off = offsetof(struct dummy_offset , u64), .imm =TEST_FILL_1 , },/* return 1 */ { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -468,42 +468,42 @@ test_store1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_store2_prog[] = { { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =TEST_FILL_1 , }, { .code = (BPF_STX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u8), }, { .code = (BPF_STX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u16), }, { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_STX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u64), },/* return 1 */ { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -512,46 +512,46 @@ static const struct rte_ebpf_insn test_load1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_B), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u8), }, { .code = (BPF_LDX | BPF_MEM | BPF_H), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u16), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u64), }, /* return sum */ { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_4, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_4, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_2, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -588,40 +588,40 @@ test_load1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_ldimm1_prog[] = { { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (uint32_t )TEST_IMM_1 , }, { .imm =TEST_IMM_1 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_3 , .imm = (uint32_t )TEST_IMM_2 , }, { .imm =TEST_IMM_2 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_5 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_5 , .imm = (uint32_t )TEST_IMM_3 , }, { .imm =TEST_IMM_3 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_7 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_7 , .imm = (uint32_t )TEST_IMM_4 , }, { .imm =TEST_IMM_4 >>32 , }, { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_9 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_9 , .imm = (uint32_t )TEST_IMM_5 , }, {
@@ -629,27 +629,27 @@ static const struct rte_ebpf_insn test_ldimm1_prog[] = { },/* return sum */ { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_5, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_5, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_7, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_7, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_9, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_9, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -677,68 +677,68 @@ static const struct rte_ebpf_insn test_mul1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_MUL | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_MUL_1, }, { - .code = (EBPF_ALU64 | BPF_MUL | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_MUL | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_MUL_2, }, { .code = (BPF_ALU | BPF_MUL | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, { - .code = (EBPF_ALU64 | BPF_MUL | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_MUL | BPF_X), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_3, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -789,134 +789,134 @@ static const struct rte_ebpf_insn test_shift1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_LSH | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_SHIFT_1, }, { - .code = (EBPF_ALU64 | EBPF_ARSH | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ARSH | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_SHIFT_2, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_4, + .dst_reg = BPF_REG_4, .imm = TEST_SHIFT64_MASK, }, { - .code = (EBPF_ALU64 | BPF_LSH | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_4, + .code = (BPF_ALU64 | BPF_LSH | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_4, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_4, + .dst_reg = BPF_REG_4, .imm = TEST_SHIFT32_MASK, }, { .code = (BPF_ALU | BPF_RSH | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_4, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_4, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[2].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[3].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_SHIFT64_MASK, }, { - .code = (EBPF_ALU64 | EBPF_ARSH | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_ARSH | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_2, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_SHIFT32_MASK, }, { .code = (BPF_ALU | BPF_LSH | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[4].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[5].u64), }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -983,88 +983,88 @@ test_shift1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_jump1_prog[] = { [0 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0 , }, [1 ] = { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[0].u32), }, [2 ] = { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_1 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[0].u64), }, [3 ] = { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_4 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_4 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[1].u32), }, [4 ] = { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_5 , - .src_reg =EBPF_REG_1 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_5 , + .src_reg =BPF_REG_1 , .off = offsetof(struct dummy_vect8, in[1].u64), }, [5 ] = { .code = (BPF_JMP |BPF_JEQ |BPF_K ), - .dst_reg =EBPF_REG_2 , + .dst_reg =BPF_REG_2 , .imm =TEST_JCC_1 , .off =8 , }, [6 ] = { - .code = (BPF_JMP |EBPF_JSLE |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JSLE |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =TEST_JCC_2 , .off =9 , }, [7 ] = { .code = (BPF_JMP |BPF_JGT |BPF_K ), - .dst_reg =EBPF_REG_4 , + .dst_reg =BPF_REG_4 , .imm =TEST_JCC_3 , .off =10 , }, [8 ] = { .code = (BPF_JMP |BPF_JSET |BPF_K ), - .dst_reg =EBPF_REG_5 , + .dst_reg =BPF_REG_5 , .imm =TEST_JCC_4 , .off =11 , }, [9 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JNE |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_3 , .off =12 , }, [10 ] = { - .code = (BPF_JMP |EBPF_JSGT |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_4 , + .code = (BPF_JMP |BPF_JSGT |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_4 , .off =13 , }, [11 ] = { - .code = (BPF_JMP |EBPF_JLE |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_5 , + .code = (BPF_JMP |BPF_JLE |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_5 , .off =14 , }, [12 ] = { .code = (BPF_JMP |BPF_JSET |BPF_X ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_5 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_5 , .off =15 , }, [13 ] = { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, [14 ] = { - .code = (EBPF_ALU64 |BPF_OR |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_OR |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0x1 , }, [15 ] = {
@@ -1072,8 +1072,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -10, }, [16] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x2, }, [17] = {
@@ -1081,8 +1081,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -11, }, [18] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x4, }, [19] = {
@@ -1090,8 +1090,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -12, }, [20] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x8, }, [21] = {
@@ -1099,8 +1099,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -13, }, [22] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x10, }, [23] = {
@@ -1108,8 +1108,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -14, }, [24] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x20, }, [25] = {
@@ -1117,8 +1117,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -15, }, [26] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x40, }, [27] = {
@@ -1126,8 +1126,8 @@ static const struct rte_ebpf_insn test_jump1_prog[] = { .off = -16, }, [28] = { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_0, .imm = 0x80, }, [29] = {
@@ -1192,98 +1192,98 @@ test_jump1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_jump2_prog[] = { [0 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =0xe , }, [1 ] = { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_1 , .off =12 , }, [2 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JNE |BPF_K ), + .dst_reg =BPF_REG_3 , .off =2 , .imm =0x81 , }, [3 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =0x12 , }, [4 ] = { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_1 , .off =16 , }, [5 ] = { - .code = (EBPF_ALU64 |BPF_AND |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU64 |BPF_AND |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =0xffff , }, [6 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_JMP |BPF_JNE |BPF_K ), + .dst_reg =BPF_REG_3 , .off =9 , .imm =0x8 , }, [7 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , }, [8 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0 , }, [9 ] = { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_1 , .off =16 , }, [10 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =TEST_NETMASK , }, [11 ] = { - .code = (BPF_ALU |EBPF_END |EBPF_TO_BE ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_END |BPF_TO_BE ), + .dst_reg =BPF_REG_3 , .imm =sizeof (uint32_t ) *CHAR_BIT , }, [12 ] = { .code = (BPF_ALU |BPF_AND |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , }, [13 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =TEST_SUBNET , }, [14 ] = { - .code = (BPF_ALU |EBPF_END |EBPF_TO_BE ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU |BPF_END |BPF_TO_BE ), + .dst_reg =BPF_REG_3 , .imm =sizeof (uint32_t ) *CHAR_BIT , }, [15 ] = { .code = (BPF_JMP |BPF_JEQ |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , .off =1 , }, [16 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =-1 , }, [17 ] = { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -1358,137 +1358,137 @@ static const struct rte_ebpf_insn test_alu1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_5, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_5, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_FILL_1, }, { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_FILL_1, }, { .code = (BPF_ALU | BPF_XOR | BPF_K), - .dst_reg = EBPF_REG_4, + .dst_reg = BPF_REG_4, .imm = TEST_FILL_1, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_K), - .dst_reg = EBPF_REG_5, + .code = (BPF_ALU64 | BPF_ADD | BPF_K), + .dst_reg = BPF_REG_5, .imm = TEST_FILL_1, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_5, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_5, .off = offsetof(struct dummy_vect8, out[3].u64), }, { .code = (BPF_ALU | BPF_OR | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_3, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_XOR | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_4, + .code = (BPF_ALU64 | BPF_XOR | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_4, }, { .code = (BPF_ALU | BPF_SUB | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_5, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_5, }, { - .code = (EBPF_ALU64 | BPF_AND | BPF_X), - .dst_reg = EBPF_REG_5, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_AND | BPF_X), + .dst_reg = BPF_REG_5, + .src_reg = BPF_REG_2, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[4].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[5].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[6].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_5, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_5, .off = offsetof(struct dummy_vect8, out[7].u64), }, /* return (-r2 + (-r3)) */ { .code = (BPF_ALU | BPF_NEG), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, }, { - .code = (EBPF_ALU64 | BPF_NEG), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_NEG), + .dst_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_3, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_2, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -1540,114 +1540,114 @@ static const struct rte_ebpf_insn test_bele1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_H), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u16), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u64), }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_BE), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU | BPF_END | BPF_TO_BE), + .dst_reg = BPF_REG_2, .imm = sizeof(uint16_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_BE), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU | BPF_END | BPF_TO_BE), + .dst_reg = BPF_REG_3, .imm = sizeof(uint32_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_BE), - .dst_reg = EBPF_REG_4, + .code = (BPF_ALU | BPF_END | BPF_TO_BE), + .dst_reg = BPF_REG_4, .imm = sizeof(uint64_t) * CHAR_BIT, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_H), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u16), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u64), }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_LE), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU | BPF_END | BPF_TO_LE), + .dst_reg = BPF_REG_2, .imm = sizeof(uint16_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_LE), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU | BPF_END | BPF_TO_LE), + .dst_reg = BPF_REG_3, .imm = sizeof(uint32_t) * CHAR_BIT, }, { - .code = (BPF_ALU | EBPF_END | EBPF_TO_LE), - .dst_reg = EBPF_REG_4, + .code = (BPF_ALU | BPF_END | BPF_TO_LE), + .dst_reg = BPF_REG_4, .imm = sizeof(uint64_t) * CHAR_BIT, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[3].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[4].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[5].u64), }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -1705,132 +1705,132 @@ test_bele1_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_xadd1_prog[] = { { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_3 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_3 , .imm =-1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_3 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_3 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_4 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_4 , .imm =TEST_FILL_1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_4 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_4 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_4 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_4 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_5 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_5 , .imm =TEST_MUL_1 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_5 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_5 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_5 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_5 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_6 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_6 , .imm =TEST_MUL_2 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_6 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_6 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_6 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_6 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_7 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_7 , .imm =TEST_JCC_2 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_7 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_7 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_7 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_7 , .off = offsetof(struct dummy_offset , u64), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_8 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_8 , .imm =TEST_JCC_3 , }, { - .code = (BPF_STX |EBPF_XADD |BPF_W ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_8 , + .code = (BPF_STX |BPF_XADD |BPF_W ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_8 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_STX |EBPF_XADD |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_8 , + .code = (BPF_STX |BPF_XADD |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_8 , .off = offsetof(struct dummy_offset , u64), },/* return 1 */ { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -1894,90 +1894,90 @@ static const struct rte_ebpf_insn test_div1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[0].u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[1].u64), }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[2].u32), }, { .code = (BPF_ALU | BPF_DIV | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = TEST_MUL_1, }, { - .code = (EBPF_ALU64 | BPF_MOD | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_MOD | BPF_K), + .dst_reg = BPF_REG_3, .imm = TEST_MUL_2, }, { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_2, .imm = 1, }, { - .code = (EBPF_ALU64 | BPF_OR | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_OR | BPF_K), + .dst_reg = BPF_REG_3, .imm = 1, }, { .code = (BPF_ALU | BPF_MOD | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, { - .code = (EBPF_ALU64 | BPF_DIV | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_DIV | BPF_X), + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_3, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_2, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_2, .off = offsetof(struct dummy_vect8, out[0].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_3, .off = offsetof(struct dummy_vect8, out[1].u64), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_4, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_4, .off = offsetof(struct dummy_vect8, out[2].u64), }, /* check that we can handle division by zero gracefully. */ { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_vect8, in[3].u32), }, { .code = (BPF_ALU | BPF_DIV | BPF_X), - .dst_reg = EBPF_REG_4, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_4, + .src_reg = BPF_REG_2, }, /* return 1 */ { - .code = (BPF_ALU | EBPF_MOV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU | BPF_MOV | BPF_K), + .dst_reg = BPF_REG_0, .imm = 1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -2018,71 +2018,71 @@ static const struct rte_ebpf_insn test_call1_prog[] = { { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_1, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u32), }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_1, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_1, .off = offsetof(struct dummy_offset, u64), }, { .code = (BPF_STX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_2, + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_2, .off = -4, }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_3, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_3, .off = -16, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_10, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_10, }, { - .code = (EBPF_ALU64 | BPF_SUB | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_SUB | BPF_K), + .dst_reg = BPF_REG_2, .imm = 4, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_3, - .src_reg = EBPF_REG_10, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_3, + .src_reg = BPF_REG_10, }, { - .code = (EBPF_ALU64 | BPF_SUB | BPF_K), - .dst_reg = EBPF_REG_3, + .code = (BPF_ALU64 | BPF_SUB | BPF_K), + .dst_reg = BPF_REG_3, .imm = 16, }, { - .code = (BPF_JMP | EBPF_CALL), + .code = (BPF_JMP | BPF_CALL), .imm = 0, }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_10, + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_10, .off = -4, }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_10, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_10, .off = -16 }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_2, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -2142,74 +2142,74 @@ static const struct rte_bpf_xsym test_call1_xsym[] = {static const struct rte_ebpf_insn test_call2_prog[] = { { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_1 , .imm = -(int32_t )sizeof (struct dummy_offset ), }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_10 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =-2 * (int32_t )sizeof (struct dummy_offset ), }, { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u64)), }, { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u32)), }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(2 *sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u16)), }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off = -(int32_t )(2 *sizeof (struct dummy_offset ) - offsetof(struct dummy_offset , u8)), }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2268,51 +2268,51 @@ static const struct rte_bpf_xsym test_call2_xsym[] = {static const struct rte_ebpf_insn test_call3_prog[] = { { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_0 , + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u8), }, { .code = (BPF_LDX |BPF_MEM |BPF_H ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_0 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u16), }, { .code = (BPF_LDX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_4 , - .src_reg =EBPF_REG_0 , + .dst_reg =BPF_REG_4 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u32), }, { - .code = (BPF_LDX |BPF_MEM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_0 , + .code = (BPF_LDX |BPF_MEM |BPF_DW ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_0 , .off = offsetof(struct dummy_offset , u64), },/* return sum */ { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_4 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_4 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_3 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_3 , }, { - .code = (EBPF_ALU64 |BPF_ADD |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_2 , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2381,82 +2381,82 @@ static const struct rte_bpf_xsym test_call3_xsym[] = {static const struct rte_ebpf_insn test_call4_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-4 , .imm =1 , }, { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-3 , .imm =2 , }, { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-2 , .imm =3 , }, { .code = (BPF_ST |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_10 , .off =-1 , .imm =4 , }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =4 , }, { - .code = (EBPF_ALU64 |BPF_SUB |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_SUB |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_2 , }, { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , .off =-4 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_10 , .off =-3 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_3 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_3 , + .src_reg =BPF_REG_10 , .off =-2 , }, { .code = (BPF_LDX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_4 , - .src_reg =EBPF_REG_10 , + .dst_reg =BPF_REG_4 , + .src_reg =BPF_REG_10 , .off =-1 , }, { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =1 , }, { - .code = (EBPF_ALU64 |BPF_XOR |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_XOR |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =TEST_MEMFROB , }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2554,146 +2554,146 @@ static const struct rte_bpf_xsym test_call4_xsym[] = {static const struct rte_ebpf_insn test_call5_prog[] = { [0 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =STRING_GEEK , }, [1 ] = { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_1 , .off =-8 , }, [2 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_6 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_6 , .imm =0 , }, [3 ] = { .code = (BPF_STX |BPF_MEM |BPF_B ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_6 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_6 , .off =-4 , }, [4 ] = { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_6 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_6 , .off =-12 , }, [5 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =STRING_WEEK , }, [6 ] = { .code = (BPF_STX |BPF_MEM |BPF_W ), - .dst_reg =EBPF_REG_10 , - .src_reg =EBPF_REG_1 , + .dst_reg =BPF_REG_10 , + .src_reg =BPF_REG_1 , .off =-16 , }, [7 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, [8 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =-8 , }, [9 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_1 , }, [10 ] = { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, [11 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_0 , }, [12 ] = { - .code = (BPF_ALU |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =-1 , }, [13 ] = { - .code = (EBPF_ALU64 |BPF_LSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_LSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [14 ] = { - .code = (EBPF_ALU64 |BPF_RSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_RSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [15 ] = { - .code = (BPF_JMP |EBPF_JNE |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_JMP |BPF_JNE |BPF_K ), + .dst_reg =BPF_REG_1 , .off =11 , .imm =0 , }, [16 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_10 , }, [17 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =-8 , }, [18 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_2 , - .src_reg =EBPF_REG_10 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_2 , + .src_reg =BPF_REG_10 , }, [19 ] = { - .code = (EBPF_ALU64 |BPF_ADD |BPF_K ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_ALU64 |BPF_ADD |BPF_K ), + .dst_reg =BPF_REG_2 , .imm =-16 , }, [20 ] = { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 , }, [21 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_0 , }, [22 ] = { - .code = (EBPF_ALU64 |BPF_LSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_LSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [23 ] = { - .code = (EBPF_ALU64 |BPF_RSH |BPF_K ), - .dst_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_RSH |BPF_K ), + .dst_reg =BPF_REG_1 , .imm =0x20 , }, [24 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ), - .dst_reg =EBPF_REG_0 , - .src_reg =EBPF_REG_1 , + .code = (BPF_ALU64 |BPF_MOV |BPF_X ), + .dst_reg =BPF_REG_0 , + .src_reg =BPF_REG_1 , }, [25 ] = { .code = (BPF_JMP |BPF_JEQ |BPF_X ), - .dst_reg =EBPF_REG_1 , - .src_reg =EBPF_REG_6 , + .dst_reg =BPF_REG_1 , + .src_reg =BPF_REG_6 , .off =1 , }, [26 ] = { - .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_ALU64 |BPF_MOV |BPF_K ), + .dst_reg =BPF_REG_0 , .imm =0 , }, [27 ] = { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };
@@ -2763,9 +2763,9 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_6, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_6, + .src_reg = BPF_REG_1, },/* load IPv4 version and IHL */ {
@@ -2774,50 +2774,50 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = { },/* check IP version */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_0, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = 0xf0, }, { .code = (BPF_JMP | BPF_JEQ | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = IPVERSION << 4, .off = 2, }, /* invalid IP version, return 0 */ { - .code = (EBPF_ALU64 | BPF_XOR | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_XOR | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, /* load 3-rd byte of IP data */ { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = RTE_IPV4_HDR_IHL_MASK, }, { .code = (BPF_ALU | BPF_LSH | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = 2, }, { .code = (BPF_LD | BPF_IND | BPF_B), - .src_reg = EBPF_REG_0, + .src_reg = BPF_REG_0, .imm = 3, }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_7, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_7, + .src_reg = BPF_REG_0, }, /* load IPv4 src addr */ {
@@ -2825,9 +2825,9 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = { .imm = offsetof(struct rte_ipv4_hdr, src_addr), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_7, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_7, + .src_reg = BPF_REG_0, },/* load IPv4 total length */ {
@@ -2835,38 +2835,38 @@ static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = { .imm = offsetof(struct rte_ipv4_hdr, total_length), }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_8, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_8, + .src_reg = BPF_REG_0, }, /* load last 4 bytes of IP data */ { .code = (BPF_LD | BPF_IND | BPF_W), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, .imm = -(int32_t)sizeof(uint32_t), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_7, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_7, + .src_reg = BPF_REG_0, }, /* load 2 bytes from the middle of IP data */ { - .code = (EBPF_ALU64 | BPF_RSH | BPF_K), - .dst_reg = EBPF_REG_8, + .code = (BPF_ALU64 | BPF_RSH | BPF_K), + .dst_reg = BPF_REG_8, .imm = 1, }, { .code = (BPF_LD | BPF_IND | BPF_H), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_7, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_7, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3021,9 +3021,9 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_6, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_6, + .src_reg = BPF_REG_1, },/* load IPv4 version and IHL */ {
@@ -3032,50 +3032,50 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = { },/* check IP version */ { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_2, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_2, + .src_reg = BPF_REG_0, }, { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = 0xf0, }, { .code = (BPF_JMP | BPF_JEQ | BPF_K), - .dst_reg = EBPF_REG_2, + .dst_reg = BPF_REG_2, .imm = IPVERSION << 4, .off = 2, }, /* invalid IP version, return 0 */ { - .code = (EBPF_ALU64 | BPF_XOR | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_XOR | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, /* load 3-rd byte of IP data */ { .code = (BPF_ALU | BPF_AND | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = RTE_IPV4_HDR_IHL_MASK, }, { .code = (BPF_ALU | BPF_LSH | BPF_K), - .dst_reg = EBPF_REG_0, + .dst_reg = BPF_REG_0, .imm = 2, }, { .code = (BPF_LD | BPF_IND | BPF_B), - .src_reg = EBPF_REG_0, + .src_reg = BPF_REG_0, .imm = 3, }, { .code = (BPF_STX | BPF_MEM | BPF_B), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_0, + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_0, .off = (int16_t)(offsetof(struct dummy_offset, u8) - sizeof(struct dummy_offset)), },
@@ -3086,8 +3086,8 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = { }, { .code = (BPF_STX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_0, + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_0, .off = (int16_t )(offsetof(struct dummy_offset , u32) - sizeof(struct dummy_offset)), },
@@ -3097,71 +3097,71 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = { .imm = offsetof(struct rte_ipv4_hdr, total_length), }, { - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .dst_reg = EBPF_REG_8, - .src_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .dst_reg = BPF_REG_8, + .src_reg = BPF_REG_0, }, /* load last 4 bytes of IP data */ { .code = (BPF_LD | BPF_IND | BPF_W), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, .imm = -(int32_t)sizeof(uint32_t), }, { - .code = (BPF_STX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_10, - .src_reg = EBPF_REG_0, + .code = (BPF_STX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_10, + .src_reg = BPF_REG_0, .off = (int16_t)(offsetof(struct dummy_offset, u64) - sizeof(struct dummy_offset)), }, /* load 2 bytes from the middle of IP data */ { - .code = (EBPF_ALU64 | BPF_RSH | BPF_K), - .dst_reg = EBPF_REG_8, + .code = (BPF_ALU64 | BPF_RSH | BPF_K), + .dst_reg = BPF_REG_8, .imm = 1, }, { .code = (BPF_LD | BPF_IND | BPF_H), - .src_reg = EBPF_REG_8, + .src_reg = BPF_REG_8, }, { - .code = (BPF_LDX | BPF_MEM | EBPF_DW), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_10, + .code = (BPF_LDX | BPF_MEM | BPF_DW), + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_10, .off = (int16_t)(offsetof(struct dummy_offset, u64) - sizeof(struct dummy_offset)), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, }, { .code = (BPF_LDX | BPF_MEM | BPF_W), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_10, + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_10, .off = (int16_t)(offsetof(struct dummy_offset, u32) - sizeof(struct dummy_offset)), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, }, { .code = (BPF_LDX | BPF_MEM | BPF_B), - .dst_reg = EBPF_REG_1, - .src_reg = EBPF_REG_10, + .dst_reg = BPF_REG_1, + .src_reg = BPF_REG_10, .off = (int16_t)(offsetof(struct dummy_offset, u8) - sizeof(struct dummy_offset)), }, { - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .dst_reg = EBPF_REG_0, - .src_reg = EBPF_REG_1, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .dst_reg = BPF_REG_0, + .src_reg = BPF_REG_1, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3169,8 +3169,8 @@ static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (int32_t )INT64_MIN , }, {
@@ -3178,13 +3178,13 @@ static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = { },/* Divide r0 by immediate -1 */ { - .code = (EBPF_ALU64 | BPF_DIV | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_DIV | BPF_K), + .dst_reg = BPF_REG_0, .imm = -1, },/* Exit for correctness otherwise */ { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3201,8 +3201,8 @@ test_int64min_udiv_uint64max_check(uint64_t rc, const void *arg)static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (int32_t )INT64_MIN , }, {
@@ -3210,13 +3210,13 @@ static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = { },/* Modulo r0 by immediate -1 */ { - .code = (EBPF_ALU64 | BPF_MOD | BPF_K), - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOD | BPF_K), + .dst_reg = BPF_REG_0, .imm = -1, },/* Exit for correctness otherwise */ { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };
@@ -3654,8 +3654,8 @@ static inttest_bpf_exec_wrong_nb_prog_arg (void) {static const struct rte_ebpf_insn ins[] = { - { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, - { .code = (BPF_JMP |EBPF_EXIT ), } + { .code = (BPF_ALU64 |BPF_MOV |BPF_K ), .dst_reg =BPF_REG_0 , .imm =0 }, + { .code = (BPF_JMP |BPF_EXIT ), } };static const struct rte_bpf_prm_ex prm = { .sz =sizeof (struct rte_bpf_prm_ex ),
@@ -3696,8 +3696,8 @@ static inttest_bpf_exec_wrong_flags (void) {static const struct rte_ebpf_insn ins[] = { - { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, - { .code = (BPF_JMP |EBPF_EXIT ), } + { .code = (BPF_ALU64 |BPF_MOV |BPF_K ), .dst_reg =BPF_REG_0 , .imm =0 }, + { .code = (BPF_JMP |BPF_EXIT ), } };static const struct rte_bpf_prm_ex prm = { .sz =sizeof (struct rte_bpf_prm_ex ),
@@ -3760,11 +3760,11 @@ call_from_bpf_test(text_xfunc_t xfunc) {static const struct rte_ebpf_insn ins[] = { { - .code = (BPF_JMP |EBPF_CALL ), + .code = (BPF_JMP |BPF_CALL ), .imm =0 ,/* xsym #0 */ }, { - .code = (BPF_JMP |EBPF_EXIT ), + .code = (BPF_JMP |BPF_EXIT ), }, };const struct rte_bpf_xsym xsym[] = {
@@ -5006,8 +5006,8 @@ test_xadd32(void)static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5016,8 +5016,8 @@ test_xadd32(void) }, {/* Set r2 to XADD operand. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_2, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_2, .imm = (uint32_t)XADD_OPERAND, }, {
@@ -5026,27 +5026,27 @@ test_xadd32(void) }, { /* Atomically add r2 to value0, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { /* Negate r2. */ - .code = (EBPF_ALU64 | BPF_NEG | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_NEG | BPF_K), + .dst_reg = BPF_REG_2, }, { /* Atomically add r2 to value1, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct xchg_arg expected = {
@@ -5086,8 +5086,8 @@ test_xadd64(void)static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_0 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_0 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5096,8 +5096,8 @@ test_xadd64(void) }, {/* Set r2 to XADD operand. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_2, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_2, .imm = (uint32_t)XADD_OPERAND, }, {
@@ -5106,27 +5106,27 @@ test_xadd64(void) }, { /* Atomically add r2 to value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { /* Negate r2. */ - .code = (EBPF_ALU64 | BPF_NEG | BPF_K), - .dst_reg = EBPF_REG_2, + .code = (BPF_ALU64 | BPF_NEG | BPF_K), + .dst_reg = BPF_REG_2, }, { /* Atomically add r2 to value1. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_ADD, + .imm = BPF_ADD, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct xchg_arg expected = {
@@ -5152,8 +5152,8 @@ test_xchg32(void)static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_2 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5162,32 +5162,32 @@ test_xchg32(void) }, { /* Atomically exchange r2 with value0, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value1, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value0, 32-bit. */ - .code = (BPF_STX | EBPF_ATOMIC | BPF_W), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_W), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Set upper half of r0 to return value. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_0, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_0, .imm = 0, }, {
@@ -5199,12 +5199,12 @@ test_xchg32(void)* Add r2 (should have upper half cleared by this time) * to r0 to use as a return value. */ - .code = (EBPF_ALU64 | BPF_ADD | BPF_X), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_ADD | BPF_X), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, };struct xchg_arg expected = {
@@ -5247,8 +5247,8 @@ test_xchg64(void)static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ - .code = (BPF_LD |BPF_IMM |EBPF_DW ), - .dst_reg =EBPF_REG_2 , + .code = (BPF_LD |BPF_IMM |BPF_DW ), + .dst_reg =BPF_REG_2 , .imm = (uint32_t )XCHG_RETURN_VALUE , }, {
@@ -5257,36 +5257,36 @@ test_xchg64(void) }, { /* Atomically exchange r2 with value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value1. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value1), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Atomically exchange r2 with value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), - .imm = BPF_ATOMIC_XCHG, + .imm = BPF_XCHG, }, { /* Copy r2 to r0 to use as a return value. */ - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct xchg_arg expected = {
@@ -5310,8 +5310,8 @@ test_atomic_imm(int32_t imm, bool is_valid) const struct rte_ebpf_insn ins[] = { { /* Set r2 to return value. */ - .code = (BPF_LD | BPF_IMM | EBPF_DW), - .dst_reg = EBPF_REG_2, + .code = (BPF_LD | BPF_IMM | BPF_DW), + .dst_reg = BPF_REG_2, .imm = (uint32_t)XCHG_RETURN_VALUE, }, {
@@ -5320,20 +5320,20 @@ test_atomic_imm(int32_t imm, bool is_valid) }, { /* Atomically exchange r2 with value0. */ - .code = (BPF_STX | EBPF_ATOMIC | EBPF_DW), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_1, + .code = (BPF_STX | BPF_ATOMIC | BPF_DW), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_1, .off = offsetof(struct xchg_arg, value0), .imm = imm, }, { /* Copy r2 to r0 to use as a return value. */ - .code = (EBPF_ALU64 | EBPF_MOV | BPF_X), - .src_reg = EBPF_REG_2, - .dst_reg = EBPF_REG_0, + .code = (BPF_ALU64 | BPF_MOV | BPF_X), + .src_reg = BPF_REG_2, + .dst_reg = BPF_REG_0, }, { - .code = (BPF_JMP | EBPF_EXIT), + .code = (BPF_JMP | BPF_EXIT), }, }; const struct rte_bpf_prm prm = {
@@ -5360,8 +5360,8 @@ static int test_atomic_imms(void) { RTE_TEST_ASSERT_SUCCESS(test_atomic_imm(INT32_MIN, false), "expect success"); - for (int32_t imm = BPF_ATOMIC_ADD - 1; imm <= BPF_ATOMIC_XCHG + 1; ++imm) { - const bool is_valid = imm == BPF_ATOMIC_ADD || imm == BPF_ATOMIC_XCHG; + for (int32_t imm = BPF_ADD - 1; imm <= BPF_XCHG + 1; ++imm) { + const bool is_valid = imm == BPF_ADD || imm == BPF_XCHG; RTE_TEST_ASSERT_SUCCESS(test_atomic_imm(imm, is_valid), "expect success"); } RTE_TEST_ASSERT_SUCCESS(test_atomic_imm(INT32_MAX, false), "expect success");
app/test/test_bpf_validate.c +99 -99
13 lines not on this page · raw message
lib/bpf/bpf_def.h +35 -41
76 lines not on this page · raw message
lib/bpf/bpf_exec.c +76 -76
152 lines not on this page · raw message
lib/bpf/bpf_jit_arm64.c +107 -107
214 lines not on this page · raw message
lib/bpf/bpf_jit_x86.c +155 -155
310 lines not on this page · raw message
lib/bpf/bpf_validate.c +133 -133
266 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.43.0
Part of the diff is not shown here. View the raw message.
RE: [PATCH v2 2/2] bpf: rename macros to match Linux kernel
Quoted 7 lines
BPF opcode macro names had small deviations from the ones defined in Linux headers, confusing humans and AI tools during code generation and analysis, since both are mostly trained on the Linux spelling.
Rename them to match Linux counterparts.
But then, there would be a risk that inside DPDK code we will use definitions provided by linux includes without even noticing that? I understand that both should boil down to the same values, but still sort of grey area here...
Shall we add 'RTE_' or '_RTE_' prefix to our own ones?
Quoted 3 lines
Signed-off-by Marat Khalili <[email protected]>---
v3 cover bpf_def.h cleanups
In reply to Marat KhaliliThe goal of this patch is to clarify the public/private status of the eBPF definitions and prevent name conflicts. It achieves this by moving the required public symbols into the public ``rte_bpf.h`` header with a proper ``RTE_`` prefix, and making the remaining ``bpf_def.h`` header private.
v3:
* Dropped part 2 (renaming macros) as there was no consensus on it.
* Added a release notes entry detailing the API change (bpf_def.h becoming private and public symbols moved to rte_bpf.h).
v2:
* Following the AI suggestion renamed RTE_EBPF_FUNC_MAX_ARGS to RTE_BPF_FUNC_MAX_ARGS.
* Rebased on fresh main hoping to overcome the unrelated CI issues.
* Cautiously re-posting without the RFC label.
Marat Khalili (1):
bpf: make bpf_def.h private
app/test/test_bpf.c | 79 +++++++++++++------------- app/test/test_bpf_validate.c | 74 ++++++++++++------------ doc/guides/rel_notes/release_26_11.rst | 6 ++ lib/bpf/bpf_convert.c | 38 ++++++------- lib/bpf/bpf_def.h | 15 ----- lib/bpf/bpf_dump.c | 13 +++-- lib/bpf/bpf_exec.c | 8 +-- lib/bpf/bpf_impl.h | 3 +- lib/bpf/bpf_jit_arm64.c | 4 +- lib/bpf/bpf_jit_x86.c | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 10 ++-- lib/bpf/bpf_validate.c | 44 +++++++------- lib/bpf/bpf_validate.h | 6 +- lib/bpf/bpf_validate_debug.c | 6 +- lib/bpf/meson.build | 1 - lib/bpf/rte_bpf.h | 33 ++++++++--- lib/bpf/rte_bpf_validate_debug.h | 8 +-- 18 files changed, 180 insertions(+), 172 deletions(-)
Signature · 1 line
2.43.0
PATCH v3 1/1 bpf: make bpf_def.h private
From: Marat Khalili <[email protected]>
Both bpf_def.h header file and the symbols it defined were not previously prefixed with rte_, creating an opportunity for name conflicts. Status of the file itself (private or public) was unclear.
Move public symbols after adding the necessary prefix (rte_ebpf_insn and RTE_BPF_FUNC_MAX_ARGS) into the public header file rte_bpf.h, and make the rest private.
--- app/test/test_bpf.c | 79 +++++++++++++------------- app/test/test_bpf_validate.c | 74 ++++++++++++------------ doc/guides/rel_notes/release_26_11.rst | 6 ++ lib/bpf/bpf_convert.c | 38 ++++++------- lib/bpf/bpf_def.h | 15 ----- lib/bpf/bpf_dump.c | 13 +++-- lib/bpf/bpf_exec.c | 8 +-- lib/bpf/bpf_impl.h | 3 +- lib/bpf/bpf_jit_arm64.c | 4 +- lib/bpf/bpf_jit_x86.c | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 10 ++-- lib/bpf/bpf_validate.c | 44 +++++++------- lib/bpf/bpf_validate.h | 6 +- lib/bpf/bpf_validate_debug.c | 6 +- lib/bpf/meson.build | 1 - lib/bpf/rte_bpf.h | 33 ++++++++--- lib/bpf/rte_bpf_validate_debug.h | 8 +-- 18 files changed, 180 insertions(+), 172 deletions(-)
app/test/test_bpf.c +40 -39
@@ -16,6 +16,7 @@#include <rte_byteorder.h> #include <rte_errno.h> +#include "bpf_def.h" #include "test.h" #if !defined(RTE_LIB_BPF )
@@ -52,7 +53,7 @@ test_bpf(void)* TEST_SUCCESS on success, error code on failure. */ static int -bpf_load_test (uint32_t nb_ins,const struct ebpf_insn *ins,int expected_errno) +bpf_load_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,int expected_errno) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -87,7 +88,7 @@ bpf_load_test(uint32_t nb_ins, const struct ebpf_insn *ins, int expected_errno)static int test_no_instructions (void ) { -static const struct ebpf_insn ins[] = {}; +static const struct rte_ebpf_insn ins[] = {};return bpf_load_test (RTE_DIM (ins), ins,EINVAL ); }
@@ -100,7 +101,7 @@ REGISTER_FAST_TEST(bpf_no_instructions_autotest, NOHUGE_OK, ASAN_OK, test_no_insstatic int test_exit_only (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_EXIT ), },
@@ -117,7 +118,7 @@ REGISTER_FAST_TEST(bpf_exit_only_autotest, NOHUGE_OK, ASAN_OK, test_exit_only);static int test_no_exit (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -136,7 +137,7 @@ REGISTER_FAST_TEST(bpf_no_exit_autotest, NOHUGE_OK, ASAN_OK, test_no_exit);static int test_minimal_working (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -158,7 +159,7 @@ REGISTER_FAST_TEST(bpf_minimal_working_autotest, NOHUGE_OK, ASAN_OK, test_minimastatic int test_add_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to one. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -186,7 +187,7 @@ REGISTER_FAST_TEST(bpf_add_one_autotest, NOHUGE_OK, ASAN_OK, test_add_one);static int test_subtract_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Subtract one from the program argument. */ .code = (EBPF_ALU64 |BPF_SUB |BPF_K ),
@@ -214,7 +215,7 @@ REGISTER_FAST_TEST(bpf_subtract_one_autotest, NOHUGE_OK, ASAN_OK, test_subtract_static int test_jump_over_invalid_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Jump over the next instruction for some r1. */ .code = (BPF_JMP |BPF_JEQ |BPF_K ),
@@ -251,7 +252,7 @@ REGISTER_FAST_TEST(bpf_jump_over_invalid_first_autotest, NOHUGE_OK, ASAN_OK,static int test_jump_over_invalid_non_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -401,7 +402,7 @@ dummy_prepare(void *arg) }/* store immediate test-cases */ -static const struct ebpf_insn test_store1_prog[] = { +static const struct rte_ebpf_insn test_store1_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_1 ,
@@ -464,7 +465,7 @@ test_store1_check(uint64_t rc, const void *arg) }/* store register test-cases */ -static const struct ebpf_insn test_store2_prog[] = { +static const struct rte_ebpf_insn test_store2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -507,7 +508,7 @@ static const struct ebpf_insn test_store2_prog[] = { };/* load test-cases */ -static const struct ebpf_insn test_load1_prog[] = { +static const struct rte_ebpf_insn test_load1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_B ),
@@ -584,7 +585,7 @@ test_load1_check(uint64_t rc, const void *arg) }/* load immediate test-cases */ -static const struct ebpf_insn test_ldimm1_prog[] = { +static const struct rte_ebpf_insn test_ldimm1_prog[] = { { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -672,7 +673,7 @@ test_ldimm1_check(uint64_t rc, const void *arg)/* alu mul test-cases */ -static const struct ebpf_insn test_mul1_prog[] = { +static const struct rte_ebpf_insn test_mul1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -784,7 +785,7 @@ test_mul1_check(uint64_t rc, const void *arg) }/* alu shift test-cases */ -static const struct ebpf_insn test_shift1_prog[] = { +static const struct rte_ebpf_insn test_shift1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -979,7 +980,7 @@ test_shift1_check(uint64_t rc, const void *arg) }/* jmp test-cases */ -static const struct ebpf_insn test_jump1_prog[] = { +static const struct rte_ebpf_insn test_jump1_prog[] = { [0 ] = { .code = (BPF_ALU |EBPF_MOV |BPF_K ),
@@ -1188,7 +1189,7 @@ test_jump1_check(uint64_t rc, const void *arg) }/* Jump test case - check ip4_dest in particular subnet */ -static const struct ebpf_insn test_jump2_prog[] = { +static const struct rte_ebpf_insn test_jump2_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1353,7 +1354,7 @@ test_jump2_check(uint64_t rc, const void *arg) }/* alu (add, sub, and, or, xor, neg) test-cases */ -static const struct ebpf_insn test_alu1_prog[] = { +static const struct rte_ebpf_insn test_alu1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -1535,7 +1536,7 @@ test_alu1_check(uint64_t rc, const void *arg) }/* endianness conversions (BE->LE/LE->BE) test-cases */ -static const struct ebpf_insn test_bele1_prog[] = { +static const struct rte_ebpf_insn test_bele1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_H ),
@@ -1701,7 +1702,7 @@ test_bele1_check(uint64_t rc, const void *arg) }/* atomic add test-cases */ -static const struct ebpf_insn test_xadd1_prog[] = { +static const struct rte_ebpf_insn test_xadd1_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1889,7 +1890,7 @@ test_xadd1_check(uint64_t rc, const void *arg) }/* alu div test-cases */ -static const struct ebpf_insn test_div1_prog[] = { +static const struct rte_ebpf_insn test_div1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2013,7 +2014,7 @@ test_div1_check(uint64_t rc, const void *arg) }/* call test-cases */ -static const struct ebpf_insn test_call1_prog[] = { +static const struct rte_ebpf_insn test_call1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2138,7 +2139,7 @@ static const struct rte_bpf_xsym test_call1_xsym[] = { }, }; -static const struct ebpf_insn test_call2_prog[] = { +static const struct rte_ebpf_insn test_call2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -2264,7 +2265,7 @@ static const struct rte_bpf_xsym test_call2_xsym[] = { }, }; -static const struct ebpf_insn test_call3_prog[] = { +static const struct rte_ebpf_insn test_call3_prog[] = { { .code = (BPF_JMP |EBPF_CALL ),
@@ -2377,7 +2378,7 @@ static const struct rte_bpf_xsym test_call3_xsym[] = { };/* Test for stack corruption in multiple function calls */ -static const struct ebpf_insn test_call4_prog[] = { +static const struct rte_ebpf_insn test_call4_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_10 ,
@@ -2550,7 +2551,7 @@ static const struct rte_bpf_xsym test_call4_xsym[] = { };/* string compare test case */ -static const struct ebpf_insn test_call5_prog[] = { +static const struct rte_ebpf_insn test_call5_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -2758,7 +2759,7 @@ static const struct rte_bpf_xsym test_call5_xsym[] = { };/* load mbuf (BPF_ABS/BPF_IND) test-cases */ -static const struct ebpf_insn test_ld_mbuf1_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3016,7 +3017,7 @@ test_ld_mbuf2_check(uint64_t rc, const void *arg) }/* same as test_ld_mbuf1, but now store intermediate results on the stack */ -static const struct ebpf_insn test_ld_mbuf3_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3165,7 +3166,7 @@ static const struct ebpf_insn test_ld_mbuf3_prog[] = { };/* divide INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_udiv_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3197,7 +3198,7 @@ test_int64min_udiv_uint64max_check(uint64_t rc, const void *arg) }/* modulo INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_umod_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3652,7 +3653,7 @@ REGISTER_FAST_TEST(bpf_load_null_autotest, NOHUGE_OK, ASAN_OK, test_bpf_load_nulstatic int test_bpf_exec_wrong_nb_prog_arg (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3694,7 +3695,7 @@ REGISTER_FAST_TEST(bpf_exec_wrong_nb_prog_arg_autotest, NOHUGE_OK, ASAN_OK,static int test_bpf_exec_wrong_flags (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3757,7 +3758,7 @@ typedef uint64_t (*text_xfunc_t)(uint64_t argument);static int call_from_bpf_test (text_xfunc_t xfunc) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_CALL ), .imm =0 ,/* xsym #0 */
@@ -4935,7 +4936,7 @@ static const struct xchg_arg xchg_input = {/* Run program against xchg_input and compare output value with expected. */ static int -run_xchg_test (uint32_t nb_ins,const struct ebpf_insn *ins,struct xchg_arg expected) +run_xchg_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,struct xchg_arg expected) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -5002,7 +5003,7 @@ run_xchg_test(uint32_t nb_ins, const struct ebpf_insn *ins, struct xchg_arg expestatic int test_xadd32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5082,7 +5083,7 @@ REGISTER_FAST_TEST(bpf_xadd32_autotest, NOHUGE_OK, ASAN_OK, test_xadd32);static int test_xadd64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5148,7 +5149,7 @@ REGISTER_FAST_TEST(bpf_xadd64_autotest, NOHUGE_OK, ASAN_OK, test_xadd64);static int test_xchg32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5243,7 +5244,7 @@ REGISTER_FAST_TEST(bpf_xchg32_autotest, NOHUGE_OK, ASAN_OK, test_xchg32);static int test_xchg64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5306,7 +5307,7 @@ REGISTER_FAST_TEST(bpf_xchg64_autotest, NOHUGE_OK, ASAN_OK, test_xchg64);static int test_atomic_imm (int32_t imm,bool is_valid) { -const struct ebpf_insn ins[] = { +const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
app/test/test_bpf_validate.c +37 -37
286 lines not on this page · raw message
doc/guides/rel_notes/release_26_11.rst +6 -0
@@ -95,6 +95,12 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* bpf: Made the ``bpf_def.h`` header file private, so eBPF instruction opcodes + are no longer publicly available (their numerical values follow the RFC and + e.g. Linux headers). The definition of the instruction struct and number of + program arguments were moved to ``rte_bpf.h`` and gained the public ``RTE_`` + prefix: ``struct rte_ebpf_insn`` and ``RTE_BPF_FUNC_MAX_ARGS``. + * eventdev: Promoted the following API from experimental to stable: * Rx adapter: ``rte_event_eth_rx_adapter_create_ext_with_params``,
lib/bpf/bpf_convert.c +19 -19
@@ -82,7 +82,7 @@/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ #define EBPF_ALU64_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -90,7 +90,7 @@ .imm = 0 })#define BPF_ALU32_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -100,7 +100,7 @@/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ #define BPF_ALU32_IMM (OP ,DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -110,7 +110,7 @@/* Short form of mov, dst_reg = src_reg */ #define BPF_MOV64_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -118,7 +118,7 @@ .imm = 0 })#define BPF_MOV32_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -128,7 +128,7 @@/* Short form of mov, dst_reg = imm32 */ #define BPF_MOV32_IMM (DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -138,7 +138,7 @@/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ #define BPF_MOV32_RAW (TYPE ,DST ,SRC ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_SRC(TYPE), \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -148,7 +148,7 @@/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ #define BPF_LD_ABS (SIZE ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -158,7 +158,7 @@/* Memory load, dst_reg = *(uint *) (src_reg + off16) */ #define BPF_LDX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -168,7 +168,7 @@/* Memory store, *(uint *) (dst_reg + off16) = src_reg */ #define BPF_STX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -178,7 +178,7 @@/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ #define BPF_JMP_IMM (OP ,DST ,IMM ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -188,7 +188,7 @@/* Raw code statement block */ #define BPF_RAW_INSN (CODE ,DST ,SRC ,OFF ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = CODE, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -198,7 +198,7 @@/* Program exit */ #define BPF_EXIT_INSN () \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | EBPF_EXIT, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -210,7 +210,7 @@* If and when DPDK BPF supports them. */ static bool convert_bpf_load (const struct bpf_insn *fp, - struct ebpf_insn **new_insnp __rte_unused) + struct rte_ebpf_insn **new_insnp __rte_unused) {switch (fp->k) {case SKF_AD_OFF +SKF_AD_PROTOCOL :
@@ -240,11 +240,11 @@ static bool convert_bpf_load(const struct bpf_insn *fp, }static int bpf_convert_filter (const struct bpf_insn *prog,size_t len, -struct ebpf_insn *new_prog,uint32_t *new_len) +struct rte_ebpf_insn *new_prog,uint32_t *new_len) {unsigned int pass =0 ;size_t new_flen =0 , target, i; -struct ebpf_insn *new_insn; +struct rte_ebpf_insn *new_insn;const struct bpf_insn *fp;int *addrs =NULL ;uint8_t bpf_src;
@@ -284,8 +284,8 @@ static int bpf_convert_filter(const struct bpf_insn *prog, size_t len, }for (i =0 ; i < len; fp++, i++) { -struct ebpf_insn tmp_insns[6 ] = { }; -struct ebpf_insn *insn = tmp_insns; +struct rte_ebpf_insn tmp_insns[6 ] = { }; +struct rte_ebpf_insn *insn = tmp_insns;if (addrs) addrs[i] = new_insn - new_prog;
@@ -526,7 +526,7 @@ struct rte_bpf_prm * rte_bpf_convert(const struct bpf_program *prog) {struct rte_bpf_prm *prm =NULL ; -struct ebpf_insn *ebpf =NULL ; +struct rte_ebpf_insn *ebpf =NULL ;uint32_t ebpf_len =0 ;int ret;
lib/bpf/bpf_def.h +0 -15
@@ -129,20 +129,5 @@ enum {*/ #define EBPF_PSEUDO_CALL EBPF_REG_1 -/* -* eBPF instruction format -*/ -struct ebpf_insn { -uint8_t code; -uint8_t dst_reg:4 ; -uint8_t src_reg:4 ; -int16_t off; -int32_t imm; -}; - -/* -* eBPF allows functions with R1-R5 as arguments. -*/ -#define EBPF_FUNC_MAX_ARGS (EBPF_REG_6 - EBPF_REG_1)#endif /* RTE_BPF_DEF_H_ */
lib/bpf/bpf_dump.c +7 -6
@@ -9,6 +9,7 @@#include <eal_export.h> #include "rte_bpf.h" +#include "bpf_def.h" #define BPF_OP_INDEX (x) (BPF_OP(x) >> 4)#define BPF_SIZE_INDEX (x) (BPF_SIZE(x) >> 3)
@@ -48,7 +49,7 @@ static const char *const jump_tbl[16] = { RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_insn_is_wide, 26.07)bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins) +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins) {return ins->code == (BPF_LD |BPF_IMM |EBPF_DW ); }
@@ -56,7 +57,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins)/* Format one (possibly wide) eBPF command as hexadecimal in objdump format. */ static int -format_hexadecimal (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_hexadecimal (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t flags) {const char *const b = (const char *)ins;
@@ -93,7 +94,7 @@ atomic_op(int32_t imm)/* Format one (possibly wide) eBPF command as assembler. */ static int -format_disassembly (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_disassembly (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {uint8_t cls =BPF_CLASS (ins->code);
@@ -221,7 +222,7 @@ format_disassembly(char *buffer, size_t bufsz, const struct ebpf_insn *ins, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_format, 26.07)int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {if ((flags &RTE_BPF_FORMAT_FLAG_HEXADECIMAL ) !=0 )
@@ -231,13 +232,13 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins, }RTE_EXPORT_SYMBOL (rte_bpf_dump) -void rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len) +void rte_bpf_dump(FILE *f, const struct rte_ebpf_insn *buf, uint32_t len) {uint32_t i;char buffer[256 ];for (i =0 ; i < len; ++i) { -const struct ebpf_insn *ins = buf + i; +const struct rte_ebpf_insn *ins = buf + i; format_disassembly(buffer, sizeof(buffer), ins, i, RTE_BPF_FORMAT_FLAG_DISASSEMBLY |
lib/bpf/bpf_exec.c +4 -4
@@ -108,7 +108,7 @@static inline void -bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -127,7 +127,7 @@ bpf_alu_be(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins) }static inline void -bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -147,7 +147,7 @@ bpf_alu_le(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins)static inline const void *bpf_ld_mbuf (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ], -const struct ebpf_insn *ins,uint32_t off,uint32_t len) +const struct rte_ebpf_insn *ins,uint32_t off,uint32_t len) {const struct rte_mbuf *mb;const void *p;
@@ -165,7 +165,7 @@ bpf_ld_mbuf(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM],static inline uint64_t bpf_exec (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ]) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;for (ins = bpf->prm.raw.ins; ; ins++) {switch (ins->code) {
lib/bpf/bpf_impl.h +2 -1
@@ -7,6 +7,7 @@#include <rte_bpf.h> #include <sys/mman.h> +#include "bpf_def.h" #define MAX_BPF_STACK_SIZE 0x200
@@ -22,7 +23,7 @@ struct __rte_bpf_load {struct rte_bpf_prm_ex prm;/* Conversion from cBPF. */ -struct ebpf_insn *ins; +struct rte_ebpf_insn *ins;/* Loading ELF and applying relocations. */ int elf_fd;/* ELF fd, must be negative (not zero) by default. */
lib/bpf/bpf_jit_arm64.c +2 -2
@@ -1126,7 +1126,7 @@ emit_branch(struct a64_jit_ctx *ctx, uint8_t op, uint32_t i, int16_t off)static void check_program_has_call (struct a64_jit_ctx *ctx,struct rte_bpf *bpf) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint8_t op;uint32_t i;
@@ -1150,7 +1150,7 @@ static int emit(struct a64_jit_ctx *ctx, struct rte_bpf *bpf) { uint8_t op, dst, src, tmp1, tmp2, tmp3; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint64_t u64;int16_t off;int32_t imm;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -1315,7 +1315,7 @@ static int emit(struct bpf_jit_state *st, const struct rte_bpf *bpf) { uint32_t i, dr, op, sr; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;/* reset state fields */ st->sz =0 ;
lib/bpf/bpf_load.c +1 -1
@@ -61,7 +61,7 @@ bpf_check_xsym(const struct rte_bpf_xsym *xsym)return -EINVAL ; }else if (xsym->type ==RTE_BPF_XTYPE_FUNC ) { -if (xsym->func.nb_args >EBPF_FUNC_MAX_ARGS ) +if (xsym->func.nb_args >RTE_BPF_FUNC_MAX_ARGS )return -EINVAL ;/* check function arguments */
lib/bpf/bpf_load_elf.c +5 -5
@@ -58,7 +58,7 @@ bpf_find_xsym(const char *sn, enum rte_bpf_xtype type,* symbol *sn* */ static int -resolve_xsym (const char *sn,size_t ofs,struct ebpf_insn *ins,size_t ins_sz, +resolve_xsym (const char *sn,size_t ofs,struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {uint32_t idx, fidx;
@@ -169,7 +169,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx) sd =elf_getdata (sc,NULL );if (sd ==NULL || sd->d_size ==0 || - sd->d_size %sizeof (struct ebpf_insn ) !=0 ) { + sd->d_size %sizeof (struct rte_ebpf_insn ) !=0 ) { rc =elf_errno ();RTE_BPF_LOG_LINE (ERR ,"%s(%p, %s) error code: %d(%s)" , __func__, elf, section, rc,elf_errmsg (rc));
@@ -186,7 +186,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx)*/ static int process_reloc (Elf *elf,size_t sym_idx,Elf64_Rel *re,size_t re_sz, -struct ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) +struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {int32_t rc;uint32_t i, n;
@@ -235,7 +235,7 @@ process_reloc(Elf *elf, size_t sym_idx, Elf64_Rel *re, size_t re_sz,* and update bpf code. */ static int -elf_reloc_code (Elf *elf,struct ebpf_insn *ins,size_t ins_sz,size_t sidx, +elf_reloc_code (Elf *elf,struct rte_ebpf_insn *ins,size_t ins_sz,size_t sidx,const struct rte_bpf_prm_ex *prm) {Elf64_Rel *re;
@@ -355,7 +355,7 @@ __rte_bpf_load_elf_code(struct __rte_bpf_load *load) prm->origin =RTE_BPF_ORIGIN_RAW ; prm->raw.ins = sd->d_buf; - prm->raw.nb_ins = sd->d_size /sizeof (struct ebpf_insn ); + prm->raw.nb_ins = sd->d_size /sizeof (struct rte_ebpf_insn ); rc =elf_reloc_code (load->elf, sd->d_buf, sd->d_size, sidx, prm);if (rc <0 )
lib/bpf/bpf_validate.c +22 -22
166 lines not on this page · raw message
lib/bpf/bpf_validate.h +3 -3
@@ -11,7 +11,7 @@* Internal-use headers for eBPF validation observability. */ -#include <bpf_def.h> +#include <rte_bpf.h> #ifdef __cplusplusextern "C" {
@@ -32,12 +32,12 @@ __rte_bpf_validate_state_is_valid(const struct bpf_verifier *verifier);*/ int __rte_bpf_validate_can_access (const struct bpf_verifier *verifier, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/* Get possible truth values of the specified jump condition. */ int __rte_bpf_validate_may_jump (const struct bpf_verifier *verifier, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/* Format known information about the register for the user. */ int
lib/bpf/bpf_validate_debug.c +3 -3
@@ -319,7 +319,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug) RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_get_ins, 26.07)int rte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins) +const struct rte_ebpf_insn **ins,uint32_t *nb_ins) {if (debug ==NULL )return -EINVAL ;
@@ -378,7 +378,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_can_access, 26.07)int rte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64) +const struct rte_ebpf_insn *access,uint64_t off64) {if (debug ==NULL || access ==NULL )return -EINVAL ;
@@ -392,7 +392,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_may_jump, 26.07)int rte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64) +const struct rte_ebpf_insn *jump,uint64_t imm64) {if (debug ==NULL || jump ==NULL )return -EINVAL ;
lib/bpf/meson.build +0 -1
@@ -35,7 +35,6 @@ elif dpdk_conf.has('RTE_ARCH_ARM64') endif headers = files( - 'bpf_def.h', 'rte_bpf.h', 'rte_bpf_ethdev.h', 'rte_bpf_validate_debug.h',
lib/bpf/rte_bpf.h +24 -9
@@ -19,12 +19,27 @@#include <rte_common.h> #include <rte_mbuf.h> #include <rte_malloc.h> -#include <bpf_def.h> #ifdef __cplusplusextern "C" {#endif +/* +* eBPF instruction format +*/ +struct rte_ebpf_insn { +uint8_t code; +uint8_t dst_reg:4 ; +uint8_t src_reg:4 ; +int16_t off; +int32_t imm; +}; + +/* +* eBPF allows functions with up to 5 arguments. +*/ +#define RTE_BPF_FUNC_MAX_ARGS 5 +#define RTE_BPF_EXEC_FLAG_JIT RTE_BIT64(0)/**< use JIT-compiled version */ /** Mask with all supported `RTE_BPF_EXEC_FLAG_*` flags set. */
@@ -96,7 +111,7 @@ struct rte_bpf_xsym {uint64_t (*val)(uint64_t ,uint64_t ,uint64_t ,uint64_t ,uint64_t );uint32_t nb_args; -struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS ]; +struct rte_bpf_arg args[RTE_BPF_FUNC_MAX_ARGS ];/**< Function arguments descriptions. */ struct rte_bpf_arg ret;/**< function return value. */ } func;
@@ -135,7 +150,7 @@ struct rte_bpf_prm_ex {/** program origin parameters, member in use depends on origin */ union {struct { -const struct ebpf_insn *ins;/**< eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ } raw;struct {
@@ -157,7 +172,7 @@ struct rte_bpf_prm_ex {/**< array of external symbols that eBPF code is allowed to reference */ uint32_t nb_xsym;/**< number of elements in xsym */ -struct rte_bpf_arg prog_arg[EBPF_FUNC_MAX_ARGS ];/**< program arguments */ +struct rte_bpf_arg prog_arg[RTE_BPF_FUNC_MAX_ARGS ];/**< program arguments */ uint32_t nb_prog_arg;/**< program argument count */ /* Validate debug instance. */
@@ -168,7 +183,7 @@ struct rte_bpf_prm_ex {* Input parameters for loading eBPF code, legacy version. */ struct rte_bpf_prm { -const struct ebpf_insn *ins;/**< array of eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< array of eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ const struct rte_bpf_xsym *xsym;/**< array of external symbols that eBPF code is allowed to reference */
@@ -217,7 +232,7 @@ struct rte_bpf_jit_ex {/* Tuple of eBPF program arguments. */ struct rte_bpf_prog_ctx { -union rte_bpf_func_arg arg[EBPF_FUNC_MAX_ARGS ]; +union rte_bpf_func_arg arg[RTE_BPF_FUNC_MAX_ARGS ]; };struct rte_bpf ;
@@ -420,7 +435,7 @@ rte_bpf_get_jit_ex(const struct rte_bpf *bpf, struct rte_bpf_jit_ex *jit);*/ __rte_experimental bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins); +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins);/** * Print eBPF instruction into a buffer.
@@ -443,7 +458,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins);*/ __rte_experimental int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags);/**
@@ -457,7 +472,7 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins,* Number of BPF instructions to dump. */ void -rte_bpf_dump (FILE *f,const struct ebpf_insn *buf,uint32_t len); +rte_bpf_dump (FILE *f,const struct rte_ebpf_insn *buf,uint32_t len);struct bpf_program ;
lib/bpf/rte_bpf_validate_debug.h +4 -4
@@ -13,7 +13,7 @@* Can be used for debugging BPF validation problems as well as in tests. */ -#include <bpf_def.h> +#include <rte_bpf.h> #include <rte_compat.h> #include <stdbool.h>
@@ -181,7 +181,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug)__rte_experimental intrte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins); +const struct rte_ebpf_insn **ins,uint32_t *nb_ins);/** * Get last triggered breakpoint or catchpoint.
@@ -249,7 +249,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug__rte_experimental intrte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/** * Get possible truth values of the specified jump condition.
@@ -269,7 +269,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug,__rte_experimental intrte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/** * Format information about specified register for the user.
Signature · 1 line
2.43.0
Re: [PATCH v3 1/1] bpf: make bpf_def.h private
Apologies, sent the wrong version; please ignore. Will post v4 tomorrow.
v4 cover bpf_def.h cleanups
In reply to Marat KhaliliThe goal of this patch is to clarify the public/private status of the eBPF definitions and prevent name conflicts. It achieves this by moving the required public symbols into the public ``rte_bpf.h`` header with a proper ``RTE_`` prefix, and making the remaining ``bpf_def.h`` header private.
v4: reposting verbatim after additional tests involving external apps.
v3:
* Dropped part 2 (renaming macros) as there was no consensus on it.
* Added a release notes entry detailing the API change (bpf_def.h becoming private and public symbols moved to rte_bpf.h).
v2:
* Following the AI suggestion renamed RTE_EBPF_FUNC_MAX_ARGS to RTE_BPF_FUNC_MAX_ARGS.
* Rebased on fresh main hoping to overcome the unrelated CI issues.
* Cautiously re-posting without the RFC label.
Marat Khalili (1):
bpf: make bpf_def.h private
app/test/test_bpf.c | 79 +++++++++++++------------- app/test/test_bpf_validate.c | 74 ++++++++++++------------ doc/guides/rel_notes/release_26_11.rst | 6 ++ lib/bpf/bpf_convert.c | 38 ++++++------- lib/bpf/bpf_def.h | 15 ----- lib/bpf/bpf_dump.c | 13 +++-- lib/bpf/bpf_exec.c | 8 +-- lib/bpf/bpf_impl.h | 3 +- lib/bpf/bpf_jit_arm64.c | 4 +- lib/bpf/bpf_jit_x86.c | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 10 ++-- lib/bpf/bpf_validate.c | 44 +++++++------- lib/bpf/bpf_validate.h | 6 +- lib/bpf/bpf_validate_debug.c | 6 +- lib/bpf/meson.build | 1 - lib/bpf/rte_bpf.h | 33 ++++++++--- lib/bpf/rte_bpf_validate_debug.h | 8 +-- 18 files changed, 180 insertions(+), 172 deletions(-)
Signature · 1 line
2.43.0
PATCH v4 1/1 bpf: make bpf_def.h private
From: Marat Khalili <[email protected]>
Both bpf_def.h header file and the symbols it defined were not previously prefixed with rte_, creating an opportunity for name conflicts. Status of the file itself (private or public) was unclear.
Move public symbols after adding the necessary prefix (rte_ebpf_insn and RTE_BPF_FUNC_MAX_ARGS) into the public header file rte_bpf.h, and make the rest private.
--- app/test/test_bpf.c | 79 +++++++++++++------------- app/test/test_bpf_validate.c | 74 ++++++++++++------------ doc/guides/rel_notes/release_26_11.rst | 6 ++ lib/bpf/bpf_convert.c | 38 ++++++------- lib/bpf/bpf_def.h | 15 ----- lib/bpf/bpf_dump.c | 13 +++-- lib/bpf/bpf_exec.c | 8 +-- lib/bpf/bpf_impl.h | 3 +- lib/bpf/bpf_jit_arm64.c | 4 +- lib/bpf/bpf_jit_x86.c | 2 +- lib/bpf/bpf_load.c | 2 +- lib/bpf/bpf_load_elf.c | 10 ++-- lib/bpf/bpf_validate.c | 44 +++++++------- lib/bpf/bpf_validate.h | 6 +- lib/bpf/bpf_validate_debug.c | 6 +- lib/bpf/meson.build | 1 - lib/bpf/rte_bpf.h | 33 ++++++++--- lib/bpf/rte_bpf_validate_debug.h | 8 +-- 18 files changed, 180 insertions(+), 172 deletions(-)
app/test/test_bpf.c +40 -39
@@ -16,6 +16,7 @@#include <rte_byteorder.h> #include <rte_errno.h> +#include "bpf_def.h" #include "test.h" #if !defined(RTE_LIB_BPF )
@@ -52,7 +53,7 @@ test_bpf(void)* TEST_SUCCESS on success, error code on failure. */ static int -bpf_load_test (uint32_t nb_ins,const struct ebpf_insn *ins,int expected_errno) +bpf_load_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,int expected_errno) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -87,7 +88,7 @@ bpf_load_test(uint32_t nb_ins, const struct ebpf_insn *ins, int expected_errno)static int test_no_instructions (void ) { -static const struct ebpf_insn ins[] = {}; +static const struct rte_ebpf_insn ins[] = {};return bpf_load_test (RTE_DIM (ins), ins,EINVAL ); }
@@ -100,7 +101,7 @@ REGISTER_FAST_TEST(bpf_no_instructions_autotest, NOHUGE_OK, ASAN_OK, test_no_insstatic int test_exit_only (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_EXIT ), },
@@ -117,7 +118,7 @@ REGISTER_FAST_TEST(bpf_exit_only_autotest, NOHUGE_OK, ASAN_OK, test_exit_only);static int test_no_exit (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -136,7 +137,7 @@ REGISTER_FAST_TEST(bpf_no_exit_autotest, NOHUGE_OK, ASAN_OK, test_no_exit);static int test_minimal_working (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -158,7 +159,7 @@ REGISTER_FAST_TEST(bpf_minimal_working_autotest, NOHUGE_OK, ASAN_OK, test_minimastatic int test_add_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to one. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -186,7 +187,7 @@ REGISTER_FAST_TEST(bpf_add_one_autotest, NOHUGE_OK, ASAN_OK, test_add_one);static int test_subtract_one (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Subtract one from the program argument. */ .code = (EBPF_ALU64 |BPF_SUB |BPF_K ),
@@ -214,7 +215,7 @@ REGISTER_FAST_TEST(bpf_subtract_one_autotest, NOHUGE_OK, ASAN_OK, test_subtract_static int test_jump_over_invalid_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Jump over the next instruction for some r1. */ .code = (BPF_JMP |BPF_JEQ |BPF_K ),
@@ -251,7 +252,7 @@ REGISTER_FAST_TEST(bpf_jump_over_invalid_first_autotest, NOHUGE_OK, ASAN_OK,static int test_jump_over_invalid_non_first (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set return value to the program argument. */ .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -401,7 +402,7 @@ dummy_prepare(void *arg) }/* store immediate test-cases */ -static const struct ebpf_insn test_store1_prog[] = { +static const struct rte_ebpf_insn test_store1_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_1 ,
@@ -464,7 +465,7 @@ test_store1_check(uint64_t rc, const void *arg) }/* store register test-cases */ -static const struct ebpf_insn test_store2_prog[] = { +static const struct rte_ebpf_insn test_store2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -507,7 +508,7 @@ static const struct ebpf_insn test_store2_prog[] = { };/* load test-cases */ -static const struct ebpf_insn test_load1_prog[] = { +static const struct rte_ebpf_insn test_load1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_B ),
@@ -584,7 +585,7 @@ test_load1_check(uint64_t rc, const void *arg) }/* load immediate test-cases */ -static const struct ebpf_insn test_ldimm1_prog[] = { +static const struct rte_ebpf_insn test_ldimm1_prog[] = { { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -672,7 +673,7 @@ test_ldimm1_check(uint64_t rc, const void *arg)/* alu mul test-cases */ -static const struct ebpf_insn test_mul1_prog[] = { +static const struct rte_ebpf_insn test_mul1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -784,7 +785,7 @@ test_mul1_check(uint64_t rc, const void *arg) }/* alu shift test-cases */ -static const struct ebpf_insn test_shift1_prog[] = { +static const struct rte_ebpf_insn test_shift1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -979,7 +980,7 @@ test_shift1_check(uint64_t rc, const void *arg) }/* jmp test-cases */ -static const struct ebpf_insn test_jump1_prog[] = { +static const struct rte_ebpf_insn test_jump1_prog[] = { [0 ] = { .code = (BPF_ALU |EBPF_MOV |BPF_K ),
@@ -1188,7 +1189,7 @@ test_jump1_check(uint64_t rc, const void *arg) }/* Jump test case - check ip4_dest in particular subnet */ -static const struct ebpf_insn test_jump2_prog[] = { +static const struct rte_ebpf_insn test_jump2_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1353,7 +1354,7 @@ test_jump2_check(uint64_t rc, const void *arg) }/* alu (add, sub, and, or, xor, neg) test-cases */ -static const struct ebpf_insn test_alu1_prog[] = { +static const struct rte_ebpf_insn test_alu1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -1535,7 +1536,7 @@ test_alu1_check(uint64_t rc, const void *arg) }/* endianness conversions (BE->LE/LE->BE) test-cases */ -static const struct ebpf_insn test_bele1_prog[] = { +static const struct rte_ebpf_insn test_bele1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_H ),
@@ -1701,7 +1702,7 @@ test_bele1_check(uint64_t rc, const void *arg) }/* atomic add test-cases */ -static const struct ebpf_insn test_xadd1_prog[] = { +static const struct rte_ebpf_insn test_xadd1_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -1889,7 +1890,7 @@ test_xadd1_check(uint64_t rc, const void *arg) }/* alu div test-cases */ -static const struct ebpf_insn test_div1_prog[] = { +static const struct rte_ebpf_insn test_div1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2013,7 +2014,7 @@ test_div1_check(uint64_t rc, const void *arg) }/* call test-cases */ -static const struct ebpf_insn test_call1_prog[] = { +static const struct rte_ebpf_insn test_call1_prog[] = { { .code = (BPF_LDX |BPF_MEM |BPF_W ),
@@ -2138,7 +2139,7 @@ static const struct rte_bpf_xsym test_call1_xsym[] = { }, }; -static const struct ebpf_insn test_call2_prog[] = { +static const struct rte_ebpf_insn test_call2_prog[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_X ),
@@ -2264,7 +2265,7 @@ static const struct rte_bpf_xsym test_call2_xsym[] = { }, }; -static const struct ebpf_insn test_call3_prog[] = { +static const struct rte_ebpf_insn test_call3_prog[] = { { .code = (BPF_JMP |EBPF_CALL ),
@@ -2377,7 +2378,7 @@ static const struct rte_bpf_xsym test_call3_xsym[] = { };/* Test for stack corruption in multiple function calls */ -static const struct ebpf_insn test_call4_prog[] = { +static const struct rte_ebpf_insn test_call4_prog[] = { { .code = (BPF_ST |BPF_MEM |BPF_B ), .dst_reg =EBPF_REG_10 ,
@@ -2550,7 +2551,7 @@ static const struct rte_bpf_xsym test_call4_xsym[] = { };/* string compare test case */ -static const struct ebpf_insn test_call5_prog[] = { +static const struct rte_ebpf_insn test_call5_prog[] = { [0 ] = { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ),
@@ -2758,7 +2759,7 @@ static const struct rte_bpf_xsym test_call5_xsym[] = { };/* load mbuf (BPF_ABS/BPF_IND) test-cases */ -static const struct ebpf_insn test_ld_mbuf1_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf1_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3016,7 +3017,7 @@ test_ld_mbuf2_check(uint64_t rc, const void *arg) }/* same as test_ld_mbuf1, but now store intermediate results on the stack */ -static const struct ebpf_insn test_ld_mbuf3_prog[] = { +static const struct rte_ebpf_insn test_ld_mbuf3_prog[] = {/* BPF_ABS/BPF_IND implicitly expect mbuf ptr in R6 */ {
@@ -3165,7 +3166,7 @@ static const struct ebpf_insn test_ld_mbuf3_prog[] = { };/* divide INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_udiv_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_udiv_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3197,7 +3198,7 @@ test_int64min_udiv_uint64max_check(uint64_t rc, const void *arg) }/* modulo INT64_MIN by -1 */ -static const struct ebpf_insn test_int64min_umod_uint64max_prog[] = { +static const struct rte_ebpf_insn test_int64min_umod_uint64max_prog[] = {/* Load INT64_MIN into r0 */ { .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -3652,7 +3653,7 @@ REGISTER_FAST_TEST(bpf_load_null_autotest, NOHUGE_OK, ASAN_OK, test_bpf_load_nulstatic int test_bpf_exec_wrong_nb_prog_arg (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3694,7 +3695,7 @@ REGISTER_FAST_TEST(bpf_exec_wrong_nb_prog_arg_autotest, NOHUGE_OK, ASAN_OK,static int test_bpf_exec_wrong_flags (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (EBPF_ALU64 |EBPF_MOV |BPF_K ), .dst_reg =EBPF_REG_0 , .imm =0 }, { .code = (BPF_JMP |EBPF_EXIT ), } };
@@ -3757,7 +3758,7 @@ typedef uint64_t (*text_xfunc_t)(uint64_t argument);static int call_from_bpf_test (text_xfunc_t xfunc) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { { .code = (BPF_JMP |EBPF_CALL ), .imm =0 ,/* xsym #0 */
@@ -4935,7 +4936,7 @@ static const struct xchg_arg xchg_input = {/* Run program against xchg_input and compare output value with expected. */ static int -run_xchg_test (uint32_t nb_ins,const struct ebpf_insn *ins,struct xchg_arg expected) +run_xchg_test (uint32_t nb_ins,const struct rte_ebpf_insn *ins,struct xchg_arg expected) {const struct rte_bpf_prm prm = { .ins = ins,
@@ -5002,7 +5003,7 @@ run_xchg_test(uint32_t nb_ins, const struct ebpf_insn *ins, struct xchg_arg expestatic int test_xadd32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5082,7 +5083,7 @@ REGISTER_FAST_TEST(bpf_xadd32_autotest, NOHUGE_OK, ASAN_OK, test_xadd32);static int test_xadd64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r0 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5148,7 +5149,7 @@ REGISTER_FAST_TEST(bpf_xadd64_autotest, NOHUGE_OK, ASAN_OK, test_xadd64);static int test_xchg32 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5243,7 +5244,7 @@ REGISTER_FAST_TEST(bpf_xchg32_autotest, NOHUGE_OK, ASAN_OK, test_xchg32);static int test_xchg64 (void ) { -static const struct ebpf_insn ins[] = { +static const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
@@ -5306,7 +5307,7 @@ REGISTER_FAST_TEST(bpf_xchg64_autotest, NOHUGE_OK, ASAN_OK, test_xchg64);static int test_atomic_imm (int32_t imm,bool is_valid) { -const struct ebpf_insn ins[] = { +const struct rte_ebpf_insn ins[] = { {/* Set r2 to return value. */ .code = (BPF_LD |BPF_IMM |EBPF_DW ),
app/test/test_bpf_validate.c +37 -37
286 lines not on this page · raw message
doc/guides/rel_notes/release_26_11.rst +6 -0
@@ -95,6 +95,12 @@ API Changes Also, make sure to start the actual text at the margin. ======================================================= +* bpf: Made the ``bpf_def.h`` header file private, so eBPF instruction opcodes + are no longer publicly available (their numerical values follow the RFC and + e.g. Linux headers). The definition of the instruction struct and number of + program arguments were moved to ``rte_bpf.h`` and gained the public ``RTE_`` + prefix: ``struct rte_ebpf_insn`` and ``RTE_BPF_FUNC_MAX_ARGS``. + * eventdev: Promoted the following API from experimental to stable: * Rx adapter: ``rte_event_eth_rx_adapter_create_ext_with_params``,
lib/bpf/bpf_convert.c +19 -19
@@ -82,7 +82,7 @@/* ALU ops on registers, bpf_add|sub|...: dst_reg += src_reg */ #define EBPF_ALU64_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -90,7 +90,7 @@ .imm = 0 })#define BPF_ALU32_REG (OP ,DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -100,7 +100,7 @@/* ALU ops on immediates, bpf_add|sub|...: dst_reg += imm32 */ #define BPF_ALU32_IMM (OP ,DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -110,7 +110,7 @@/* Short form of mov, dst_reg = src_reg */ #define BPF_MOV64_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = EBPF_ALU64 | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -118,7 +118,7 @@ .imm = 0 })#define BPF_MOV32_REG (DST ,SRC ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_X, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -128,7 +128,7 @@/* Short form of mov, dst_reg = imm32 */ #define BPF_MOV32_IMM (DST ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -138,7 +138,7 @@/* Short form of mov based on type, BPF_X: dst_reg = src_reg, BPF_K: dst_reg = imm32 */ #define BPF_MOV32_RAW (TYPE ,DST ,SRC ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_ALU | EBPF_MOV | BPF_SRC(TYPE), \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -148,7 +148,7 @@/* Direct packet access, R0 = *(uint *) (skb->data + imm32) */ #define BPF_LD_ABS (SIZE ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LD | BPF_SIZE(SIZE) | BPF_ABS, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -158,7 +158,7 @@/* Memory load, dst_reg = *(uint *) (src_reg + off16) */ #define BPF_LDX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_LDX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -168,7 +168,7 @@/* Memory store, *(uint *) (dst_reg + off16) = src_reg */ #define BPF_STX_MEM (SIZE ,DST ,SRC ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_STX | BPF_SIZE(SIZE) | BPF_MEM, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -178,7 +178,7 @@/* Conditional jumps against immediates, if (dst_reg 'op' imm32) goto pc + off16 */ #define BPF_JMP_IMM (OP ,DST ,IMM ,OFF ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | BPF_OP(OP) | BPF_K, \ .dst_reg = DST, \ .src_reg = 0, \
@@ -188,7 +188,7 @@/* Raw code statement block */ #define BPF_RAW_INSN (CODE ,DST ,SRC ,OFF ,IMM ) \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = CODE, \ .dst_reg = DST, \ .src_reg = SRC, \
@@ -198,7 +198,7 @@/* Program exit */ #define BPF_EXIT_INSN () \ - ((struct ebpf_insn) { \ + ((struct rte_ebpf_insn) { \ .code = BPF_JMP | EBPF_EXIT, \ .dst_reg = 0, \ .src_reg = 0, \
@@ -210,7 +210,7 @@* If and when DPDK BPF supports them. */ static bool convert_bpf_load (const struct bpf_insn *fp, - struct ebpf_insn **new_insnp __rte_unused) + struct rte_ebpf_insn **new_insnp __rte_unused) {switch (fp->k) {case SKF_AD_OFF +SKF_AD_PROTOCOL :
@@ -240,11 +240,11 @@ static bool convert_bpf_load(const struct bpf_insn *fp, }static int bpf_convert_filter (const struct bpf_insn *prog,size_t len, -struct ebpf_insn *new_prog,uint32_t *new_len) +struct rte_ebpf_insn *new_prog,uint32_t *new_len) {unsigned int pass =0 ;size_t new_flen =0 , target, i; -struct ebpf_insn *new_insn; +struct rte_ebpf_insn *new_insn;const struct bpf_insn *fp;int *addrs =NULL ;uint8_t bpf_src;
@@ -284,8 +284,8 @@ static int bpf_convert_filter(const struct bpf_insn *prog, size_t len, }for (i =0 ; i < len; fp++, i++) { -struct ebpf_insn tmp_insns[6 ] = { }; -struct ebpf_insn *insn = tmp_insns; +struct rte_ebpf_insn tmp_insns[6 ] = { }; +struct rte_ebpf_insn *insn = tmp_insns;if (addrs) addrs[i] = new_insn - new_prog;
@@ -526,7 +526,7 @@ struct rte_bpf_prm * rte_bpf_convert(const struct bpf_program *prog) {struct rte_bpf_prm *prm =NULL ; -struct ebpf_insn *ebpf =NULL ; +struct rte_ebpf_insn *ebpf =NULL ;uint32_t ebpf_len =0 ;int ret;
lib/bpf/bpf_def.h +0 -15
@@ -129,20 +129,5 @@ enum {*/ #define EBPF_PSEUDO_CALL EBPF_REG_1 -/* -* eBPF instruction format -*/ -struct ebpf_insn { -uint8_t code; -uint8_t dst_reg:4 ; -uint8_t src_reg:4 ; -int16_t off; -int32_t imm; -}; - -/* -* eBPF allows functions with R1-R5 as arguments. -*/ -#define EBPF_FUNC_MAX_ARGS (EBPF_REG_6 - EBPF_REG_1)#endif /* RTE_BPF_DEF_H_ */
lib/bpf/bpf_dump.c +7 -6
@@ -9,6 +9,7 @@#include <eal_export.h> #include "rte_bpf.h" +#include "bpf_def.h" #define BPF_OP_INDEX (x) (BPF_OP(x) >> 4)#define BPF_SIZE_INDEX (x) (BPF_SIZE(x) >> 3)
@@ -48,7 +49,7 @@ static const char *const jump_tbl[16] = { RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_insn_is_wide, 26.07)bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins) +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins) {return ins->code == (BPF_LD |BPF_IMM |EBPF_DW ); }
@@ -56,7 +57,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins)/* Format one (possibly wide) eBPF command as hexadecimal in objdump format. */ static int -format_hexadecimal (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_hexadecimal (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t flags) {const char *const b = (const char *)ins;
@@ -93,7 +94,7 @@ atomic_op(int32_t imm)/* Format one (possibly wide) eBPF command as assembler. */ static int -format_disassembly (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +format_disassembly (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {uint8_t cls =BPF_CLASS (ins->code);
@@ -221,7 +222,7 @@ format_disassembly(char *buffer, size_t bufsz, const struct ebpf_insn *ins, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_format, 26.07)int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags) {if ((flags &RTE_BPF_FORMAT_FLAG_HEXADECIMAL ) !=0 )
@@ -231,13 +232,13 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins, }RTE_EXPORT_SYMBOL (rte_bpf_dump) -void rte_bpf_dump(FILE *f, const struct ebpf_insn *buf, uint32_t len) +void rte_bpf_dump(FILE *f, const struct rte_ebpf_insn *buf, uint32_t len) {uint32_t i;char buffer[256 ];for (i =0 ; i < len; ++i) { -const struct ebpf_insn *ins = buf + i; +const struct rte_ebpf_insn *ins = buf + i; format_disassembly(buffer, sizeof(buffer), ins, i, RTE_BPF_FORMAT_FLAG_DISASSEMBLY |
lib/bpf/bpf_exec.c +4 -4
@@ -108,7 +108,7 @@static inline void -bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_be (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -127,7 +127,7 @@ bpf_alu_be(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins) }static inline void -bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct ebpf_insn *ins) +bpf_alu_le (uint64_t reg[EBPF_REG_NUM ],const struct rte_ebpf_insn *ins) {uint64_t *v;
@@ -147,7 +147,7 @@ bpf_alu_le(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins)static inline const void *bpf_ld_mbuf (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ], -const struct ebpf_insn *ins,uint32_t off,uint32_t len) +const struct rte_ebpf_insn *ins,uint32_t off,uint32_t len) {const struct rte_mbuf *mb;const void *p;
@@ -165,7 +165,7 @@ bpf_ld_mbuf(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM],static inline uint64_t bpf_exec (const struct rte_bpf *bpf,uint64_t reg[EBPF_REG_NUM ]) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;for (ins = bpf->prm.raw.ins; ; ins++) {switch (ins->code) {
lib/bpf/bpf_impl.h +2 -1
@@ -7,6 +7,7 @@#include <rte_bpf.h> #include <sys/mman.h> +#include "bpf_def.h" #define MAX_BPF_STACK_SIZE 0x200
@@ -22,7 +23,7 @@ struct __rte_bpf_load {struct rte_bpf_prm_ex prm;/* Conversion from cBPF. */ -struct ebpf_insn *ins; +struct rte_ebpf_insn *ins;/* Loading ELF and applying relocations. */ int elf_fd;/* ELF fd, must be negative (not zero) by default. */
lib/bpf/bpf_jit_arm64.c +2 -2
@@ -1126,7 +1126,7 @@ emit_branch(struct a64_jit_ctx *ctx, uint8_t op, uint32_t i, int16_t off)static void check_program_has_call (struct a64_jit_ctx *ctx,struct rte_bpf *bpf) { -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint8_t op;uint32_t i;
@@ -1150,7 +1150,7 @@ static int emit(struct a64_jit_ctx *ctx, struct rte_bpf *bpf) { uint8_t op, dst, src, tmp1, tmp2, tmp3; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;uint64_t u64;int16_t off;int32_t imm;
lib/bpf/bpf_jit_x86.c +1 -1
@@ -1315,7 +1315,7 @@ static int emit(struct bpf_jit_state *st, const struct rte_bpf *bpf) { uint32_t i, dr, op, sr; -const struct ebpf_insn *ins; +const struct rte_ebpf_insn *ins;/* reset state fields */ st->sz =0 ;
lib/bpf/bpf_load.c +1 -1
@@ -61,7 +61,7 @@ bpf_check_xsym(const struct rte_bpf_xsym *xsym)return -EINVAL ; }else if (xsym->type ==RTE_BPF_XTYPE_FUNC ) { -if (xsym->func.nb_args >EBPF_FUNC_MAX_ARGS ) +if (xsym->func.nb_args >RTE_BPF_FUNC_MAX_ARGS )return -EINVAL ;/* check function arguments */
lib/bpf/bpf_load_elf.c +5 -5
@@ -58,7 +58,7 @@ bpf_find_xsym(const char *sn, enum rte_bpf_xtype type,* symbol *sn* */ static int -resolve_xsym (const char *sn,size_t ofs,struct ebpf_insn *ins,size_t ins_sz, +resolve_xsym (const char *sn,size_t ofs,struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {uint32_t idx, fidx;
@@ -169,7 +169,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx) sd =elf_getdata (sc,NULL );if (sd ==NULL || sd->d_size ==0 || - sd->d_size %sizeof (struct ebpf_insn ) !=0 ) { + sd->d_size %sizeof (struct rte_ebpf_insn ) !=0 ) { rc =elf_errno ();RTE_BPF_LOG_LINE (ERR ,"%s(%p, %s) error code: %d(%s)" , __func__, elf, section, rc,elf_errmsg (rc));
@@ -186,7 +186,7 @@ find_elf_code(Elf *elf, const char *section, Elf_Data **psd, size_t *pidx)*/ static int process_reloc (Elf *elf,size_t sym_idx,Elf64_Rel *re,size_t re_sz, -struct ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) +struct rte_ebpf_insn *ins,size_t ins_sz,const struct rte_bpf_prm_ex *prm) {int32_t rc;uint32_t i, n;
@@ -235,7 +235,7 @@ process_reloc(Elf *elf, size_t sym_idx, Elf64_Rel *re, size_t re_sz,* and update bpf code. */ static int -elf_reloc_code (Elf *elf,struct ebpf_insn *ins,size_t ins_sz,size_t sidx, +elf_reloc_code (Elf *elf,struct rte_ebpf_insn *ins,size_t ins_sz,size_t sidx,const struct rte_bpf_prm_ex *prm) {Elf64_Rel *re;
@@ -355,7 +355,7 @@ __rte_bpf_load_elf_code(struct __rte_bpf_load *load) prm->origin =RTE_BPF_ORIGIN_RAW ; prm->raw.ins = sd->d_buf; - prm->raw.nb_ins = sd->d_size /sizeof (struct ebpf_insn ); + prm->raw.nb_ins = sd->d_size /sizeof (struct rte_ebpf_insn ); rc =elf_reloc_code (load->elf, sd->d_buf, sd->d_size, sidx, prm);if (rc <0 )
lib/bpf/bpf_validate.c +22 -22
166 lines not on this page · raw message
lib/bpf/bpf_validate.h +3 -3
@@ -11,7 +11,7 @@* Internal-use headers for eBPF validation observability. */ -#include <bpf_def.h> +#include <rte_bpf.h> #ifdef __cplusplusextern "C" {
@@ -32,12 +32,12 @@ __rte_bpf_validate_state_is_valid(const struct bpf_verifier *verifier);*/ int __rte_bpf_validate_can_access (const struct bpf_verifier *verifier, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/* Get possible truth values of the specified jump condition. */ int __rte_bpf_validate_may_jump (const struct bpf_verifier *verifier, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/* Format known information about the register for the user. */ int
lib/bpf/bpf_validate_debug.c +3 -3
@@ -319,7 +319,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug) RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_get_ins, 26.07)int rte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins) +const struct rte_ebpf_insn **ins,uint32_t *nb_ins) {if (debug ==NULL )return -EINVAL ;
@@ -378,7 +378,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_can_access, 26.07)int rte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64) +const struct rte_ebpf_insn *access,uint64_t off64) {if (debug ==NULL || access ==NULL )return -EINVAL ;
@@ -392,7 +392,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug, RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_bpf_validate_debug_may_jump, 26.07)int rte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64) +const struct rte_ebpf_insn *jump,uint64_t imm64) {if (debug ==NULL || jump ==NULL )return -EINVAL ;
lib/bpf/meson.build +0 -1
@@ -35,7 +35,6 @@ elif dpdk_conf.has('RTE_ARCH_ARM64') endif headers = files( - 'bpf_def.h', 'rte_bpf.h', 'rte_bpf_ethdev.h', 'rte_bpf_validate_debug.h',
lib/bpf/rte_bpf.h +24 -9
@@ -19,12 +19,27 @@#include <rte_common.h> #include <rte_mbuf.h> #include <rte_malloc.h> -#include <bpf_def.h> #ifdef __cplusplusextern "C" {#endif +/* +* eBPF instruction format +*/ +struct rte_ebpf_insn { +uint8_t code; +uint8_t dst_reg:4 ; +uint8_t src_reg:4 ; +int16_t off; +int32_t imm; +}; + +/* +* eBPF allows functions with up to 5 arguments. +*/ +#define RTE_BPF_FUNC_MAX_ARGS 5 +#define RTE_BPF_EXEC_FLAG_JIT RTE_BIT64(0)/**< use JIT-compiled version */ /** Mask with all supported `RTE_BPF_EXEC_FLAG_*` flags set. */
@@ -96,7 +111,7 @@ struct rte_bpf_xsym {uint64_t (*val)(uint64_t ,uint64_t ,uint64_t ,uint64_t ,uint64_t );uint32_t nb_args; -struct rte_bpf_arg args[EBPF_FUNC_MAX_ARGS ]; +struct rte_bpf_arg args[RTE_BPF_FUNC_MAX_ARGS ];/**< Function arguments descriptions. */ struct rte_bpf_arg ret;/**< function return value. */ } func;
@@ -135,7 +150,7 @@ struct rte_bpf_prm_ex {/** program origin parameters, member in use depends on origin */ union {struct { -const struct ebpf_insn *ins;/**< eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ } raw;struct {
@@ -157,7 +172,7 @@ struct rte_bpf_prm_ex {/**< array of external symbols that eBPF code is allowed to reference */ uint32_t nb_xsym;/**< number of elements in xsym */ -struct rte_bpf_arg prog_arg[EBPF_FUNC_MAX_ARGS ];/**< program arguments */ +struct rte_bpf_arg prog_arg[RTE_BPF_FUNC_MAX_ARGS ];/**< program arguments */ uint32_t nb_prog_arg;/**< program argument count */ /* Validate debug instance. */
@@ -168,7 +183,7 @@ struct rte_bpf_prm_ex {* Input parameters for loading eBPF code, legacy version. */ struct rte_bpf_prm { -const struct ebpf_insn *ins;/**< array of eBPF instructions */ +const struct rte_ebpf_insn *ins;/**< array of eBPF instructions */ uint32_t nb_ins;/**< number of instructions in ins */ const struct rte_bpf_xsym *xsym;/**< array of external symbols that eBPF code is allowed to reference */
@@ -217,7 +232,7 @@ struct rte_bpf_jit_ex {/* Tuple of eBPF program arguments. */ struct rte_bpf_prog_ctx { -union rte_bpf_func_arg arg[EBPF_FUNC_MAX_ARGS ]; +union rte_bpf_func_arg arg[RTE_BPF_FUNC_MAX_ARGS ]; };struct rte_bpf ;
@@ -420,7 +435,7 @@ rte_bpf_get_jit_ex(const struct rte_bpf *bpf, struct rte_bpf_jit_ex *jit);*/ __rte_experimental bool -rte_bpf_insn_is_wide (const struct ebpf_insn *ins); +rte_bpf_insn_is_wide (const struct rte_ebpf_insn *ins);/** * Print eBPF instruction into a buffer.
@@ -443,7 +458,7 @@ rte_bpf_insn_is_wide(const struct ebpf_insn *ins);*/ __rte_experimental int -rte_bpf_format (char *buffer,size_t bufsz,const struct ebpf_insn *ins, +rte_bpf_format (char *buffer,size_t bufsz,const struct rte_ebpf_insn *ins,uint32_t pc,uint32_t flags);/**
@@ -457,7 +472,7 @@ rte_bpf_format(char *buffer, size_t bufsz, const struct ebpf_insn *ins,* Number of BPF instructions to dump. */ void -rte_bpf_dump (FILE *f,const struct ebpf_insn *buf,uint32_t len); +rte_bpf_dump (FILE *f,const struct rte_ebpf_insn *buf,uint32_t len);struct bpf_program ;
lib/bpf/rte_bpf_validate_debug.h +4 -4
@@ -13,7 +13,7 @@* Can be used for debugging BPF validation problems as well as in tests. */ -#include <bpf_def.h> +#include <rte_bpf.h> #include <rte_compat.h> #include <stdbool.h>
@@ -181,7 +181,7 @@ rte_bpf_validate_debug_get_bpf_param(const struct rte_bpf_validate_debug *debug)__rte_experimental intrte_bpf_validate_debug_get_ins (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn **ins,uint32_t *nb_ins); +const struct rte_ebpf_insn **ins,uint32_t *nb_ins);/** * Get last triggered breakpoint or catchpoint.
@@ -249,7 +249,7 @@ rte_bpf_validate_debug_get_validation_result(const struct rte_bpf_validate_debug__rte_experimental intrte_bpf_validate_debug_can_access (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *access,uint64_t off64); +const struct rte_ebpf_insn *access,uint64_t off64);/** * Get possible truth values of the specified jump condition.
@@ -269,7 +269,7 @@ rte_bpf_validate_debug_can_access(const struct rte_bpf_validate_debug *debug,__rte_experimental intrte_bpf_validate_debug_may_jump (const struct rte_bpf_validate_debug *debug, -const struct ebpf_insn *jump,uint64_t imm64); +const struct rte_ebpf_insn *jump,uint64_t imm64);/** * Format information about specified register for the user.
Signature · 1 line
2.43.0
Re: [PATCH v4 1/1] bpf: make bpf_def.h private
|Recheck-request: |iol-unit-arm64-testing
Re: [PATCH v4 1/1] bpf: make bpf_def.h private
In reply to Marat Khalili|Recheck-request: rebase=main, |iol-unit-arm64-testing
Re: [PATCH v4 1/1] bpf: make bpf_def.h private
In reply to Marat KhaliliError in ci/iol-unit-arm64-testing does not seem to be related to the patch because it is a different test that fails, and identical v3 successfully passed CI before.
Thomas Monjalon
AppliedRe: [PATCH v4 1/1] bpf: make bpf_def.h private
In reply to Marat Khalili18/09/2026 11:21, Marat Khalili:
Quoted 6 lines
From: Marat Khalili <[email protected]>
Both
bpf_def.hheader file and the symbols it defined were not previously prefixed withrte_, creating an opportunity for name conflicts. Status of the file itself (private or public) was unclear.
Quoted 6 lines
Move public symbols after adding the necessary prefix (
rte_ebpf_insnandRTE_BPF_FUNC_MAX_ARGS) into the public header filerte_bpf.h, and make the rest private.Signed-off-by Marat Khalili <[email protected]>
Applied, thanks.