Skip to content

Commit 0cfe71f

Browse files
fengidriPaolo Abeni
authored andcommitted
netdev: add queue stats
These stats are commonly. Support reporting those via netdev-genl queue stats. name: rx-hw-drops name: rx-hw-drop-overruns name: rx-csum-unnecessary name: rx-csum-none name: rx-csum-bad name: rx-hw-gro-packets name: rx-hw-gro-bytes name: rx-hw-gro-wire-packets name: rx-hw-gro-wire-bytes name: rx-hw-drop-ratelimits name: tx-hw-drops name: tx-hw-drop-errors name: tx-csum-none name: tx-needs-csum name: tx-hw-gso-packets name: tx-hw-gso-bytes name: tx-hw-gso-wire-packets name: tx-hw-gso-wire-bytes name: tx-hw-drop-ratelimits Signed-off-by: Xuan Zhuo <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent d806e1f commit 0cfe71f

File tree

5 files changed

+190
-2
lines changed

5 files changed

+190
-2
lines changed

Documentation/netlink/specs/netdev.yaml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,110 @@ attribute-sets:
335335
Allocation failure may, or may not result in a packet drop, depending
336336
on driver implementation and whether system recovers quickly.
337337
type: uint
338+
-
339+
name: rx-hw-drops
340+
doc: |
341+
Number of all packets which entered the device, but never left it,
342+
including but not limited to: packets dropped due to lack of buffer
343+
space, processing errors, explicit or implicit policies and packet
344+
filters.
345+
type: uint
346+
-
347+
name: rx-hw-drop-overruns
348+
doc: |
349+
Number of packets dropped due to transient lack of resources, such as
350+
buffer space, host descriptors etc.
351+
type: uint
352+
-
353+
name: rx-csum-unnecessary
354+
doc: Number of packets that were marked as CHECKSUM_UNNECESSARY.
355+
type: uint
356+
-
357+
name: rx-csum-none
358+
doc: Number of packets that were not checksummed by device.
359+
type: uint
360+
-
361+
name: rx-csum-bad
362+
doc: |
363+
Number of packets with bad checksum. The packets are not discarded,
364+
but still delivered to the stack.
365+
type: uint
366+
-
367+
name: rx-hw-gro-packets
368+
doc: |
369+
Number of packets that were coalesced from smaller packets by the device.
370+
Counts only packets coalesced with the HW-GRO netdevice feature,
371+
LRO-coalesced packets are not counted.
372+
type: uint
373+
-
374+
name: rx-hw-gro-bytes
375+
doc: See `rx-hw-gro-packets`.
376+
type: uint
377+
-
378+
name: rx-hw-gro-wire-packets
379+
doc: |
380+
Number of packets that were coalesced to bigger packetss with the HW-GRO
381+
netdevice feature. LRO-coalesced packets are not counted.
382+
type: uint
383+
-
384+
name: rx-hw-gro-wire-bytes
385+
doc: See `rx-hw-gro-wire-packets`.
386+
type: uint
387+
-
388+
name: rx-hw-drop-ratelimits
389+
doc: |
390+
Number of the packets dropped by the device due to the received
391+
packets bitrate exceeding the device rate limit.
392+
type: uint
393+
-
394+
name: tx-hw-drops
395+
doc: |
396+
Number of packets that arrived at the device but never left it,
397+
encompassing packets dropped for reasons such as processing errors, as
398+
well as those affected by explicitly defined policies and packet
399+
filtering criteria.
400+
type: uint
401+
-
402+
name: tx-hw-drop-errors
403+
doc: Number of packets dropped because they were invalid or malformed.
404+
type: uint
405+
-
406+
name: tx-csum-none
407+
doc: |
408+
Number of packets that did not require the device to calculate the
409+
checksum.
410+
type: uint
411+
-
412+
name: tx-needs-csum
413+
doc: |
414+
Number of packets that required the device to calculate the checksum.
415+
type: uint
416+
-
417+
name: tx-hw-gso-packets
418+
doc: |
419+
Number of packets that necessitated segmentation into smaller packets
420+
by the device.
421+
type: uint
422+
-
423+
name: tx-hw-gso-bytes
424+
doc: See `tx-hw-gso-packets`.
425+
type: uint
426+
-
427+
name: tx-hw-gso-wire-packets
428+
doc: |
429+
Number of wire-sized packets generated by processing
430+
`tx-hw-gso-packets`
431+
type: uint
432+
-
433+
name: tx-hw-gso-wire-bytes
434+
doc: See `tx-hw-gso-wire-packets`.
435+
type: uint
436+
-
437+
name: tx-hw-drop-ratelimits
438+
doc: |
439+
Number of the packets dropped by the device due to the transmit
440+
packets bitrate exceeding the device rate limit.
441+
type: uint
338442

