Files
iproute2-next/tc
Ido Schimmel e7638a027a tc_util: Add support for 64-bit hardware packets counter
The netlink nest that carriers tc action statistics looks as follows:

[TCA_ACT_STATS]
	[TCA_STATS_BASIC]
	[TCA_STATS_BASIC_HW]

Where 'TCA_STATS_BASIC' carries the combined software and hardware
packets (32-bits) and bytes (64-bit) counters and 'TCA_STATS_BASIC_HW'
carries the hardware statistics.

When the number of packets exceeds 0xffffffff, the kernel emits the
'TCA_STATS_PKT64' attribute:

[TCA_ACT_STATS]
	[TCA_STATS_BASIC]
	[TCA_STATS_PKT64]
	[TCA_STATS_BASIC_HW]
	[TCA_STATS_PKT64]

This layout is not ideal as the only way for user space to know what
each 'TCA_STATS_PKT64' attribute carries is to check which attribute
precedes it, which is exactly what some applications are doing [1].

Do the same in iproute2 so that users with existing kernels could read
the 64-bit hardware packets counter of tc actions instead of reading the
truncated 32-bit counter.

Before:

$ tc -s filter show dev swp2 ingress
filter protocol all pref 1 flower chain 0
filter protocol all pref 1 flower chain 0 handle 0x1
  skip_sw
  in_hw in_hw_count 1
        action order 1: mirred (Egress Redirect to device swp1) stolen
        index 1 ref 1 bind 1 installed 47 sec used 23 sec
        Action statistics:
        Sent 368689092544 bytes 5760767071 pkt (dropped 0, overlimits 0 requeues 0)
        Sent software 0 bytes 0 pkt
        Sent hardware 368689092544 bytes 1465799775 pkt
        backlog 0b 0p requeues 0
        used_hw_stats immediate

Where 5760767071 - 1465799775 = 0x100000000

After:

$ tc -s filter show dev swp2 ingress
filter protocol all pref 1 flower chain 0
filter protocol all pref 1 flower chain 0 handle 0x1
  skip_sw
  in_hw in_hw_count 1
        action order 1: mirred (Egress Redirect to device swp1) stolen
        index 1 ref 1 bind 1 installed 71 sec used 47 sec
        Action statistics:
        Sent 368689092544 bytes 5760767071 pkt (dropped 0, overlimits 0 requeues 0)
        Sent software 0 bytes 0 pkt
        Sent hardware 368689092544 bytes 5760767071 pkt
        backlog 0b 0p requeues 0
        used_hw_stats immediate

[1] 006e1c6dbf

Reported-by: Joe Botha <joe@atomic.ac>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David Ahern <dsahern@kernel.org>
2025-02-07 21:02:08 +00:00
..
2020-01-20 09:43:22 -08:00
2024-03-12 15:11:43 -07:00
2024-01-25 16:49:10 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2020-01-20 09:43:22 -08:00
2023-01-14 09:00:34 -08:00
2024-12-12 15:22:22 -08:00
2024-03-12 15:11:43 -07:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2024-01-08 01:44:50 +00:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2023-01-14 09:00:34 -08:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-10-07 09:37:24 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2017-11-24 12:21:35 -08:00
2024-03-12 15:11:43 -07:00
2024-03-13 09:56:29 -07:00
2024-03-13 09:56:29 -07:00
2023-01-14 09:00:34 -08:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2024-03-12 15:11:43 -07:00
2020-07-20 16:34:02 +00:00
2023-01-14 09:00:34 -08:00
2018-11-24 07:10:58 -08:00
2023-01-14 09:00:34 -08:00
2024-10-05 17:48:11 +00:00