History

netdev: add per-queue statistics

The ethtool-nl family does a good job exposing various protocol related and IEEE/IETF statistics which used to get dumped under ethtool -S, with creative names. Queue stats don't have a netlink API, yet, and remain a lion's share of ethtool -S output for new drivers. Not only is that bad because the names differ driver to driver but it's also bug-prone. Intuitively drivers try to report only the stats for active queues, but querying ethtool stats involves multiple system calls, and the number of stats is read separately from the stats themselves. Worse still when user space asks for values of the stats, it doesn't inform the kernel how big the buffer is. If number of stats increases in the meantime kernel will overflow user buffer. Add a netlink API for dumping queue stats. Queue information is exposed via the netdev-genl family, so add the stats there. Support per-queue and sum-for-device dumps. Latter will be useful when subsequent patches add more interesting common stats than just bytes and packets. The API does not currently distinguish between HW and SW stats. The expectation is that the source of the stats will either not matter much (good packets) or be obvious (skb alloc errors).

Jakub Kicinski committed 2 years ago

Commit ab63a231 parent e8bb2cc9 files · +421 −0Browse files

Showing the changes to include/uapi (1 of 9 files). Show all

Unified · Split

include/uapi/linux/netdev.h+19−0
@@ -70,6 +70,10 @@ enum netdev_queue_type { · 69 unmodified lines
70 NETDEV_QUEUE_TYPE_TX,70 NETDEV_QUEUE_TYPE_TX,
71};71};
72 72
73enum netdev_qstats_scope {
74 NETDEV_QSTATS_SCOPE_QUEUE = 1,
75};
76
73enum {77enum {
74 NETDEV_A_DEV_IFINDEX = 1,78 NETDEV_A_DEV_IFINDEX = 1,
75 NETDEV_A_DEV_PAD,79 NETDEV_A_DEV_PAD,
@@ -132,6 +136,20 @@ enum { · 56 unmodified lines
132 NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)136 NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
133};137};
134 138
139enum {
140 NETDEV_A_QSTATS_IFINDEX = 1,
141 NETDEV_A_QSTATS_QUEUE_TYPE,
142 NETDEV_A_QSTATS_QUEUE_ID,
143 NETDEV_A_QSTATS_SCOPE,
144 NETDEV_A_QSTATS_RX_PACKETS = 8,
145 NETDEV_A_QSTATS_RX_BYTES,
146 NETDEV_A_QSTATS_TX_PACKETS,
147 NETDEV_A_QSTATS_TX_BYTES,
148
149 __NETDEV_A_QSTATS_MAX,
150 NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1)
151};
152
135enum {153enum {
136 NETDEV_CMD_DEV_GET = 1,154 NETDEV_CMD_DEV_GET = 1,
137 NETDEV_CMD_DEV_ADD_NTF,155 NETDEV_CMD_DEV_ADD_NTF,
@@ -144,6 +162,7 @@ enum { · 6 unmodified lines
144 NETDEV_CMD_PAGE_POOL_STATS_GET,162 NETDEV_CMD_PAGE_POOL_STATS_GET,
145 NETDEV_CMD_QUEUE_GET,163 NETDEV_CMD_QUEUE_GET,
146 NETDEV_CMD_NAPI_GET,164 NETDEV_CMD_NAPI_GET,
165 NETDEV_CMD_QSTATS_GET,
147 166
148 __NETDEV_CMD_MAX,167 __NETDEV_CMD_MAX,
149 NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1)168 NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1)