339443
operations:
340444
list:

include/net/netdev_queues.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,38 @@ struct netdev_queue_stats_rx {
99
u64 bytes;
1010
u64 packets;
1111
u64 alloc_fail;
12+
13+
u64 hw_drops;
14+
u64 hw_drop_overruns;
15+
16+
u64 csum_unnecessary;
17+
u64 csum_none;
18+
u64 csum_bad;
19+
20+
u64 hw_gro_packets;
21+
u64 hw_gro_bytes;
22+
u64 hw_gro_wire_packets;
23+
u64 hw_gro_wire_bytes;
24+
25+
u64 hw_drop_ratelimits;
1226
};
1327

1428
struct netdev_queue_stats_tx {
1529
u64 bytes;
1630
u64 packets;
31+
32+
u64 hw_drops;
33+
u64 hw_drop_errors;
34+
35+
u64 csum_none;
36+
u64 needs_csum;
37+
38+
u64 hw_gso_packets;
39+
u64 hw_gso_bytes;
40+
u64 hw_gso_wire_packets;
41+
u64 hw_gso_wire_bytes;
42+
43+
u64 hw_drop_ratelimits;
1744
};
1845

1946
/**

include/uapi/linux/netdev.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,25 @@ enum {
146146
NETDEV_A_QSTATS_TX_PACKETS,
147147
NETDEV_A_QSTATS_TX_BYTES,
148148
NETDEV_A_QSTATS_RX_ALLOC_FAIL,
149+
NETDEV_A_QSTATS_RX_HW_DROPS,
150+
NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS,
151+
NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY,
152+
NETDEV_A_QSTATS_RX_CSUM_NONE,
153+
NETDEV_A_QSTATS_RX_CSUM_BAD,
154+
NETDEV_A_QSTATS_RX_HW_GRO_PACKETS,
155+
NETDEV_A_QSTATS_RX_HW_GRO_BYTES,
156+
NETDEV_A_QSTATS_RX_HW_GRO_WIRE_PACKETS,
157+
NETDEV_A_QSTATS_RX_HW_GRO_WIRE_BYTES,
158+
NETDEV_A_QSTATS_RX_HW_DROP_RATELIMITS,
159+
NETDEV_A_QSTATS_TX_HW_DROPS,
160+
NETDEV_A_QSTATS_TX_HW_DROP_ERRORS,
161+
NETDEV_A_QSTATS_TX_CSUM_NONE,
162+
NETDEV_A_QSTATS_TX_NEEDS_CSUM,
163+
NETDEV_A_QSTATS_TX_HW_GSO_PACKETS,
164+
NETDEV_A_QSTATS_TX_HW_GSO_BYTES,
165+
NETDEV_A_QSTATS_TX_HW_GSO_WIRE_PACKETS,
166+
NETDEV_A_QSTATS_TX_HW_GSO_WIRE_BYTES,
167+
NETDEV_A_QSTATS_TX_HW_DROP_RATELIMITS,
149168

150169
__NETDEV_A_QSTATS_MAX,
151170
NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1)

net/core/netdev-genl.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,17 @@ netdev_nl_stats_write_rx(struct sk_buff *rsp, struct netdev_queue_stats_rx *rx)
489489
{
490490
if (netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_PACKETS, rx->packets) ||
491491
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_BYTES, rx->bytes) ||
492-
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_ALLOC_FAIL, rx->alloc_fail))
492+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_ALLOC_FAIL, rx->alloc_fail) ||
493+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROPS, rx->hw_drops) ||
494+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS, rx->hw_drop_overruns) ||
495+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY, rx->csum_unnecessary) ||
496+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_NONE, rx->csum_none) ||
497+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_CSUM_BAD, rx->csum_bad) ||
498+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_PACKETS, rx->hw_gro_packets) ||
499+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_BYTES, rx->hw_gro_bytes) ||
500+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_WIRE_PACKETS, rx->hw_gro_wire_packets) ||
501+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_GRO_WIRE_BYTES, rx->hw_gro_wire_bytes) ||
502+
netdev_stat_put(rsp, NETDEV_A_QSTATS_RX_HW_DROP_RATELIMITS, rx->hw_drop_ratelimits))
493503
return -EMSGSIZE;
494504
return 0;
495505
}
@@ -498,7 +508,16 @@ static int
498508
netdev_nl_stats_write_tx(struct sk_buff *rsp, struct netdev_queue_stats_tx *tx)
499509
{
500510
if (netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_PACKETS, tx->packets) ||
501-
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_BYTES, tx->bytes))
511+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_BYTES, tx->bytes) ||
512+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_DROPS, tx->hw_drops) ||
513+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_DROP_ERRORS, tx->hw_drop_errors) ||
514+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_CSUM_NONE, tx->csum_none) ||
515+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_NEEDS_CSUM, tx->needs_csum) ||
516+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_PACKETS, tx->hw_gso_packets) ||
517+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_BYTES, tx->hw_gso_bytes) ||
518+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_WIRE_PACKETS, tx->hw_gso_wire_packets) ||
519+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_GSO_WIRE_BYTES, tx->hw_gso_wire_bytes) ||
520+
netdev_stat_put(rsp, NETDEV_A_QSTATS_TX_HW_DROP_RATELIMITS, tx->hw_drop_ratelimits))
502521
return -EMSGSIZE;
503522
return 0;
504523
}

tools/include/uapi/linux/netdev.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,25 @@ enum {
146146
NETDEV_A_QSTATS_TX_PACKETS,
147147
NETDEV_A_QSTATS_TX_BYTES,
148148
NETDEV_A_QSTATS_RX_ALLOC_FAIL,
149+
NETDEV_A_QSTATS_RX_HW_DROPS,
150+
NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS,
151+
NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY,
152+
NETDEV_A_QSTATS_RX_CSUM_NONE,
153+
NETDEV_A_QSTATS_RX_CSUM_BAD,
154+
NETDEV_A_QSTATS_RX_HW_GRO_PACKETS,
155+
NETDEV_A_QSTATS_RX_HW_GRO_BYTES,
156+
NETDEV_A_QSTATS_RX_HW_GRO_WIRE_PACKETS,
157+
NETDEV_A_QSTATS_RX_HW_GRO_WIRE_BYTES,
158+
NETDEV_A_QSTATS_RX_HW_DROP_RATELIMITS,
159+
NETDEV_A_QSTATS_TX_HW_DROPS,
160+
NETDEV_A_QSTATS_TX_HW_DROP_ERRORS,
161+
NETDEV_A_QSTATS_TX_CSUM_NONE,
162+
NETDEV_A_QSTATS_TX_NEEDS_CSUM,
163+
NETDEV_A_QSTATS_TX_HW_GSO_PACKETS,
164+
NETDEV_A_QSTATS_TX_HW_GSO_BYTES,
165+
NETDEV_A_QSTATS_TX_HW_GSO_WIRE_PACKETS,
166+
NETDEV_A_QSTATS_TX_HW_GSO_WIRE_BYTES,
167+
NETDEV_A_QSTATS_TX_HW_DROP_RATELIMITS,
149168

150169
__NETDEV_A_QSTATS_MAX,
151170
NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1)

0 commit comments

Comments
 (0)