STRUCT I40E_STATS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– struct i40e_stats(9) πŸ’–

okay so this is a page from the Kernel API Manual (yes, the actual struct i40e_stats(9) one, bestie) and it's literally about how one little ethtool statistic gets described in the i40e driver. it's short, it's slay, let's go 🫢


✨ NAME ✨

struct i40e_stats β€” the definition for an ethtool statistic. that's it, that's the whole vibe πŸŽ€


🌸 SYNOPSIS 🌸

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

like look at her, three fields, no notes πŸ‘‘


πŸ¦‹ Members πŸ¦‹

  • stat_string β€” the statistic name, aka the little label that shows up in the ethtool -S output πŸ’…
  • sizeof_stat β€” the sizeof of the stat. has to be no greater than sizeof(u64), no cap 🚨
  • stat_offset β€” the offsetof of the stat from a base pointer. she's all about where things sit relative to home 🧚

⭐ Description ⭐

so this structure defines one single statistic that gets added to the ethtool stats buffer, and it describes that statistic as an offset from a common base pointer. simple, elegant, iconic.

stats should be defined in constant arrays using the I40E_STAT macro, and every element of that array has to use the same _type for calculating the sizeof_stat and the stat_offset. consistency is the whole point, fr fr ✨

the sizeof_stat is expected to be exactly one of:

  • sizeof(u8)
  • sizeof(u16)
  • sizeof(u32)
  • sizeof(u64)

other sizes are not expected and will produce a WARN_ONCE from the i40e_add_ethtool_stat helper function 😭 so like… don't do that. consider this your warning. literally.

now, stat_string is interpreted as a format string, which means formatted values can be inserted while you loop over multiple structures for a given statistics array πŸ”₯ and because of that, every statistic string in an array should have the same type and number of format specifiers β€” those get formatted by the variadic arguments to the i40e_add_stat_strings helper function. matching vibes only, bestie πŸ’œ

ngl the format-string thing is the part people mess up. same type, same number of specifiers. that's the assignment. πŸ“

🌈 SEE ALSO 🌈

first up, the actual kernel file: ./drivers/net/ethernet/intel/i40e/i40e_ethtool.c β€” go read her, she's the main character πŸŽ€

and then the whole friend group πŸ’–:

i40e_add_one_ethtool_stat(9), __i40e_add_ethtool_stats(9), i40e_add_ethtool_stats(9), i40e_add_queue_stats(9), __i40e_add_stat_strings(9), i40e_add_stat_strings(9), i40e_partition_setting_complaint(9), i40e_phy_type_to_ethtool(9), i40e_get_settings_link_up_fec(9), i40e_get_settings_link_up(9), i40e_get_settings_link_down(9), i40e_get_link_ksettings(9), i40e_speed_to_link_speed(9), i40e_set_link_ksettings(9), i40e_get_pauseparam(9), i40e_set_pauseparam(9), i40e_get_stats_count(9), i40e_get_veb_tc_stats(9), i40e_get_pfc_stats(9), i40e_get_ethtool_stats(9), i40e_get_stat_strings(9), i40e_set_wol(9), __i40e_get_coalesce(9), i40e_get_coalesce(9), i40e_get_per_queue_coalesce(9), i40e_set_itr_per_queue(9), __i40e_set_coalesce(9), i40e_set_coalesce(9), i40e_set_per_queue_coalesce(9), i40e_check_mask(9), i40e_parse_rx_flow_user_data(9), i40e_fill_rx_flow_user_data(9), i40e_get_ethtool_fdir_all(9), i40e_get_ethtool_fdir_entry(9), i40e_get_rx_ring_count(9), i40e_get_rxnfc(9), i40e_get_rss_hash_bits(9), i40e_update_ethtool_fdir_entry(9), i40e_prune_flex_pit_list(9), i40e_del_fdir_entry(9), i40e_unused_pit_index(9), i40e_find_flex_offset(9), i40e_add_flex_offset(9), __i40e_reprogram_flex_pit(9), i40e_reprogram_flex_pit(9), i40e_flow_str(9), i40e_pit_index_to_mask(9), i40e_print_input_set(9), i40e_check_fdir_input_set(9), i40e_match_fdir_filter(9), i40e_disallow_matching_filters(9), i40e_add_fdir_ethtool(9), i40e_set_rxnfc(9), i40e_max_channels(9), i40e_get_channels(9), i40e_set_channels(9), i40e_get_rxfh_key_size(9), i40e_get_rxfh_indir_size(9), i40e_get_rxfh(9), i40e_set_rxfh(9), i40e_get_priv_flags(9), i40e_set_priv_flags(9), i40e_get_module_info(9), i40e_get_module_eeprom(9)

like that's the entire group chat and they ALL ate πŸ’€πŸ”₯


okay that's the page!! this iconic little doc comes from ./drivers/net/ethernet/intel/i40e, dated October 2026, and it's filed under struct i40e_stats(9) in the Kernel API Manual. mwah, go read some kernel source, ily, bye πŸ«ΆπŸ’–βœ¨

πŸ“¦ where this page comes from