Skip to content

Commit 5cecb6c

Browse files
ogerlitzdavem330
authored andcommitted
net/sched: cls_bpf: Reflect HW offload status
BPF classifier support for the "in hw" offloading flags. Signed-off-by: Or Gerlitz <[email protected]> Reviewed-by: Amir Vadai <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 24d3dc6 commit 5cecb6c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

net/sched/cls_bpf.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
148148
struct net_device *dev = tp->q->dev_queue->dev;
149149
struct tc_cls_bpf_offload bpf_offload = {};
150150
struct tc_to_netdev offload;
151+
int err;
151152

152153
offload.type = TC_SETUP_CLSBPF;
153154
offload.cls_bpf = &bpf_offload;
@@ -159,8 +160,13 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
159160
bpf_offload.exts_integrated = prog->exts_integrated;
160161
bpf_offload.gen_flags = prog->gen_flags;
161162

162-
return dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
163-
tp->protocol, &offload);
163+
err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle,
164+
tp->protocol, &offload);
165+
166+
if (!err && (cmd == TC_CLSBPF_ADD || cmd == TC_CLSBPF_REPLACE))
167+
prog->gen_flags |= TCA_CLS_FLAGS_IN_HW;
168+
169+
return err;
164170
}
165171

166172
static int cls_bpf_offload(struct tcf_proto *tp, struct cls_bpf_prog *prog,
@@ -511,6 +517,9 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
511517
return ret;
512518
}
513519

520+
if (!tc_in_hw(prog->gen_flags))
521+
prog->gen_flags |= TCA_CLS_FLAGS_NOT_IN_HW;
522+
514523
if (oldprog) {
515524
list_replace_rcu(&oldprog->link, &prog->link);
516525
tcf_unbind_filter(tp, &oldprog->res);

0 commit comments

Comments
 (0)