Skip to content

Commit 3036dab

Browse files
hadarhenziondavem330
authored andcommitted
net/sched: cls_flower: Provide a filter to replace/destroy hardware filter functions
Instead of providing many arguments to fl_hw_{replace/destroy}_filter functions, just provide cls_fl_filter struct that includes all the relevant args. This patches doesn't add any new functionality. 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 7968521 commit 3036dab

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

net/sched/cls_flower.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static void fl_destroy_filter(struct rcu_head *head)
201201
kfree(f);
202202
}
203203

204-
static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie)
204+
static void fl_hw_destroy_filter(struct tcf_proto *tp, struct cls_fl_filter *f)
205205
{
206206
struct net_device *dev = tp->q->dev_queue->dev;
207207
struct tc_cls_flower_offload offload = {0};
@@ -211,7 +211,7 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie)
211211
return;
212212

213213
offload.command = TC_CLSFLOWER_DESTROY;
214-
offload.cookie = cookie;
214+
offload.cookie = (unsigned long)f;
215215

216216
tc.type = TC_SETUP_CLSFLOWER;
217217
tc.cls_flower = &offload;
@@ -222,32 +222,30 @@ static void fl_hw_destroy_filter(struct tcf_proto *tp, unsigned long cookie)
222222
static int fl_hw_replace_filter(struct tcf_proto *tp,
223223
struct flow_dissector *dissector,
224224
struct fl_flow_key *mask,
225-
struct fl_flow_key *key,
226-
struct tcf_exts *actions,
227-
unsigned long cookie, u32 flags)
225+
struct cls_fl_filter *f)
228226
{
229227
struct net_device *dev = tp->q->dev_queue->dev;
230228
struct tc_cls_flower_offload offload = {0};
231229
struct tc_to_netdev tc;
232230
int err;
233231

234232
if (!tc_can_offload(dev, tp))
235-
return tc_skip_sw(flags) ? -EINVAL : 0;
233+
return tc_skip_sw(f->flags) ? -EINVAL : 0;
236234

237235
offload.command = TC_CLSFLOWER_REPLACE;
238-
offload.cookie = cookie;
236+
offload.cookie = (unsigned long)f;
239237
offload.dissector = dissector;
240238
offload.mask = mask;
241-
offload.key = key;
242-
offload.exts = actions;
239+
offload.key = &f->key;
240+
offload.exts = &f->exts;
243241

244242
tc.type = TC_SETUP_CLSFLOWER;
245243
tc.cls_flower = &offload;
246244

247245
err = dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol,
248246
&tc);
249247

250-
if (tc_skip_sw(flags))
248+
if (tc_skip_sw(f->flags))
251249
return err;
252250

253251
return 0;
@@ -276,7 +274,7 @@ static void __fl_delete(struct tcf_proto *tp, struct cls_fl_filter *f)
276274
{
277275
list_del_rcu(&f->list);
278276
if (!tc_skip_hw(f->flags))
279-
fl_hw_destroy_filter(tp, (unsigned long)f);
277+
fl_hw_destroy_filter(tp, f);
280278
tcf_unbind_filter(tp, &f->res);
281279
call_rcu(&f->rcu, fl_destroy_filter);
282280
}
@@ -748,10 +746,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
748746
err = fl_hw_replace_filter(tp,
749747
&head->dissector,
750748
&mask.key,
751-
&fnew->key,
752-
&fnew->exts,
753-
(unsigned long)fnew,
754-
fnew->flags);
749+
fnew);
755750
if (err)
756751
goto errout;
757752
}
@@ -760,7 +755,7 @@ static int fl_change(struct net *net, struct sk_buff *in_skb,
760755
rhashtable_remove_fast(&head->ht, &fold->ht_node,
761756
head->ht_params);
762757
if (!tc_skip_hw(fold->flags))
763-
fl_hw_destroy_filter(tp, (unsigned long)fold);
758+
fl_hw_destroy_filter(tp, fold);
764759
}
765760

766761
*arg = (unsigned long) fnew;

0 commit comments

Comments
 (0)