STRUCT IDPF_STATS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… struct idpf_stats(9) β€” the Kernel API Manual, bestie edition

okay so real talk, today we're doing struct idpf_stats from the Kernel API Manual, and honestly? she's giving "definition for an ethtool statistic" and she's iconic for it. let's get into it πŸŽ€


✨ NAME ✨

struct idpf_stats β€” the literal definition for an ethtool statistic. that's it, that's the girl πŸ’–


🌸 SYNOPSIS 🌸

okay bestie, here's the shape of her, copy it exactly, no cap:

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

πŸ¦‹ Members πŸ¦‹

  • stat_string β€” the statistic name you're gonna see displayed in ethtool -S output. this is her name tag at the party ✨
  • sizeof_stat β€” the sizeof of the stat, and it must be no greater than sizeof(u64). highkey a size limit, don't push it πŸ’…
  • stat_offset β€” the offsetof of the stat from a base pointer. it's giving "where u at relative to the base" energy 🧚

🫢 Description 🫢

so this structure defines a statistic to be added to the ethtool stats buffer, mmkay? it defines a statistic as an offset from a common base pointer. that's the whole bit.

stats should be defined in constant arrays using the IDPF_STAT macro, and every single element of that array has to use the same _type so the sizeof_stat and stat_offset come out right. no mixing, no chaos, we stay consistent πŸ‘‘

the sizeof_stat is expected to be sizeof(u8), sizeof(u16), sizeof(u32) or sizeof(u64). other sizes are not expected and will produce a WARN_ONCE from the idpf_add_ethtool_stat helper function. so like... don't do that 😭 the kernel will literally yell at you.

and the stat_string? she's interpreted as a format string. that 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 idpf_add_stat_string helper function. same type, same number of specifiers, every time β€” fr fr, that's the vibe check 🌈


πŸ’œ SEE ALSO πŸ’œ

the kernel file: ./drivers/net/ethernet/intel/idpf/idpf_ethtool.c ⭐

and the whole friend group, all here, all accounted for:


and that's the whole page, bestie, you ate it up πŸ“

mwah πŸ’‹ this one came from ./drivers/net/ethernet/intel/idpf, dated October 2026, and it's been struct idpf_stats(9) the whole time. go be a main character in idpf_ethtool.c now πŸ‘‘βœ¨
πŸ“¦ where this page comes from