Skip to content

Commit 10cbc68

Browse files
amirvdavem330
authored andcommitted
net/sched: cls_flower: Hardware offloaded filters statistics support
Introduce a new command in ndo_setup_tc() for hardware offloaded filters, to call the NIC driver, and make it update the statistics. This will be done before dumping the filter and its statistics. Signed-off-by: Amir Vadai <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9fea47d commit 10cbc68

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/net/pkt_cls.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ static inline bool tc_flags_valid(u32 flags)
426426
enum tc_fl_command {
427427
TC_CLSFLOWER_REPLACE,
428428
TC_CLSFLOWER_DESTROY,
429+
TC_CLSFLOWER_STATS,
429430
};
430431

431432
struct tc_cls_flower_offload {

net/sched/cls_flower.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,25 @@ static void fl_hw_replace_filter(struct tcf_proto *tp,
210210
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
211211
}
212212

213+
static void fl_hw_update_stats(struct tcf_proto *tp, struct cls_fl_filter *f)
214+
{
215+
struct net_device *dev = tp->q->dev_queue->dev;
216+
struct tc_cls_flower_offload offload = {0};
217+
struct tc_to_netdev tc;
218+
219+
if (!tc_should_offload(dev, 0))
220+
return;
221+
222+
offload.command = TC_CLSFLOWER_STATS;
223+
offload.cookie = (unsigned long)f;
224+
offload.exts = &f->exts;
225+
226+
tc.type = TC_SETUP_CLSFLOWER;
227+
tc.cls_flower = &offload;
228+
229+
dev->netdev_ops->ndo_setup_tc(dev, tp->q->handle, tp->protocol, &tc);
230+
}
231+
213232
static bool fl_destroy(struct tcf_proto *tp, bool force)
214233
{
215234
struct cls_fl_head *head = rtnl_dereference(tp->root);
@@ -662,6 +681,8 @@ static int fl_dump(struct net *net, struct tcf_proto *tp, unsigned long fh,
662681
goto nla_put_failure;
663682
}
664683

684+
fl_hw_update_stats(tp, f);
685+
665686
if (fl_dump_key_val(skb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST,
666687
mask->eth.dst, TCA_FLOWER_KEY_ETH_DST_MASK,
667688
sizeof(key->eth.dst)) ||

0 commit comments

Comments
 (0)