|
@@ -43,6 +43,7 @@ struct cls_bpf_prog {
|
|
|
struct tcf_result res;
|
|
|
bool exts_integrated;
|
|
|
u32 gen_flags;
|
|
|
+ unsigned int in_hw_count;
|
|
|
struct tcf_exts exts;
|
|
|
u32 handle;
|
|
|
u16 bpf_num_ops;
|
|
@@ -174,6 +175,7 @@ static int cls_bpf_offload_cmd(struct tcf_proto *tp, struct cls_bpf_prog *prog,
|
|
|
cls_bpf_offload_cmd(tp, oldprog, prog, extack);
|
|
|
return err;
|
|
|
} else if (err > 0) {
|
|
|
+ prog->in_hw_count = err;
|
|
|
tcf_block_offload_inc(block, &prog->gen_flags);
|
|
|
}
|
|
|
}
|
|
@@ -652,6 +654,42 @@ skip:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+static int cls_bpf_reoffload(struct tcf_proto *tp, bool add, tc_setup_cb_t *cb,
|
|
|
+ void *cb_priv, struct netlink_ext_ack *extack)
|
|
|
+{
|
|
|
+ struct cls_bpf_head *head = rtnl_dereference(tp->root);
|
|
|
+ struct tcf_block *block = tp->chain->block;
|
|
|
+ struct tc_cls_bpf_offload cls_bpf = {};
|
|
|
+ struct cls_bpf_prog *prog;
|
|
|
+ int err;
|
|
|
+
|
|
|
+ list_for_each_entry(prog, &head->plist, link) {
|
|
|
+ if (tc_skip_hw(prog->gen_flags))
|
|
|
+ continue;
|
|
|
+
|
|
|
+ tc_cls_common_offload_init(&cls_bpf.common, tp, prog->gen_flags,
|
|
|
+ extack);
|
|
|
+ cls_bpf.command = TC_CLSBPF_OFFLOAD;
|
|
|
+ cls_bpf.exts = &prog->exts;
|
|
|
+ cls_bpf.prog = add ? prog->filter : NULL;
|
|
|
+ cls_bpf.oldprog = add ? NULL : prog->filter;
|
|
|
+ cls_bpf.name = prog->bpf_name;
|
|
|
+ cls_bpf.exts_integrated = prog->exts_integrated;
|
|
|
+
|
|
|
+ err = cb(TC_SETUP_CLSBPF, &cls_bpf, cb_priv);
|
|
|
+ if (err) {
|
|
|
+ if (add && tc_skip_sw(prog->gen_flags))
|
|
|
+ return err;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ tc_cls_offload_cnt_update(block, &prog->in_hw_count,
|
|
|
+ &prog->gen_flags, add);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static struct tcf_proto_ops cls_bpf_ops __read_mostly = {
|
|
|
.kind = "bpf",
|
|
|
.owner = THIS_MODULE,
|
|
@@ -662,6 +700,7 @@ static struct tcf_proto_ops cls_bpf_ops __read_mostly = {
|
|
|
.change = cls_bpf_change,
|
|
|
.delete = cls_bpf_delete,
|
|
|
.walk = cls_bpf_walk,
|
|
|
+ .reoffload = cls_bpf_reoffload,
|
|
|
.dump = cls_bpf_dump,
|
|
|
.bind_class = cls_bpf_bind_class,
|
|
|
};
|