Commit bfee64de authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Alexei Starovoitov

nfp: bpf: add map deletes from the datapath

Support calling map_delete_elem() FW helper from the datapath
programs.  For JIT checks and code are basically equivalent
to map lookups.  Similarly to other map helper key must be on
the stack.  Different pointer types are left for future extension.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: default avatarJiong Wang <jiong.wang@netronome.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 44d65a47
...@@ -2329,6 +2329,7 @@ static int call(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -2329,6 +2329,7 @@ static int call(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
return adjust_head(nfp_prog, meta); return adjust_head(nfp_prog, meta);
case BPF_FUNC_map_lookup_elem: case BPF_FUNC_map_lookup_elem:
case BPF_FUNC_map_update_elem: case BPF_FUNC_map_update_elem:
case BPF_FUNC_map_delete_elem:
return map_call_stack_common(nfp_prog, meta); return map_call_stack_common(nfp_prog, meta);
default: default:
WARN_ONCE(1, "verifier allowed unsupported function\n"); WARN_ONCE(1, "verifier allowed unsupported function\n");
...@@ -3216,6 +3217,9 @@ void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv) ...@@ -3216,6 +3217,9 @@ void *nfp_bpf_relo_for_vnic(struct nfp_prog *nfp_prog, struct nfp_bpf_vnic *bv)
case BPF_FUNC_map_update_elem: case BPF_FUNC_map_update_elem:
val = nfp_prog->bpf->helpers.map_update; val = nfp_prog->bpf->helpers.map_update;
break; break;
case BPF_FUNC_map_delete_elem:
val = nfp_prog->bpf->helpers.map_delete;
break;
default: default:
pr_err("relocation of unknown helper %d\n", pr_err("relocation of unknown helper %d\n",
val); val);
......
...@@ -287,6 +287,9 @@ nfp_bpf_parse_cap_func(struct nfp_app_bpf *bpf, void __iomem *value, u32 length) ...@@ -287,6 +287,9 @@ nfp_bpf_parse_cap_func(struct nfp_app_bpf *bpf, void __iomem *value, u32 length)
case BPF_FUNC_map_update_elem: case BPF_FUNC_map_update_elem:
bpf->helpers.map_update = readl(&cap->func_addr); bpf->helpers.map_update = readl(&cap->func_addr);
break; break;
case BPF_FUNC_map_delete_elem:
bpf->helpers.map_delete = readl(&cap->func_addr);
break;
} }
return 0; return 0;
......
...@@ -129,6 +129,7 @@ enum pkt_vec { ...@@ -129,6 +129,7 @@ enum pkt_vec {
* @helpers: helper addressess for various calls * @helpers: helper addressess for various calls
* @helpers.map_lookup: map lookup helper address * @helpers.map_lookup: map lookup helper address
* @helpers.map_update: map update helper address * @helpers.map_update: map update helper address
* @helpers.map_delete: map delete helper address
*/ */
struct nfp_app_bpf { struct nfp_app_bpf {
struct nfp_app *app; struct nfp_app *app;
...@@ -164,6 +165,7 @@ struct nfp_app_bpf { ...@@ -164,6 +165,7 @@ struct nfp_app_bpf {
struct { struct {
u32 map_lookup; u32 map_lookup;
u32 map_update; u32 map_update;
u32 map_delete;
} helpers; } helpers;
}; };
......
...@@ -201,6 +201,14 @@ nfp_bpf_check_call(struct nfp_prog *nfp_prog, struct bpf_verifier_env *env, ...@@ -201,6 +201,14 @@ nfp_bpf_check_call(struct nfp_prog *nfp_prog, struct bpf_verifier_env *env,
!nfp_bpf_stack_arg_ok("map_update", env, reg3, NULL)) !nfp_bpf_stack_arg_ok("map_update", env, reg3, NULL))
return -EOPNOTSUPP; return -EOPNOTSUPP;
break; break;
case BPF_FUNC_map_delete_elem:
if (!nfp_bpf_map_call_ok("map_delete", env, meta,
bpf->helpers.map_delete, reg1) ||
!nfp_bpf_stack_arg_ok("map_delete", env, reg2,
meta->func_id ? &meta->arg2 : NULL))
return -EOPNOTSUPP;
break;
default: default:
pr_vlog(env, "unsupported function id: %d\n", func_id); pr_vlog(env, "unsupported function id: %d\n", func_id);
return -EOPNOTSUPP; return -EOPNOTSUPP;
......
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