Skip to content

Commit

Permalink
Documentation: reflect generic XDP statistics
Browse files Browse the repository at this point in the history
Add a couple of hints on how to retrieve and implement generic XDP
statistics for drivers/interfaces. Mention that it's unwanted to
include related XDP counters in driver-defined Ethtool stats.

Signed-off-by: Alexander Lobakin <alexandr.lobakin@intel.com>
  • Loading branch information
alobakin committed Oct 22, 2021
1 parent 93f40bb commit 8fc7d34
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Documentation/networking/statistics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ If `-s` is specified once the detailed errors won't be shown.

`ip` supports JSON formatting via the `-j` option.

For some interfaces, standard XDP statistics are available.
It can be accessed the same ways, e.g. `ip`::

$ ip link xdpstats dev enp178s0
16: enp178s0:
xdp-channel0-rx_xdp_packets: 0
xdp-channel0-rx_xdp_bytes: 1
xdp-channel0-rx_xdp_errors: 2
xdp-channel0-rx_xdp_aborted: 3
xdp-channel0-rx_xdp_drop: 4
xdp-channel0-rx_xdp_invalid: 5
xdp-channel0-rx_xdp_pass: 6
xdp-channel0-rx_xdp_redirect: 7
xdp-channel0-rx_xdp_redirect_errors: 8
xdp-channel0-rx_xdp_tx: 9
xdp-channel0-rx_xdp_tx_errors: 10
xdp-channel0-tx_xdp_xmit_packets: 11
xdp-channel0-tx_xdp_xmit_bytes: 12
xdp-channel0-tx_xdp_xmit_errors: 13
xdp-channel0-tx_xdp_xmit_full: 14

Those are usually per-channel. JSON is also supported via the `-j` opt.

Protocol-specific statistics
----------------------------

Expand Down Expand Up @@ -147,6 +170,8 @@ Statistics are reported both in the responses to link information
requests (`RTM_GETLINK`) and statistic requests (`RTM_GETSTATS`,
when `IFLA_STATS_LINK_64` bit is set in the `.filter_mask` of the request).

`IFLA_STATS_LINK_XDP_XSTATS` bit is used to retrieve standard XDP statstics.

ethtool
-------

Expand Down Expand Up @@ -206,6 +231,14 @@ Retrieving ethtool statistics is a multi-syscall process, drivers are advised
to keep the number of statistics constant to avoid race conditions with
user space trying to read them.

It is up to the developers whether to implement XDP statistics or not due to
possible performance hits. If so, it is encouraged to export it using generic
XDP statistics infrastructure, not driver-defined Ethtool stats.
It can be achieve by implementing `.ndo_get_xdp_stats` and, optionally but
preferred, `.ndo_get_xdp_stats_nch`. There are several common helper structures
and functions in `include/net/xdp.h` to make this simpler and keep the code
compact.

Statistics must persist across routine operations like bringing the interface
down and up.

Expand Down

0 comments on commit 8fc7d34

Please sign in to comment.