STRUCT IAVF_STATS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ¦‹ struct iavf_stats(9) β€” Kernel API Manual πŸ¦‹

okay bestie, so this is a page from the Kernel API Manual and it's literally all about struct iavf_stats β€” the little glow-up blueprint for, and I quote, "definition for an ethtool statistic" ✨ yes ma'am, that's the whole vibe.


🌸 NAME 🌸

struct iavf_stats β€” the definition for an ethtool statistic. that's it, that's the name, she's simple but she's iconic πŸ’…


✨ SYNOPSIS ✨

struct iavf_stats {
    char stat_string[ETH_GSTRING_LEN];
    int sizeof_stat;
    int stat_offset;
 };

look at her. three little fields, zero drama, all business 🫢


πŸŽ€ Members πŸŽ€

  • stat_string β€” the statistic name that gets displayed in the ethtool -S output. it's the label bestie, the little nametag πŸ‘‘
  • sizeof_stat β€” literally the sizeof the stat itself. rule of the house: it must be no greater than sizeof(u64). don't push it πŸ™ˆ
  • stat_offset β€” the offsetof of the stat from a base pointer. it's giving "where am I relative to home" 🧭

πŸ’– Description πŸ’–

so this structure is what defines a statistic that gets added to the ethtool stats buffer. it defines a statistic as an offset from a common base pointer β€” that's the whole trick, iykyk πŸ’«

stats should be defined in constant arrays using the IAVF_STAT macro, and listen: every single element of that array has to use the same _type for calculating sizeof_stat and stat_offset. no mixing, no chaos, we're consistent in this household periodt πŸŽ€

the sizeof_stat is expected to be sizeof(u8), sizeof(u16), sizeof(u32) or sizeof(u64). those four, that's the squad. other sizes are not expected, and if you try it you will produce a WARN_ONCE from the iavf_add_ethtool_stat helper function 😭 so like... don't. fr fr.

⚠️ heads up bestie β€” the stat_string is interpreted as a format string, which means formatted values can get inserted while looping over multiple structures for a given statistics array. so every statistic string in an array should have the same type and number of format specifiers, to be formatted by variadic arguments to the iavf_add_stat_string helper function. same type, same count, no exceptions 🫢

🌈 SEE ALSO 🌈

kernel file ./drivers/net/ethernet/intel/iavf/iavf_ethtool.c β€” go read the source, she's right there πŸ’œ

and the whole friend group, in order, no cap:


and that's the whole page bestie, go forth and offset responsibly πŸ’…

✧ο½₯゚: * sign-off time * :゚ο½₯✧ this lil masterpiece lives in ./drivers/net/ethernet/intel/iavf and it's dated October 2026 β€” struct iavf_stats(9), out πŸ¦‹πŸ’–

πŸ“¦ where this page comes from