Commit e8eb36cd authored by Amir Vadai's avatar Amir Vadai Committed by David S. Miller

net/sched: flower: Return error when hw can't offload and skip_sw is set

When skip_sw is set and hardware fails to apply filter, return error to
user. This will make error propagation logic similar to the one
currently used in u32 classifier.
Also, changed code to use tc_skip_sw() utility function.
Signed-off-by: default avatarAmir Vadai <amirva@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ce9355ac
...@@ -140,7 +140,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, ...@@ -140,7 +140,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
f = rhashtable_lookup_fast(&head->ht, f = rhashtable_lookup_fast(&head->ht,
fl_key_get_start(&skb_mkey, &head->mask), fl_key_get_start(&skb_mkey, &head->mask),
head->ht_params); head->ht_params);
if (f && !(f->flags & TCA_CLS_FLAGS_SKIP_SW)) { if (f && !tc_skip_sw(f->flags)) {
*res = f->res; *res = f->res;
return tcf_exts_exec(skb, &f->exts, res); return tcf_exts_exec(skb, &f->exts, res);
} }
...@@ -187,7 +187,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie) ...@@ -187,7 +187,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie)
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc); dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
} }
static void fl_hw_replace_filter(struct tcf_proto *tp, static int fl_hw_replace_filter(struct tcf_proto *tp,
struct flow_dissector *dissector, struct flow_dissector *dissector,
struct fl_flow_key *mask, struct fl_flow_key *mask,
struct fl_flow_key *key, struct fl_flow_key *key,
...@@ -197,9 +197,10 @@ static void fl_hw_replace_filter(struct tcf_proto *tp, ...@@ -197,9 +197,10 @@ static void fl_hw_replace_filter(struct tcf_proto *tp,
struct net_device *dev = tp->q->dev_queue->dev; struct net_device *dev = tp->q->dev_queue->dev;
struct tc_cls_flower_offload offload = {0}; struct tc_cls_flower_offload offload = {0};
struct tc_to_netdev tc; struct tc_to_netdev tc;
int err;
if (!tc_should_offload(dev, tp, flags)) if (!tc_should_offload(dev, tp, flags))
return; return tc_skip_sw(flags) ? -EINVAL : 0;
offload.command = TC_CLSFLOWER_REPLACE; offload.command = TC_CLSFLOWER_REPLACE;
offload.cookie = cookie; offload.cookie = cookie;
...@@ -211,7 +212,12 @@ static void fl_hw_replace_filter(struct tcf_proto *tp, ...@@ -211,7 +212,12 @@ static void fl_hw_replace_filter(struct tcf_proto *tp,
tc.type = TC_SETUP_CLSFLOWER; tc.type = TC_SETUP_CLSFLOWER;
tc.cls_flower = &offload; tc.cls_flower = &offload;
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc); err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
if (tc_skip_sw(flags))
return err;
return 0;
} }
static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f) static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
...@@ -572,20 +578,22 @@ static int fl_change(struct net *net, struct sk_buff *in_skb, ...@@ -572,20 +578,22 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
if (err) if (err)
goto errout; goto errout;
if (!(fnew->flags & TCA_CLS_FLAGS_SKIP_SW)) { if (!tc_skip_sw(fnew->flags)) {
err = rhashtable_insert_fast(&head->ht, &fnew->ht_node, err = rhashtable_insert_fast(&head->ht, &fnew->ht_node,
head->ht_params); head->ht_params);
if (err) if (err)
goto errout; goto errout;
} }
fl_hw_replace_filter(tp, err = fl_hw_replace_filter(tp,
&head->dissector, &head->dissector,
&mask.key, &mask.key,
&fnew->key, &fnew->key,
&fnew->exts, &fnew->exts,
(unsigned long)fnew, (unsigned long)fnew,
fnew->flags); fnew->flags);
if (err)
goto errout;
if (fold) { if (fold) {
rhashtable_remove_fast(&head->ht, &fold->ht_node, rhashtable_remove_fast(&head->ht, &fold->ht_node,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment