tc flower hw offload counters

首先mlx5_core驱动有一个单线程的workqueue,每一秒mlx5_fc_stats_work都会被调到,去fw里面查询flow对应的counter。然后放在struct mlx5_fc。这里面用到了单线程,单链表,所以mlx5_fc插入删除的时候并没有锁。当然也不是一个一个的查,而是批量的查。这个即使上百万的flow counter也不会消耗太长时间。

然后用tc去查询相应的flow的时候,下面的函数会被调到:

fl_dump
        fl_hw_update_stats
                tc_setup_cb_call
                        mlx5e_setup_tc_block_cb
                                mlx5e_stats_flower
                tcf_exts_stats_update
                        for(nr_actions)
                                tcf_action_stats_update
                                        stats_update
                                                tcfa_bstats_hw

tc_action的cpu_bstats和cpu_bstats_hw并不是每个action都有,tcf_idr_create的时候有个参数cpustats控制创建与否。但是如果实现了stats_update callback的话,这个action也可以显示hw offload counters了。

之所以有两个counter,是因为per cpu的counter太耗费cpu资源,action初始化的时候可以选择不用per cpu counter。相应的patch是:

commit bd7ac13f9c32b3251ac3c0caf6be8f64c276c5a1
Author: Vlad Buslov <vladbu@mellanox.com>
Date:   Wed Oct 30 16:09:06 2019 +0200

    net: sched: update action implementations to support flags

    Extend struct tc_action with new "tcfa_flags" field. Set the field in
    tcf_idr_create() function and provide new helper
    tcf_idr_create_from_flags() that derives 'cpustats' boolean from flags
    value. Update individual hardware-offloaded actions init() to pass their
    "flags" argument to new helper in order to skip percpu stats allocation
    when user requested it through flags.

    Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    (cherry-picked from commit e38226786022d2d8e5876ab7bc37e82b0eb57e65)
    Signed-off-by: Wen-chien Jesse Sung <jesse.sung@canonical.com>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值