Statistics about frame reception
are kept in the per-CPU array netdev_rx_stat, whose elements are of type netif_rx_stats (see include/linux/netdevice.h):
struct netif_rx_stats netdev_rx_stat[NR_CPUS];
} __ _ _cacheline_aligned;
The elements of netif_rx_stats are:
Total number of ingress frames processed, including any that might be discarded. This value is updated both in netif_rx and in netif_receive_skb, which means that (by mistake) the same frame is accounted for twice when the driver does not use NAPI (i.e., it uses the netif_rx interface; see Figure 10-2 in Chapter 10).
Number of frames that were dropped because they were received when the CPU was in the throttle state.
Number of times net_rx_action had to return while frames were still in the CPU ingress queue, so as not to become a CPU hog. See the section "Processing the NET_RX_SOFTIRQ: net_rx_action" in Chapter 10.
Number of times the CPU went into the throttle state. This value is incremented by netif_rx.
Fields that used to be used by the Fastroute feature. This feature has been dropped in kernel 2.6.8.
Number of times the CPU failed to grab the lock on a device driver (more precisely, on dev->xmit_lock) because the lock was already taken by another CPU. This counter is updated in qdisc_restart, which handles only frame transmission, not reception. cpu_collision is the only statistic about transmission that has been included in this structure.
The fact that some of the preceding counters are currently updated only by netif_rx (which is used only by non-NAPI drivers), means that their values are not correct when using NAPI drivers.
The contents of the netdev_rx_stat vector can be viewed via the /proc interface. See the next section.
Other statistics are kept by the driver in private data structures (see Chapter 2), by higher-layer protocols, and by the Traffic Control queuing disciplines. Some of those values can be read with user-space applications such as ifconfig, tc, ip, or netstat, and others are also exported via /proc.