Commit 728461f2 authored by Quentin Monnet's avatar Quentin Monnet Committed by David S. Miller

netdevsim: add extack support for TC eBPF offload

Use the recently added extack support for TC eBPF filters in netdevsim.
Signed-off-by: default avatarQuentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 52150464
...@@ -123,17 +123,35 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type, ...@@ -123,17 +123,35 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,
struct netdevsim *ns = cb_priv; struct netdevsim *ns = cb_priv;
struct bpf_prog *oldprog; struct bpf_prog *oldprog;
if (type != TC_SETUP_CLSBPF || if (type != TC_SETUP_CLSBPF) {
!tc_can_offload(ns->netdev) || NSIM_EA(cls_bpf->common.extack,
cls_bpf->common.protocol != htons(ETH_P_ALL) || "only offload of BPF classifiers supported");
cls_bpf->common.chain_index)
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
if (!tc_can_offload_extack(ns->netdev, cls_bpf->common.extack))
return -EOPNOTSUPP;
if (cls_bpf->common.protocol != htons(ETH_P_ALL)) {
NSIM_EA(cls_bpf->common.extack,
"only ETH_P_ALL supported as filter protocol");
return -EOPNOTSUPP;
}
if (!ns->bpf_tc_accept) if (cls_bpf->common.chain_index)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (!ns->bpf_tc_accept) {
NSIM_EA(cls_bpf->common.extack,
"netdevsim configured to reject BPF TC offload");
return -EOPNOTSUPP;
}
/* Note: progs without skip_sw will probably not be dev bound */ /* Note: progs without skip_sw will probably not be dev bound */
if (prog && !prog->aux->offload && !ns->bpf_tc_non_bound_accept) if (prog && !prog->aux->offload && !ns->bpf_tc_non_bound_accept) {
NSIM_EA(cls_bpf->common.extack,
"netdevsim configured to reject unbound programs");
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
if (cls_bpf->command != TC_CLSBPF_OFFLOAD) if (cls_bpf->command != TC_CLSBPF_OFFLOAD)
return -EOPNOTSUPP; return -EOPNOTSUPP;
...@@ -145,9 +163,12 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type, ...@@ -145,9 +163,12 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,
oldprog = NULL; oldprog = NULL;
if (!cls_bpf->prog) if (!cls_bpf->prog)
return 0; return 0;
if (ns->bpf_offloaded) if (ns->bpf_offloaded) {
NSIM_EA(cls_bpf->common.extack,
"driver and netdev offload states mismatch");
return -EBUSY; return -EBUSY;
} }
}
return nsim_bpf_offload(ns, cls_bpf->prog, oldprog); return nsim_bpf_offload(ns, cls_bpf->prog, oldprog);
} }
......
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