Lines Matching refs:reg

17 #define BPF_JMP_CND_REG(reg, ins, op, type)	\  argument
19 ((type)(reg)[(ins)->dst_reg] op (type)(reg)[(ins)->src_reg]) ? \
22 #define BPF_JMP_CND_IMM(reg, ins, op, type) \ argument
24 ((type)(reg)[(ins)->dst_reg] op (type)(ins)->imm) ? \
27 #define BPF_NEG_ALU(reg, ins, type) \ argument
28 ((reg)[(ins)->dst_reg] = (type)(-(reg)[(ins)->dst_reg]))
30 #define EBPF_MOV_ALU_REG(reg, ins, type) \ argument
31 ((reg)[(ins)->dst_reg] = (type)(reg)[(ins)->src_reg])
33 #define BPF_OP_ALU_REG(reg, ins, op, type) \ argument
34 ((reg)[(ins)->dst_reg] = \
35 (type)(reg)[(ins)->dst_reg] op (type)(reg)[(ins)->src_reg])
37 #define EBPF_MOV_ALU_IMM(reg, ins, type) \ argument
38 ((reg)[(ins)->dst_reg] = (type)(ins)->imm)
40 #define BPF_OP_ALU_IMM(reg, ins, op, type) \ argument
41 ((reg)[(ins)->dst_reg] = \
42 (type)(reg)[(ins)->dst_reg] op (type)(ins)->imm)
44 #define BPF_DIV_ZERO_CHECK(bpf, reg, ins, type) do { \ argument
45 if ((type)(reg)[(ins)->src_reg] == 0) { \
54 #define BPF_LD_REG(reg, ins, type) \ argument
55 ((reg)[(ins)->dst_reg] = \
56 *(type *)(uintptr_t)((reg)[(ins)->src_reg] + (ins)->off))
58 #define BPF_ST_IMM(reg, ins, type) \ argument
59 (*(type *)(uintptr_t)((reg)[(ins)->dst_reg] + (ins)->off) = \
62 #define BPF_ST_REG(reg, ins, type) \ argument
63 (*(type *)(uintptr_t)((reg)[(ins)->dst_reg] + (ins)->off) = \
64 (type)(reg)[(ins)->src_reg])
66 #define BPF_ST_XADD_REG(reg, ins, tp) \ argument
68 (uintptr_t)((reg)[(ins)->dst_reg] + (ins)->off), \
69 reg[ins->src_reg]))
75 #define BPF_LD_ABS(bpf, reg, ins, type, op) do { \ argument
76 const type *p = bpf_ld_mbuf(bpf, reg, ins, (ins)->imm, sizeof(type)); \
79 reg[EBPF_REG_0] = op(p[0]); \
82 #define BPF_LD_IND(bpf, reg, ins, type, op) do { \ argument
83 uint32_t ofs = reg[ins->src_reg] + (ins)->imm; \
84 const type *p = bpf_ld_mbuf(bpf, reg, ins, ofs, sizeof(type)); \
87 reg[EBPF_REG_0] = op(p[0]); \
92 bpf_alu_be(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins) in bpf_alu_be()
96 v = reg + ins->dst_reg; in bpf_alu_be()
111 bpf_alu_le(uint64_t reg[EBPF_REG_NUM], const struct ebpf_insn *ins) in bpf_alu_le()
115 v = reg + ins->dst_reg; in bpf_alu_le()
130 bpf_ld_mbuf(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM], in bpf_ld_mbuf()
136 mb = (const struct rte_mbuf *)(uintptr_t)reg[EBPF_REG_6]; in bpf_ld_mbuf()
137 p = rte_pktmbuf_read(mb, off, len, reg + EBPF_REG_0); in bpf_ld_mbuf()
147 bpf_exec(const struct rte_bpf *bpf, uint64_t reg[EBPF_REG_NUM]) in bpf_exec()
155 BPF_OP_ALU_IMM(reg, ins, +, uint32_t); in bpf_exec()
158 BPF_OP_ALU_IMM(reg, ins, -, uint32_t); in bpf_exec()
161 BPF_OP_ALU_IMM(reg, ins, &, uint32_t); in bpf_exec()
164 BPF_OP_ALU_IMM(reg, ins, |, uint32_t); in bpf_exec()
167 BPF_OP_ALU_IMM(reg, ins, <<, uint32_t); in bpf_exec()
170 BPF_OP_ALU_IMM(reg, ins, >>, uint32_t); in bpf_exec()
173 BPF_OP_ALU_IMM(reg, ins, ^, uint32_t); in bpf_exec()
176 BPF_OP_ALU_IMM(reg, ins, *, uint32_t); in bpf_exec()
179 BPF_OP_ALU_IMM(reg, ins, /, uint32_t); in bpf_exec()
182 BPF_OP_ALU_IMM(reg, ins, %, uint32_t); in bpf_exec()
185 EBPF_MOV_ALU_IMM(reg, ins, uint32_t); in bpf_exec()
189 BPF_OP_ALU_REG(reg, ins, +, uint32_t); in bpf_exec()
192 BPF_OP_ALU_REG(reg, ins, -, uint32_t); in bpf_exec()
195 BPF_OP_ALU_REG(reg, ins, &, uint32_t); in bpf_exec()
198 BPF_OP_ALU_REG(reg, ins, |, uint32_t); in bpf_exec()
201 BPF_OP_ALU_REG(reg, ins, <<, uint32_t); in bpf_exec()
204 BPF_OP_ALU_REG(reg, ins, >>, uint32_t); in bpf_exec()
207 BPF_OP_ALU_REG(reg, ins, ^, uint32_t); in bpf_exec()
210 BPF_OP_ALU_REG(reg, ins, *, uint32_t); in bpf_exec()
213 BPF_DIV_ZERO_CHECK(bpf, reg, ins, uint32_t); in bpf_exec()
214 BPF_OP_ALU_REG(reg, ins, /, uint32_t); in bpf_exec()
217 BPF_DIV_ZERO_CHECK(bpf, reg, ins, uint32_t); in bpf_exec()
218 BPF_OP_ALU_REG(reg, ins, %, uint32_t); in bpf_exec()
221 EBPF_MOV_ALU_REG(reg, ins, uint32_t); in bpf_exec()
224 BPF_NEG_ALU(reg, ins, uint32_t); in bpf_exec()
227 bpf_alu_be(reg, ins); in bpf_exec()
230 bpf_alu_le(reg, ins); in bpf_exec()
234 BPF_OP_ALU_IMM(reg, ins, +, uint64_t); in bpf_exec()
237 BPF_OP_ALU_IMM(reg, ins, -, uint64_t); in bpf_exec()
240 BPF_OP_ALU_IMM(reg, ins, &, uint64_t); in bpf_exec()
243 BPF_OP_ALU_IMM(reg, ins, |, uint64_t); in bpf_exec()
246 BPF_OP_ALU_IMM(reg, ins, <<, uint64_t); in bpf_exec()
249 BPF_OP_ALU_IMM(reg, ins, >>, uint64_t); in bpf_exec()
252 BPF_OP_ALU_IMM(reg, ins, >>, int64_t); in bpf_exec()
255 BPF_OP_ALU_IMM(reg, ins, ^, uint64_t); in bpf_exec()
258 BPF_OP_ALU_IMM(reg, ins, *, uint64_t); in bpf_exec()
261 BPF_OP_ALU_IMM(reg, ins, /, uint64_t); in bpf_exec()
264 BPF_OP_ALU_IMM(reg, ins, %, uint64_t); in bpf_exec()
267 EBPF_MOV_ALU_IMM(reg, ins, uint64_t); in bpf_exec()
271 BPF_OP_ALU_REG(reg, ins, +, uint64_t); in bpf_exec()
274 BPF_OP_ALU_REG(reg, ins, -, uint64_t); in bpf_exec()
277 BPF_OP_ALU_REG(reg, ins, &, uint64_t); in bpf_exec()
280 BPF_OP_ALU_REG(reg, ins, |, uint64_t); in bpf_exec()
283 BPF_OP_ALU_REG(reg, ins, <<, uint64_t); in bpf_exec()
286 BPF_OP_ALU_REG(reg, ins, >>, uint64_t); in bpf_exec()
289 BPF_OP_ALU_REG(reg, ins, >>, int64_t); in bpf_exec()
292 BPF_OP_ALU_REG(reg, ins, ^, uint64_t); in bpf_exec()
295 BPF_OP_ALU_REG(reg, ins, *, uint64_t); in bpf_exec()
298 BPF_DIV_ZERO_CHECK(bpf, reg, ins, uint64_t); in bpf_exec()
299 BPF_OP_ALU_REG(reg, ins, /, uint64_t); in bpf_exec()
302 BPF_DIV_ZERO_CHECK(bpf, reg, ins, uint64_t); in bpf_exec()
303 BPF_OP_ALU_REG(reg, ins, %, uint64_t); in bpf_exec()
306 EBPF_MOV_ALU_REG(reg, ins, uint64_t); in bpf_exec()
309 BPF_NEG_ALU(reg, ins, uint64_t); in bpf_exec()
313 BPF_LD_REG(reg, ins, uint8_t); in bpf_exec()
316 BPF_LD_REG(reg, ins, uint16_t); in bpf_exec()
319 BPF_LD_REG(reg, ins, uint32_t); in bpf_exec()
322 BPF_LD_REG(reg, ins, uint64_t); in bpf_exec()
326 reg[ins->dst_reg] = (uint32_t)ins[0].imm | in bpf_exec()
332 BPF_LD_ABS(bpf, reg, ins, uint8_t, NOP); in bpf_exec()
335 BPF_LD_ABS(bpf, reg, ins, uint16_t, rte_be_to_cpu_16); in bpf_exec()
338 BPF_LD_ABS(bpf, reg, ins, uint32_t, rte_be_to_cpu_32); in bpf_exec()
342 BPF_LD_IND(bpf, reg, ins, uint8_t, NOP); in bpf_exec()
345 BPF_LD_IND(bpf, reg, ins, uint16_t, rte_be_to_cpu_16); in bpf_exec()
348 BPF_LD_IND(bpf, reg, ins, uint32_t, rte_be_to_cpu_32); in bpf_exec()
352 BPF_ST_REG(reg, ins, uint8_t); in bpf_exec()
355 BPF_ST_REG(reg, ins, uint16_t); in bpf_exec()
358 BPF_ST_REG(reg, ins, uint32_t); in bpf_exec()
361 BPF_ST_REG(reg, ins, uint64_t); in bpf_exec()
364 BPF_ST_IMM(reg, ins, uint8_t); in bpf_exec()
367 BPF_ST_IMM(reg, ins, uint16_t); in bpf_exec()
370 BPF_ST_IMM(reg, ins, uint32_t); in bpf_exec()
373 BPF_ST_IMM(reg, ins, uint64_t); in bpf_exec()
377 BPF_ST_XADD_REG(reg, ins, 32); in bpf_exec()
380 BPF_ST_XADD_REG(reg, ins, 64); in bpf_exec()
388 BPF_JMP_CND_IMM(reg, ins, ==, uint64_t); in bpf_exec()
391 BPF_JMP_CND_IMM(reg, ins, !=, uint64_t); in bpf_exec()
394 BPF_JMP_CND_IMM(reg, ins, >, uint64_t); in bpf_exec()
397 BPF_JMP_CND_IMM(reg, ins, <, uint64_t); in bpf_exec()
400 BPF_JMP_CND_IMM(reg, ins, >=, uint64_t); in bpf_exec()
403 BPF_JMP_CND_IMM(reg, ins, <=, uint64_t); in bpf_exec()
406 BPF_JMP_CND_IMM(reg, ins, >, int64_t); in bpf_exec()
409 BPF_JMP_CND_IMM(reg, ins, <, int64_t); in bpf_exec()
412 BPF_JMP_CND_IMM(reg, ins, >=, int64_t); in bpf_exec()
415 BPF_JMP_CND_IMM(reg, ins, <=, int64_t); in bpf_exec()
418 BPF_JMP_CND_IMM(reg, ins, &, uint64_t); in bpf_exec()
422 BPF_JMP_CND_REG(reg, ins, ==, uint64_t); in bpf_exec()
425 BPF_JMP_CND_REG(reg, ins, !=, uint64_t); in bpf_exec()
428 BPF_JMP_CND_REG(reg, ins, >, uint64_t); in bpf_exec()
431 BPF_JMP_CND_REG(reg, ins, <, uint64_t); in bpf_exec()
434 BPF_JMP_CND_REG(reg, ins, >=, uint64_t); in bpf_exec()
437 BPF_JMP_CND_REG(reg, ins, <=, uint64_t); in bpf_exec()
440 BPF_JMP_CND_REG(reg, ins, >, int64_t); in bpf_exec()
443 BPF_JMP_CND_REG(reg, ins, <, int64_t); in bpf_exec()
446 BPF_JMP_CND_REG(reg, ins, >=, int64_t); in bpf_exec()
449 BPF_JMP_CND_REG(reg, ins, <=, int64_t); in bpf_exec()
452 BPF_JMP_CND_REG(reg, ins, &, uint64_t); in bpf_exec()
456 reg[EBPF_REG_0] = bpf->prm.xsym[ins->imm].func.val( in bpf_exec()
457 reg[EBPF_REG_1], reg[EBPF_REG_2], in bpf_exec()
458 reg[EBPF_REG_3], reg[EBPF_REG_4], in bpf_exec()
459 reg[EBPF_REG_5]); in bpf_exec()
463 return reg[EBPF_REG_0]; in bpf_exec()
483 uint64_t reg[EBPF_REG_NUM]; in rte_bpf_exec_burst() local
488 reg[EBPF_REG_1] = (uintptr_t)ctx[i]; in rte_bpf_exec_burst()
489 reg[EBPF_REG_10] = (uintptr_t)(stack + RTE_DIM(stack)); in rte_bpf_exec_burst()
491 rc[i] = bpf_exec(bpf, reg); in rte_bpf_exec_burst()