Skip to content

Commit 79660ff

Browse files
mdouchametan-ucw
authored andcommitted
Add some 32-bit instruction macros to BPF LAPI
Signed-off-by: Martin Doucha <[email protected]> Reviewed-by: Cyril Hrubis <[email protected]>
1 parent f41766d commit 79660ff

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

include/lapi/bpf.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ enum bpf_func_id {
449449
.off = 0, \
450450
.imm = 0 })
451451

452+
#define BPF_ALU32_REG(OP, DST, SRC) \
453+
((struct bpf_insn) { \
454+
.code = BPF_ALU | BPF_OP(OP) | BPF_X, \
455+
.dst_reg = DST, \
456+
.src_reg = SRC, \
457+
.off = 0, \
458+
.imm = 0 })
459+
452460
#define BPF_ALU64_IMM(OP, DST, IMM) \
453461
((struct bpf_insn) { \
454462
.code = BPF_ALU64 | BPF_OP(OP) | BPF_K, \
@@ -457,6 +465,14 @@ enum bpf_func_id {
457465
.off = 0, \
458466
.imm = IMM })
459467

468+
#define BPF_ALU32_IMM(OP, DST, IMM) \
469+
((struct bpf_insn) { \
470+
.code = BPF_ALU | BPF_OP(OP) | BPF_K, \
471+
.dst_reg = DST, \
472+
.src_reg = 0, \
473+
.off = 0, \
474+
.imm = IMM })
475+
460476
#define BPF_MOV64_REG(DST, SRC) \
461477
((struct bpf_insn) { \
462478
.code = BPF_ALU64 | BPF_MOV | BPF_X, \
@@ -465,6 +481,14 @@ enum bpf_func_id {
465481
.off = 0, \
466482
.imm = 0 })
467483

484+
#define BPF_MOV32_REG(DST, SRC) \
485+
((struct bpf_insn) { \
486+
.code = BPF_ALU | BPF_MOV | BPF_X, \
487+
.dst_reg = DST, \
488+
.src_reg = SRC, \
489+
.off = 0, \
490+
.imm = 0 })
491+
468492
#define BPF_LD_IMM64(DST, IMM) \
469493
BPF_LD_IMM64_RAW(DST, 0, IMM)
470494

0 commit comments

Comments
 (0)