Commit 18e53b6c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: bpf: move to datapath ABI version 2

Datapath ABI version 2 stores the packet information in LMEM
instead of NNRs.  We also have strict restrictions on which
GPRs we can use.  Only GPRs 0-23 are reserved for BPF.

Adjust the static register locations and "ABI" registers.
Note that packet length is packed with other info so we have
to extract it into one of the scratch registers, OTOH since
LMEM can be used in restricted operands we don't have to
extract packet pointer.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 995e101f
...@@ -526,22 +526,22 @@ construct_data_ind_ld(struct nfp_prog *nfp_prog, u16 offset, ...@@ -526,22 +526,22 @@ construct_data_ind_ld(struct nfp_prog *nfp_prog, u16 offset,
emit_alu(nfp_prog, imm_a(nfp_prog), emit_alu(nfp_prog, imm_a(nfp_prog),
imm_a(nfp_prog), ALU_OP_ADD, reg_imm(size)); imm_a(nfp_prog), ALU_OP_ADD, reg_imm(size));
emit_alu(nfp_prog, reg_none(), emit_alu(nfp_prog, reg_none(),
NFP_BPF_ABI_LEN, ALU_OP_SUB, imm_a(nfp_prog)); plen_reg(nfp_prog), ALU_OP_SUB, imm_a(nfp_prog));
wrp_br_special(nfp_prog, BR_BLO, OP_BR_GO_ABORT); wrp_br_special(nfp_prog, BR_BLO, OP_BR_GO_ABORT);
/* Load data */ /* Load data */
emit_cmd(nfp_prog, CMD_TGT_READ8, CMD_MODE_32b, 0, emit_cmd(nfp_prog, CMD_TGT_READ8, CMD_MODE_32b, 0,
pkt_reg(nfp_prog), imm_b(nfp_prog), sz - 1, true); pptr_reg(nfp_prog), imm_b(nfp_prog), sz - 1, true);
} else { } else {
/* Check packet length */ /* Check packet length */
tmp_reg = ur_load_imm_any(nfp_prog, offset + size, tmp_reg = ur_load_imm_any(nfp_prog, offset + size,
imm_a(nfp_prog)); imm_a(nfp_prog));
emit_alu(nfp_prog, reg_none(), emit_alu(nfp_prog, reg_none(),
NFP_BPF_ABI_LEN, ALU_OP_SUB, tmp_reg); plen_reg(nfp_prog), ALU_OP_SUB, tmp_reg);
wrp_br_special(nfp_prog, BR_BLO, OP_BR_GO_ABORT); wrp_br_special(nfp_prog, BR_BLO, OP_BR_GO_ABORT);
/* Load data */ /* Load data */
tmp_reg = re_load_imm_any(nfp_prog, offset, imm_b(nfp_prog)); tmp_reg = re_load_imm_any(nfp_prog, offset, imm_b(nfp_prog));
emit_cmd(nfp_prog, CMD_TGT_READ8, CMD_MODE_32b, 0, emit_cmd(nfp_prog, CMD_TGT_READ8, CMD_MODE_32b, 0,
pkt_reg(nfp_prog), tmp_reg, sz - 1, true); pptr_reg(nfp_prog), tmp_reg, sz - 1, true);
} }
i = 0; i = 0;
...@@ -1024,7 +1024,7 @@ static int mem_ldx4_skb(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -1024,7 +1024,7 @@ static int mem_ldx4_skb(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
{ {
if (meta->insn.off == offsetof(struct sk_buff, len)) if (meta->insn.off == offsetof(struct sk_buff, len))
emit_alu(nfp_prog, reg_both(meta->insn.dst_reg * 2), emit_alu(nfp_prog, reg_both(meta->insn.dst_reg * 2),
reg_none(), ALU_OP_NONE, NFP_BPF_ABI_LEN); reg_none(), ALU_OP_NONE, plen_reg(nfp_prog));
else else
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -1039,12 +1039,12 @@ static int mem_ldx4_xdp(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -1039,12 +1039,12 @@ static int mem_ldx4_xdp(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
meta->insn.off != offsetof(struct xdp_md, data_end)) meta->insn.off != offsetof(struct xdp_md, data_end))
return -EOPNOTSUPP; return -EOPNOTSUPP;
emit_alu(nfp_prog, dst, reg_none(), ALU_OP_NONE, NFP_BPF_ABI_PKT); emit_alu(nfp_prog, dst, reg_none(), ALU_OP_NONE, pptr_reg(nfp_prog));
if (meta->insn.off == offsetof(struct xdp_md, data)) if (meta->insn.off == offsetof(struct xdp_md, data))
return 0; return 0;
emit_alu(nfp_prog, dst, dst, ALU_OP_ADD, NFP_BPF_ABI_LEN); emit_alu(nfp_prog, dst, dst, ALU_OP_ADD, plen_reg(nfp_prog));
return 0; return 0;
} }
...@@ -1403,8 +1403,9 @@ static int nfp_fixup_branches(struct nfp_prog *nfp_prog) ...@@ -1403,8 +1403,9 @@ static int nfp_fixup_branches(struct nfp_prog *nfp_prog)
static void nfp_intro(struct nfp_prog *nfp_prog) static void nfp_intro(struct nfp_prog *nfp_prog)
{ {
emit_alu(nfp_prog, pkt_reg(nfp_prog), wrp_immed(nfp_prog, plen_reg(nfp_prog), GENMASK(13, 0));
reg_none(), ALU_OP_NONE, NFP_BPF_ABI_PKT); emit_alu(nfp_prog, plen_reg(nfp_prog),
plen_reg(nfp_prog), ALU_OP_AND, pv_len(nfp_prog));
} }
static void nfp_outro_tc_legacy(struct nfp_prog *nfp_prog) static void nfp_outro_tc_legacy(struct nfp_prog *nfp_prog)
......
...@@ -54,9 +54,13 @@ enum br_special { ...@@ -54,9 +54,13 @@ enum br_special {
}; };
enum static_regs { enum static_regs {
STATIC_REG_PKT = 1, STATIC_REG_IMM = 21, /* Bank AB */
#define REG_PKT_BANK ALU_DST_A STATIC_REG_PKT_LEN = 22, /* Bank B */
STATIC_REG_IMM = 2, /* Bank AB */ };
enum pkt_vec {
PKT_VEC_PKT_LEN = 0,
PKT_VEC_PKT_PTR = 2,
}; };
enum nfp_bpf_action_type { enum nfp_bpf_action_type {
...@@ -66,15 +70,17 @@ enum nfp_bpf_action_type { ...@@ -66,15 +70,17 @@ enum nfp_bpf_action_type {
NN_ACT_XDP, NN_ACT_XDP,
}; };
#define pkt_reg(np) reg_a((np)->regs_per_thread - STATIC_REG_PKT) #define pv_len(np) reg_lm(1, PKT_VEC_PKT_LEN)
#define imm_a(np) reg_a((np)->regs_per_thread - STATIC_REG_IMM) #define pv_ctm_ptr(np) reg_lm(1, PKT_VEC_PKT_PTR)
#define imm_b(np) reg_b((np)->regs_per_thread - STATIC_REG_IMM)
#define imm_both(np) reg_both((np)->regs_per_thread - STATIC_REG_IMM) #define plen_reg(np) reg_b(STATIC_REG_PKT_LEN)
#define pptr_reg(np) pv_ctm_ptr(np)
#define imm_a(np) reg_a(STATIC_REG_IMM)
#define imm_b(np) reg_b(STATIC_REG_IMM)
#define imm_both(np) reg_both(STATIC_REG_IMM)
#define NFP_BPF_ABI_FLAGS reg_imm(0) #define NFP_BPF_ABI_FLAGS reg_imm(0)
#define NFP_BPF_ABI_FLAG_MARK 1 #define NFP_BPF_ABI_FLAG_MARK 1
#define NFP_BPF_ABI_PKT reg_nnr(2)
#define NFP_BPF_ABI_LEN reg_nnr(3)
struct nfp_prog; struct nfp_prog;
struct nfp_insn_meta; struct nfp_insn_meta;
......
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
* @NFP_NET_CFG_BPF_ADDR: DMA address of the buffer with JITed BPF code * @NFP_NET_CFG_BPF_ADDR: DMA address of the buffer with JITed BPF code
*/ */
#define NFP_NET_CFG_BPF_ABI 0x0080 #define NFP_NET_CFG_BPF_ABI 0x0080
#define NFP_NET_BPF_ABI 1 #define NFP_NET_BPF_ABI 2
#define NFP_NET_CFG_BPF_CAP 0x0081 #define NFP_NET_CFG_BPF_CAP 0x0081
#define NFP_NET_BPF_CAP_RELO (1 << 0) /* seamless reload */ #define NFP_NET_BPF_CAP_RELO (1 << 0) /* seamless reload */
#define NFP_NET_CFG_BPF_MAX_LEN 0x0082 #define NFP_NET_CFG_BPF_MAX_LEN 0x0082
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment