/* For relocation logic use up-most byte of branch instruction as scratch * area. Remember to clear this before sending instructions to HW!
*/ #define OP_RELO_TYPE 0xff00000000000000ULL
enum nfp_relo_type {
RELO_NONE = 0, /* standard internal jumps */
RELO_BR_REL, /* internal jumps to parts of the outro */
RELO_BR_GO_OUT,
RELO_BR_GO_ABORT,
RELO_BR_GO_CALL_PUSH_REGS,
RELO_BR_GO_CALL_POP_REGS, /* external jumps to fixed addresses */
RELO_BR_NEXT_PKT,
RELO_BR_HELPER, /* immediate relocation against load address */
RELO_IMMED_REL,
};
/* To make absolute relocated branches (branches other than RELO_BR_REL) * distinguishable in user space dumps from normal jumps, add a large offset * to them.
*/ #define BR_OFF_RELO 15000
enum static_regs {
STATIC_REG_IMMA = 20, /* Bank AB */
STATIC_REG_IMM = 21, /* Bank AB */
STATIC_REG_STACK = 22, /* Bank A */
STATIC_REG_PKT_LEN = 22, /* Bank B */
};
/** * struct nfp_app_bpf - bpf app priv structure * @app: backpointer to the app * @ccm: common control message handler data * * @bpf_dev: BPF offload device handle * * @cmsg_key_sz: size of key in cmsg element array * @cmsg_val_sz: size of value in cmsg element array * * @map_list: list of offloaded maps * @maps_in_use: number of currently offloaded maps * @map_elems_in_use: number of elements allocated to offloaded maps * * @maps_neutral: hash table of offload-neutral maps (on pointer) * * @abi_version: global BPF ABI version * @cmsg_cache_cnt: number of entries to read for caching * * @adjust_head: adjust head capability * @adjust_head.flags: extra flags for adjust head * @adjust_head.off_min: minimal packet offset within buffer required * @adjust_head.off_max: maximum packet offset within buffer required * @adjust_head.guaranteed_sub: negative adjustment guaranteed possible * @adjust_head.guaranteed_add: positive adjustment guaranteed possible * * @maps: map capability * @maps.types: supported map types * @maps.max_maps: max number of maps supported * @maps.max_elems: max number of entries in each map * @maps.max_key_sz: max size of map key * @maps.max_val_sz: max size of map value * @maps.max_elem_sz: max size of map entry (key + value) * * @helpers: helper addressess for various calls * @helpers.map_lookup: map lookup helper address * @helpers.map_update: map update helper address * @helpers.map_delete: map delete helper address * @helpers.perf_event_output: output perf event to a ring buffer * * @pseudo_random: FW initialized the pseudo-random machinery (CSRs) * @queue_select: BPF can set the RX queue ID in packet vector * @adjust_tail: BPF can simply trunc packet size for adjust tail * @cmsg_multi_ent: FW can pack multiple map entries in a single cmsg
*/ struct nfp_app_bpf { struct nfp_app *app; struct nfp_ccm ccm;
/** * struct nfp_bpf_map - private per-map data attached to BPF maps for offload * @offmap: pointer to the offloaded BPF map * @bpf: back pointer to bpf app private structure * @tid: table id identifying map on datapath * * @cache_lock: protects @cache_blockers, @cache_to, @cache * @cache_blockers: number of ops in flight which block caching * @cache_gen: counter incremented by every blocker on exit * @cache_to: time when cache will no longer be valid (ns) * @cache: skb with cached response * * @l: link on the nfp_app_bpf->map_list list * @use_map: map of how the value is used (in 4B chunks)
*/ struct nfp_bpf_map { struct bpf_offloaded_map *offmap; struct nfp_app_bpf *bpf;
u32 tid;
/** * struct nfp_bpf_reg_state - register state for calls * @reg: BPF register state from latest path * @var_off: for stack arg - changes stack offset on different paths
*/ struct nfp_bpf_reg_state { struct bpf_reg_state reg; bool var_off;
};
#define FLAG_INSN_IS_JUMP_DST BIT(0) #define FLAG_INSN_IS_SUBPROG_START BIT(1) #define FLAG_INSN_PTR_CALLER_STACK_FRAME BIT(2) /* Instruction is pointless, noop even on its own */ #define FLAG_INSN_SKIP_NOOP BIT(3) /* Instruction is optimized out based on preceding instructions */ #define FLAG_INSN_SKIP_PREC_DEPENDENT BIT(4) /* Instruction is optimized by the verifier */ #define FLAG_INSN_SKIP_VERIFIER_OPT BIT(5) /* Instruction needs to zero extend to high 32-bit */ #define FLAG_INSN_DO_ZEXT BIT(6)
/** * struct nfp_insn_meta - BPF instruction wrapper * @insn: BPF instruction * @ptr: pointer type for memory operations * @ldst_gather_len: memcpy length gathered from load/store sequence * @paired_st: the paired store insn at the head of the sequence * @ptr_not_const: pointer is not always constant * @pkt_cache: packet data cache information * @pkt_cache.range_start: start offset for associated packet data cache * @pkt_cache.range_end: end offset for associated packet data cache * @pkt_cache.do_init: this read needs to initialize packet data cache * @xadd_over_16bit: 16bit immediate is not guaranteed * @xadd_maybe_16bit: 16bit immediate is possible * @jmp_dst: destination info for jump instructions * @jump_neg_op: jump instruction has inverted immediate, use ADD instead of SUB * @num_insns_after_br: number of insns following a branch jump, used for fixup * @func_id: function id for call instructions * @arg1: arg1 for call instructions * @arg2: arg2 for call instructions * @umin_src: copy of core verifier umin_value for src opearnd. * @umax_src: copy of core verifier umax_value for src operand. * @umin_dst: copy of core verifier umin_value for dst opearnd. * @umax_dst: copy of core verifier umax_value for dst operand. * @off: index of first generated machine instruction (in nfp_prog.prog) * @n: eBPF instruction number * @flags: eBPF instruction extra optimization flags * @subprog_idx: index of subprogram to which the instruction belongs * @double_cb: callback for second part of the instruction * @l: link on nfp_prog->insns list
*/ struct nfp_insn_meta { struct bpf_insn insn; union { /* pointer ops (ld/st/xadd) */ struct { struct bpf_reg_state ptr; struct bpf_insn *paired_st;
s16 ldst_gather_len; bool ptr_not_const; struct {
s16 range_start;
s16 range_end; bool do_init;
} pkt_cache; bool xadd_over_16bit; bool xadd_maybe_16bit;
}; /* jump */ struct { struct nfp_insn_meta *jmp_dst; bool jump_neg_op;
u32 num_insns_after_br; /* only for BPF-to-BPF calls */
}; /* function calls */ struct {
u32 func_id; struct bpf_reg_state arg1; struct nfp_bpf_reg_state arg2;
}; /* We are interested in range info for operands of ALU * operations. For example, shift amount, multiplicand and * multiplier etc.
*/ struct {
u64 umin_src;
u64 umax_src;
u64 umin_dst;
u64 umax_dst;
};
}; unsignedint off; unsignedshort n; unsignedshort flags; unsignedshort subprog_idx;
instr_cb_t double_cb;
/** * struct nfp_bpf_subprog_info - nfp BPF sub-program (a.k.a. function) info * @stack_depth: maximum stack depth used by this sub-program * @needs_reg_push: whether sub-program uses callee-saved registers
*/ struct nfp_bpf_subprog_info {
u16 stack_depth;
u8 needs_reg_push : 1;
};
/** * struct nfp_prog - nfp BPF program * @bpf: backpointer to the bpf app priv structure * @prog: machine code * @prog_len: number of valid instructions in @prog array * @__prog_alloc_len: alloc size of @prog array * @stack_size: total amount of stack used * @verifier_meta: temporary storage for verifier's insn meta * @type: BPF program type * @last_bpf_off: address of the last instruction translated from BPF * @tgt_out: jump target for normal exit * @tgt_abort: jump target for abort (e.g. access outside of packet buffer) * @tgt_call_push_regs: jump target for subroutine for saving R6~R9 to stack * @tgt_call_pop_regs: jump target for subroutine used for restoring R6~R9 * @n_translated: number of successfully translated instructions (for errors) * @error: error code if something went wrong * @stack_frame_depth: max stack depth for current frame * @adjust_head_location: if program has single adjust head call - the insn no. * @map_records_cnt: the number of map pointers recorded for this prog * @subprog_cnt: number of sub-programs, including main function * @map_records: the map record pointers from bpf->maps_neutral * @subprog: pointer to an array of objects holding info about sub-programs * @n_insns: number of instructions on @insns list * @insns: list of BPF instruction wrappers (struct nfp_insn_meta)
*/ struct nfp_prog { struct nfp_app_bpf *bpf;
/** * struct nfp_bpf_vnic - per-vNIC BPF priv structure * @tc_prog: currently loaded cls_bpf program * @start_off: address of the first instruction in the memory * @tgt_done: jump target to get the next packet
*/ struct nfp_bpf_vnic { struct bpf_prog *tc_prog; unsignedint start_off; unsignedint tgt_done;
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.