Skip to content

Commit 7968521

Browse files
hadarhenziondavem330
authored andcommitted
net/sched: cls_flower: Try to offload only if skip_hw flag isn't set
Check skip_hw flag isn't set before calling fl_hw_{replace/destroy}_filter and fl_hw_update_stats functions. Replace the call to tc_should_offload with tc_can_offload. tc_can_offload only checks if the device supports offloading, the check for skip_hw flag is done earlier in the flow. Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com> Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 55330f0 commit 7968521

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

net/sched/cls_flower.c

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie)
207207
struct tc_cls_flower_offload offload = {0};
208208
struct tc_to_netdev tc;
209209

210-
if (!tc_should_offload(dev, tp, 0))
210+
if (!tc_can_offload(dev, tp))
211211
return;
212212

213213
offload.command = TC_CLSFLOWER_DESTROY;
@@ -231,7 +231,7 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
231231
struct tc_to_netdev tc;
232232
int err;
233233

234-
if (!tc_should_offload(dev, tp, flags))
234+
if (!tc_can_offload(dev, tp))
235235
return tc_skip_sw(flags) ? -EINVAL : 0;
236236

237237
offload.command = TC_CLSFLOWER_REPLACE;
@@ -259,7 +259,7 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
259259
struct tc_cls_flower_offload offload = {0};
260260
struct tc_to_netdev tc;
261261

262-
if (!tc_should_offload(dev, tp, 0))
262+
if (!tc_can_offload(dev, tp))
263263
return;
264264

265265
offload.command = TC_CLSFLOWER_STATS;
@@ -275,7 +275,8 @@ static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
275275
static void __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f)
276276
{
277277
list_del_rcu(&f->list);
278-
fl_hw_destroy_filter(tp, (unsigned long)f);
278+
if (!tc_skip_hw(f->flags))
279+
fl_hw_destroy_filter(tp, (unsigned long)f);
279280
tcf_unbind_filter(tp, &f->res);
280281
call_rcu(&f->rcu, fl_destroy_filter);
281282
}
@@ -743,20 +744,23 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
743744
goto errout;
744745
}
745746

746-
err = fl_hw_replace_filter(tp,
747-
&head->dissector,
748-
&mask.key,
749-
&fnew->key,
750-
&fnew->exts,
751-
(unsigned long)fnew,
752-
fnew->flags);
753-
if (err)
754-
goto errout;
747+
if (!tc_skip_hw(fnew->flags)) {
748+
err = fl_hw_replace_filter(tp,
749+
&head->dissector,
750+
&mask.key,
751+
&fnew->key,
752+
&fnew->exts,
753+
(unsigned long)fnew,
754+
fnew->flags);
755+
if (err)
756+
goto errout;
757+
}
755758

756759
if (fold) {
757760
rhashtable_remove_fast(&head->ht, &fold->ht_node,
758761
head->ht_params);
759-
fl_hw_destroy_filter(tp, (unsigned long)fold);
762+
if (!tc_skip_hw(fold->flags))
763+
fl_hw_destroy_filter(tp, (unsigned long)fold);
760764
}
761765

762766
*arg = (unsigned long) fnew;
@@ -879,7 +883,8 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
879883
goto nla_put_failure;
880884
}
881885

882-
fl_hw_update_stats(tp, f);
886+
if (!tc_skip_hw(f->flags))
887+
fl_hw_update_stats(tp, f);
883888

884889
if (fl_dump_key_val(skb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST,
885890
mask->eth.dst, TCA_FLOWER_KEY_ETH_DST_MASK,

0 commit comments

Comments
 (0)