STRUCT ETHTOOL_STATS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ struct ethtool_stats(9) β€” the kernel API manual page, bestie edition πŸ¦‹

okay so. this is a page from the kernel API manual (that's the manual name, it's giving official πŸ’…) and it's all about struct ethtool_stats, aka device-specific statistics. if you've ever wanted your NIC to spill its numbers, this is the lil struct that carries them. let's get into it 🫢


✨ NAME ✨

struct ethtool_stats β€” device-specific statistics. that's it, that's the whole vibe. it's the container, the cute little basket 🧺 that your device's stat counters get shipped back in.


🌈 SYNOPSIS 🌈

struct ethtool_stats {
    __u32 cmd;
    __u32 n_stats;
    __u64 data[];
};

look at her. flexible array member and everything. main character energy fr.


πŸŽ€ Members πŸŽ€

  • cmd β€” the command number, and it equals ETHTOOL_GSTATS. that's your "hey kernel, gimme the stats" flag, no cap 🚩
  • n_stats β€” Number of statistics. how many of them there are. lowkey the most important field on the whole page, keep reading πŸ‘€
  • data β€” Array of statistics. the actual payload, the good stuff, the numbers themselves ✨

πŸ’œ Description πŸ’œ

okay this is the part you actually need to internalize, so pay attention bestie 😭

You must use ETHTOOL_GSSET_INFO or ETHTOOL_GDRVINFO to find the number of statistics that will be returned. like, you can't just guess. don't be that person πŸ™ˆ

Then you must allocate a buffer of the appropriate size β€” that's 8 * number of statistics, exactly, the math is not a vibe, it's a requirement β€” immediately following this structure. immediately. right after it. attached. glued. it's giving conjoined twins πŸ’«


Setting n_stats on input is optional (though preferred β€” the docs literally say preferred, so like, do it πŸ’…), but it must be zeroed otherwise. no half-measures, no uninitialized garbage.

When set, n_stats will return the requested count if it matches the actual count; otherwise, it will be zero. so it's a match-or-nothing situation, very all-or-nothing of it.

and the reason this exists? it prevents issues when the number of stats is different than the userspace allocation. basically it's a safety rail so you don't read past your buffer and have a bad time πŸ’€. respect the rail.

πŸ¦‹ SEE ALSO πŸ¦‹

Kernel file ./include/uapi/linux/ethtool.h β€” start there, it's the mothership πŸ‘‘

and then the whole extended family, in order, no skipping:

  • struct ethtool_cmd(9)
  • struct ethtool_drvinfo(9)
  • struct ethtool_wolinfo(9)
  • struct ethtool_regs(9)
  • struct ethtool_eeprom(9)
  • struct ethtool_eee(9)
  • struct ethtool_modinfo(9)
  • struct ethtool_coalesce(9)
  • struct ethtool_ringparam(9)
  • struct ethtool_channels(9)
  • struct ethtool_pauseparam(9)
  • enum ethtool_stringset(9)
  • enum ethtool_mac_stats_src(9)
  • enum ethtool_module_power_mode_policy(9)
  • enum ethtool_module_power_mode(9)
  • enum ethtool_c33_pse_ext_state(9)
  • enum ethtool_c33_pse_ext_substate_mr_mps_valid(9)
  • enum ethtool_c33_pse_ext_substate_error_condition(9)
  • enum ethtool_c33_pse_ext_substate_mr_pse_enable(9)
  • enum ethtool_c33_pse_ext_substate_option_detect_ted(9)
  • enum ethtool_c33_pse_ext_substate_option_vport_lim(9)
  • enum ethtool_c33_pse_ext_substate_ovld_detected(9)
  • enum ethtool_c33_pse_ext_substate_power_not_available(9)
  • enum ethtool_c33_pse_ext_substate_short_detected(9)
  • enum ethtool_pse_types(9)
  • enum ethtool_c33_pse_admin_state(9)
  • enum ethtool_c33_pse_pw_d_status(9)
  • enum ethtool_podl_pse_admin_state(9)
  • enum ethtool_podl_pse_pw_d_status(9)
  • enum ethtool_mm_verify_status(9)
  • enum ethtool_module_fw_flash_status(9)
  • struct ethtool_gstrings(9)
  • struct ethtool_sset_info(9)
  • enum ethtool_test_flags(9)
  • struct ethtool_test(9)
  • struct ethtool_perm_addr(9)
  • struct ethtool_tcpip4_spec(9)
  • struct ethtool_ah_espip4_spec(9)
  • struct ethtool_usrip4_spec(9)
  • struct ethtool_tcpip6_spec(9)
  • struct ethtool_ah_espip6_spec(9)
  • struct ethtool_usrip6_spec(9)
  • struct ethtool_flow_ext(9)
  • struct ethtool_rx_flow_spec(9)
  • struct ethtool_rxnfc(9)
  • struct ethtool_rxfh_indir(9)
  • struct ethtool_rxfh(9)
  • struct ethtool_rx_ntuple_flow_spec(9)
  • struct ethtool_rx_ntuple(9)
  • struct ethtool_dump(9)
  • struct ethtool_get_features_block(9)
  • struct ethtool_gfeatures(9)
  • struct ethtool_set_features_block(9)
  • struct ethtool_sfeatures(9)
  • struct ethtool_ts_info(9)
  • struct ethtool_per_queue_op(9)
  • struct ethtool_fecparam(9)
  • enum ethtool_fec_config_bits(9)
  • struct ethtool_link_settings(9)
  • enum phy_upstream(9)

yeah that's a lot of siblings. big family. they all ate tho πŸ’…


and that's the page!! source lives at ./include/uapi/linux, dated October 2026, and the title's still struct ethtool_stats(9) in case you forgot already 😌 go forth and count your stats, bestie β€” periodt πŸŽ€βœ¨

πŸ“¦ where this page comes from