diff mbox

[net-next,4/4] net/sched: cls_bpf: Use skip flags to reflect HW offload status

Message ID 20170210141933.6e51418e@cakuba.netronome.com
State RFC, archived
Delegated to: David Miller
Headers show

Commit Message

Jakub Kicinski Feb. 10, 2017, 10:19 p.m. UTC
On Thu,  9 Feb 2017 16:18:08 +0200, Or Gerlitz wrote:
> Currently there is no way of querying whether a filter is
> offloaded to HW or not when using both policy (no flag).
> 
> Reuse the skip flags to show the insertion status by setting
> the skip_hw flag in case the filter wasn't offloaded.
> 
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>

FWIW I tested this one and it works.  I also tested this version which
would take advantage of @offloaded:

Comments

Or Gerlitz Feb. 12, 2017, 10:01 a.m. UTC | #1
On Sat, Feb 11, 2017 at 12:19 AM, Jakub Kicinski
<jakub.kicinski@netronome.com> wrote:

> FWIW I tested this one and it works.  I also tested this version which
> would take advantage of @offloaded:

I assume that if we go on the existing suggestion, the below is what
you prefer,
so I will pick it up, let know if you think otherwise.


> diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
> index d9c97018317d..51d464f991ff 100644
> --- a/net/sched/cls_bpf.c
> +++ b/net/sched/cls_bpf.c
> @@ -568,8 +568,8 @@ static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
>                         struct sk_buff *skb, struct tcmsg *tm)
>  {
>         struct cls_bpf_prog *prog = (struct cls_bpf_prog *) fh;
> +       u32 gen_flags, bpf_flags = 0;
>         struct nlattr *nest;
> -       u32 bpf_flags = 0;
>         int ret;
>
>         if (prog == NULL)
> @@ -601,8 +601,11 @@ static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
>                 bpf_flags |= TCA_BPF_FLAG_ACT_DIRECT;
>         if (bpf_flags && nla_put_u32(skb, TCA_BPF_FLAGS, bpf_flags))
>                 goto nla_put_failure;
> -       if (prog->gen_flags &&
> -           nla_put_u32(skb, TCA_BPF_FLAGS_GEN, prog->gen_flags))
> +
> +       gen_flags = prog->gen_flags;
> +       if (!prog->offloaded)
> +               gen_flags |= TCA_CLS_FLAGS_SKIP_HW;
> +       if (gen_flags && nla_put_u32(skb, TCA_BPF_FLAGS_GEN, gen_flags))
>                 goto nla_put_failure;
>
>         nla_nest_end(skb, nest);
diff mbox

Patch

diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index d9c97018317d..51d464f991ff 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -568,8 +568,8 @@  static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
 			struct sk_buff *skb, struct tcmsg *tm)
 {
 	struct cls_bpf_prog *prog = (struct cls_bpf_prog *) fh;
+	u32 gen_flags, bpf_flags = 0;
 	struct nlattr *nest;
-	u32 bpf_flags = 0;
 	int ret;
 
 	if (prog == NULL)
@@ -601,8 +601,11 @@  static int cls_bpf_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
 		bpf_flags |= TCA_BPF_FLAG_ACT_DIRECT;
 	if (bpf_flags && nla_put_u32(skb, TCA_BPF_FLAGS, bpf_flags))
 		goto nla_put_failure;
-	if (prog->gen_flags &&
-	    nla_put_u32(skb, TCA_BPF_FLAGS_GEN, prog->gen_flags))
+
+	gen_flags = prog->gen_flags;
+	if (!prog->offloaded)
+		gen_flags |= TCA_CLS_FLAGS_SKIP_HW;
+	if (gen_flags && nla_put_u32(skb, TCA_BPF_FLAGS_GEN, gen_flags))
 		goto nla_put_failure;
 
 	nla_nest_end(skb, nest);