Statistical Information
The last method a driver needs is get_stats. This method returns a pointer to the statistics for the device. Its implementation is pretty easy:
struct enet_statistics *snull_stats(struct device *dev)
{
struct snull_priv *priv = (struct snull_priv *)dev->priv;
return &priv->stats;
}The real work needed to return meaningful statistics is distributed
throughout the driver, where the various fields are updated. The
following list shows the most interesting fields in
struct enet_statistics.
-
int rx_packets;,int tx_packets; These fields hold the total number of incoming and outgoing packets successfully transferred by the interface.
-
int rx_errors;,int tx_errors; The number of erroneous receptions and transmissions. Receive errors can be the result of bad checksums, wrong packet sizes, or other problems. Transmit errors are less common and are due mainly to cable problems.
-
int rx_dropped;,int tx_dropped; The number of packets dropped during reception and transmission. Packets are dropped when there’s no memory available for packet data.
tx_droppedis rarely used.
The structure has several more fields, which can be used to detail
the kind of errors that happened during transmission or
reception. The interested reader is urged to look at the structure’s
definition in <linux/if_ether.h>.
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access