From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net, daniel@iogearbox.net,
alexei.starovoitov@gmail.com, netdev@vger.kernel.org
Cc: dsahern@gmail.com, oss-drivers@netronome.com, jiri@resnulli.us,
john.fastabend@gmail.com, jhs@mojatatu.com, gerlitz.or@gmail.com,
aring@mojatatu.com, xiyou.wangcong@gmail.com,
Quentin Monnet <quentin.monnet@netronome.com>
Subject: [PATCH bpf-next 10/11] netdevsim: add extack support for TC eBPF offload
Date: Mon, 15 Jan 2018 16:30:26 -0800 [thread overview]
Message-ID: <20180116003027.9405-11-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180116003027.9405-1-jakub.kicinski@netronome.com>
From: Quentin Monnet <quentin.monnet@netronome.com>
Use the recently added extack support for TC eBPF filters in netdevsim.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
drivers/net/netdevsim/bpf.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
diff --git a/drivers/net/netdevsim/bpf.c b/drivers/net/netdevsim/bpf.c
index 5134d5c1306c..0de8ba91b262 100644
--- a/drivers/net/netdevsim/bpf.c
+++ b/drivers/net/netdevsim/bpf.c
@@ -109,17 +109,35 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,
struct netdevsim *ns = cb_priv;
struct bpf_prog *oldprog;
- if (type != TC_SETUP_CLSBPF ||
- !tc_can_offload(ns->netdev) ||
- cls_bpf->common.protocol != htons(ETH_P_ALL) ||
- cls_bpf->common.chain_index)
+ if (type != TC_SETUP_CLSBPF) {
+ NSIM_EA(cls_bpf->common.extack,
+ "only offload of BPF classifiers supported");
+ 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 (cls_bpf->common.chain_index)
return -EOPNOTSUPP;
- if (!ns->bpf_tc_accept)
+ 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 */
- 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;
+ }
if (cls_bpf->command != TC_CLSBPF_OFFLOAD)
return -EOPNOTSUPP;
@@ -131,8 +149,11 @@ int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type,
oldprog = NULL;
if (!cls_bpf->prog)
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 nsim_bpf_offload(ns, cls_bpf->prog, oldprog);
--
2.15.1
next prev parent reply other threads:[~2018-01-16 0:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-16 0:30 [PATCH bpf-next 00/11] net: sched: add extack support for cls offload Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 01/11] net: sched: add extack support to change() classifier operation Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 02/11] net: sched: prepare extack support for offload via tc_cls_common_offload Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 03/11] net: sched: cls_flower: propagate extack support for filter offload Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 04/11] net: sched: cls_matchall: " Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 05/11] net: sched: cls_u32: " Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 06/11] net: sched: cls_bpf: plumb extack support in filter for hardware offload Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 07/11] net: sched: create tc_can_offload_extack() wrapper Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 08/11] nfp: bpf: plumb extack into functions related to XDP offload Jakub Kicinski
2018-01-16 0:30 ` [PATCH bpf-next 09/11] nfp: bpf: use extack support to improve debugging Jakub Kicinski
2018-01-16 0:30 ` Jakub Kicinski [this message]
2018-01-16 0:30 ` [PATCH bpf-next 11/11] selftests/bpf: add checks on extack messages for eBPF hw offload tests Jakub Kicinski
2018-01-16 0:49 ` David Ahern
2018-01-16 0:55 ` Jakub Kicinski
2018-01-16 1:02 ` David Ahern
2018-01-16 1:04 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180116003027.9405-11-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=aring@mojatatu.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=gerlitz.or@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=quentin.monnet@netronome.com \
--cc=xiyou.wangcong@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).