drivers/net/ethernet/intel/i40e/i40e_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/i40e/i40e_ethtool.c- Extension
.c- Size
- 183638 bytes
- Lines
- 5856
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/net/intel/libie/pctype.hi40e_devids.hi40e_diag.hi40e_txrx_common.hi40e_virtchnl_pf.h
Detected Declarations
struct i40e_statsstruct i40e_cp_veb_tc_statsstruct i40e_pfc_statsstruct i40e_priv_flagsstruct i40e_ethtool_not_usedenum i40e_ethtool_test_idfunction i40e_add_one_ethtool_statfunction __i40e_add_ethtool_statsfunction ARRAY_SIZEfunction __i40e_add_stat_stringsfunction i40e_partition_setting_complaintfunction i40e_phy_type_to_ethtoolfunction i40e_get_settings_link_up_fecfunction i40e_get_settings_link_upfunction i40e_get_settings_link_downfunction i40e_get_link_ksettingsfunction i40e_speed_to_link_speedfunction i40e_set_link_ksettingsfunction i40e_set_fec_cfgfunction i40e_get_fec_paramfunction i40e_set_fec_paramfunction i40e_nway_resetfunction i40e_get_pauseparamfunction i40e_set_pauseparamfunction i40e_get_msglevelfunction i40e_set_msglevelfunction i40e_get_regs_lenfunction i40e_get_regsfunction i40e_get_eepromfunction i40e_get_eeprom_lenfunction i40e_set_eepromfunction i40e_get_drvinfofunction i40e_get_ringparamfunction i40e_active_tx_ring_indexfunction i40e_set_ringparamfunction i40e_get_stats_countfunction i40e_get_sset_countfunction arraysfunction i40e_get_pfc_statsfunction validfunction i40e_get_stat_stringsfunction i40e_get_priv_flag_stringsfunction i40e_get_stringsfunction i40e_get_ts_infofunction i40e_link_testfunction i40e_reg_testfunction i40e_eeprom_testfunction i40e_intr_test
Annotated Snippet
struct i40e_stats {
char stat_string[ETH_GSTRING_LEN];
int sizeof_stat;
int stat_offset;
};
/* Helper macro to define an i40e_stat structure with proper size and type.
* Use this when defining constant statistics arrays. Note that @_type expects
* only a type name and is used multiple times.
*/
#define I40E_STAT(_type, _name, _stat) { \
.stat_string = _name, \
.sizeof_stat = sizeof_field(_type, _stat), \
.stat_offset = offsetof(_type, _stat) \
}
/* Helper macro for defining some statistics directly copied from the netdev
* stats structure.
*/
#define I40E_NETDEV_STAT(_net_stat) \
I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat)
/* Helper macro for defining some statistics related to queues */
#define I40E_QUEUE_STAT(_name, _stat) \
I40E_STAT(struct i40e_ring, _name, _stat)
/* Stats associated with a Tx or Rx ring */
static const struct i40e_stats i40e_gstrings_queue_stats[] = {
I40E_QUEUE_STAT("%s-%u.packets", stats.packets),
I40E_QUEUE_STAT("%s-%u.bytes", stats.bytes),
};
/**
* i40e_add_one_ethtool_stat - copy the stat into the supplied buffer
* @data: location to store the stat value
* @pointer: basis for where to copy from
* @stat: the stat definition
*
* Copies the stat data defined by the pointer and stat structure pair into
* the memory supplied as data. Used to implement i40e_add_ethtool_stats and
* i40e_add_queue_stats. If the pointer is null, data will be zero'd.
*/
static void
i40e_add_one_ethtool_stat(u64 *data, void *pointer,
const struct i40e_stats *stat)
{
char *p;
if (!pointer) {
/* ensure that the ethtool data buffer is zero'd for any stats
* which don't have a valid pointer.
*/
*data = 0;
return;
}
p = (char *)pointer + stat->stat_offset;
switch (stat->sizeof_stat) {
case sizeof(u64):
*data = *((u64 *)p);
break;
case sizeof(u32):
*data = *((u32 *)p);
break;
case sizeof(u16):
*data = *((u16 *)p);
break;
case sizeof(u8):
*data = *((u8 *)p);
break;
default:
WARN_ONCE(1, "unexpected stat size for %s",
stat->stat_string);
*data = 0;
}
}
/**
* __i40e_add_ethtool_stats - copy stats into the ethtool supplied buffer
* @data: ethtool stats buffer
* @pointer: location to copy stats from
* @stats: array of stats to copy
* @size: the size of the stats definition
*
* Copy the stats defined by the stats array using the pointer as a base into
* the data buffer supplied by ethtool. Updates the data pointer to point to
* the next empty location for successive calls to __i40e_add_ethtool_stats.
* If pointer is null, set the data values to zero and update the pointer to
* skip these stats.
**/
Annotation
- Immediate include surface: `linux/net/intel/libie/pctype.h`, `i40e_devids.h`, `i40e_diag.h`, `i40e_txrx_common.h`, `i40e_virtchnl_pf.h`.
- Detected declarations: `struct i40e_stats`, `struct i40e_cp_veb_tc_stats`, `struct i40e_pfc_stats`, `struct i40e_priv_flags`, `struct i40e_ethtool_not_used`, `enum i40e_ethtool_test_id`, `function i40e_add_one_ethtool_stat`, `function __i40e_add_ethtool_stats`, `function ARRAY_SIZE`, `function __i40e_add_stat_strings`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.