linux-stable/Documentation/networking/index.rst
Jakub Kicinski 0db0c34cfb net: tighten the definition of interface statistics
This patch is born out of an investigation into which IEEE statistics
correspond to which struct rtnl_link_stats64 members. Turns out that
there seems to be reasonable consensus on the matter, among many drivers.
To save others the time (and it took more time than I'm comfortable
admitting) I'm adding comments referring to IEEE attributes to
struct rtnl_link_stats64.

Up until now we had two forms of documentation for stats - in
Documentation/ABI/testing/sysfs-class-net-statistics and the comments
on struct rtnl_link_stats64 itself. While the former is very cautious
in defining the expected behavior, the latter feel quite dated and
may not be easy to understand for modern day driver author
(e.g. rx_over_errors). At the same time modern systems are far more
complex and once obvious definitions lost their clarity. For example
- does rx_packet count at the MAC layer (aFramesReceivedOK)?
packets processed correctly by hardware? received by the driver?
or maybe received by the stack?

I tried to clarify the expectations, further clarifications from
others are very welcome.

The part hardest to untangle is rx_over_errors vs rx_fifo_errors
vs rx_missed_errors. After much deliberation I concluded that for
modern HW only two of the counters will make sense. The distinction
between internal FIFO overflow and packets dropped due to back-pressure
from the host is likely too implementation (driver and device) specific
to expose in the standard stats.

Now - which two of those counters we select to use is anyone's pick:

sysfs documentation suggests rx_over_errors counts packets which
did not fit into buffers due to MTU being too small, which I reused.
There don't seem to be many modern drivers using it (well, CAN drivers
seem to love this statistic).

Of the remaining two I picked rx_missed_errors to report device drops.
bnxt reports it and it's folded into "drop"s in procfs (while
rx_fifo_errors is an error, and modern devices usually receive the frame
OK, they just can't admit it into the pipeline).

Of the drivers I looked at only AMD Lance-like and NS8390-like use all
three of these counters. rx_missed_errors counts missed frames,
rx_over_errors counts overflow events, and rx_fifo_errors counts frames
which were truncated because they didn't fit into buffers. This suggests
that rx_fifo_errors may be the correct stat for truncated packets, but
I'd think a FIFO stat counting truncated packets would be very confusing
to a modern reader.

v2:
 - add driver developer notes about ethtool stat count and reset
 - replace Ethernet with IEEE 802.3 to better indicate source of attrs
 - mention byte counters don't count FCS
 - clarify RX counter is from device to host
 - drop "sightly" from sysfs paragraph
 - add examples of ethtool stats
 - s/incoming/received/ s/incoming/transmitted/

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2020-09-07 15:08:05 -07:00

121 lines
1.5 KiB
ReStructuredText

Linux Networking Documentation
==============================
Contents:
.. toctree::
:maxdepth: 2
netdev-FAQ
af_xdp
bareudp
batman-adv
can
can_ucan_protocol
device_drivers/index
dsa/index
devlink/index
caif/index
ethtool-netlink
ieee802154
j1939
kapi
msg_zerocopy
failover
net_dim
net_failover
page_pool
phy
sfp-phylink
alias
bridge
snmp_counter
checksum-offloads
segmentation-offloads
scaling
tls
tls-offload
nfc
6lowpan
6pack
arcnet-hardware
arcnet
atm
ax25
bonding
cdc_mbim
dccp
dctcp
decnet
dns_resolver
driver
eql
fib_trie
filter
framerelay
generic-hdlc
generic_netlink
gen_stats
gtp
ila
ipddp
ip_dynaddr
ipsec
ip-sysctl
ipv6
ipvlan
ipvs-sysctl
kcm
l2tp
lapb-module
mac80211-injection
mpls-sysctl
multiqueue
netconsole
netdev-features
netdevices
netfilter-sysctl
netif-msg
nf_conntrack-sysctl
nf_flowtable
openvswitch
operstates
packet_mmap
phonet
pktgen
plip
ppp_generic
proc_net_tcp
radiotap-headers
rds
regulatory
rxrpc
sctp
secid
seg6-sysctl
statistics
strparser
switchdev
tc-actions-env-rules
tcp-thin
team
timestamping
tproxy
tuntap
udplite
vrf
vxlan
x25-iface
x25
xfrm_device
xfrm_proc
xfrm_sync
xfrm_sysctl
.. only:: subproject and html
Indices
=======
* :ref:`genindex`