drivers/net/ethernet/intel/iavf/iavf_ethtool.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/iavf/iavf_ethtool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/iavf/iavf_ethtool.c- Extension
.c- Size
- 56812 bytes
- Lines
- 1896
- 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/bitfield.hlinux/uaccess.hnet/netdev_lock.hiavf.h
Detected Declarations
struct iavf_statsfunction iavf_add_one_ethtool_statfunction __iavf_add_ethtool_statsfunction ARRAY_SIZEfunction __iavf_add_stat_stringsfunction iavf_get_link_ksettingsfunction iavf_get_sset_countfunction iavf_get_ethtool_statsfunction iavf_get_stat_stringsfunction iavf_get_stringsfunction iavf_get_msglevelfunction iavf_set_msglevelfunction iavf_get_drvinfofunction iavf_get_ringparamfunction iavf_set_ringparamfunction __iavf_get_coalescefunction iavf_get_coalescefunction iavf_get_per_queue_coalescefunction iavf_set_itr_per_queuefunction __iavf_set_coalescefunction iavf_set_coalescefunction iavf_set_per_queue_coalescefunction iavf_fltr_to_ethtool_flowfunction iavf_ethtool_flow_to_fltrfunction iavf_is_mask_validfunction iavf_parse_rx_flow_user_datafunction iavf_fill_rx_flow_ext_datafunction iavf_get_ethtool_fdir_entryfunction iavf_get_fdir_fltr_idsfunction list_for_each_entryfunction iavf_add_fdir_fltr_infofunction iavf_add_fdir_ethtoolfunction iavf_del_fdir_ethtoolfunction iavf_adv_rss_parse_hdrsfunction iavf_adv_rss_parse_hash_fldsfunction iavf_set_rxfh_fieldsfunction iavf_get_rxfh_fieldsfunction iavf_set_rxnfcfunction iavf_get_rx_ring_countfunction iavf_get_rxnfcfunction iavf_get_channelsfunction iavf_set_channelsfunction iavf_get_rxfh_key_sizefunction iavf_get_rxfh_indir_sizefunction iavf_get_rxfhfunction iavf_set_rxfhfunction iavf_set_ethtool_ops
Annotated Snippet
struct iavf_stats {
char stat_string[ETH_GSTRING_LEN];
int sizeof_stat;
int stat_offset;
};
/* Helper macro to define an iavf_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 IAVF_STAT(_type, _name, _stat) { \
.stat_string = _name, \
.sizeof_stat = sizeof_field(_type, _stat), \
.stat_offset = offsetof(_type, _stat) \
}
/* Helper macro for defining some statistics related to queues */
#define IAVF_QUEUE_STAT(_name, _stat) \
IAVF_STAT(struct iavf_ring, _name, _stat)
/* Stats associated with a Tx or Rx ring */
static const struct iavf_stats iavf_gstrings_queue_stats[] = {
IAVF_QUEUE_STAT("%s-%u.packets", stats.packets),
IAVF_QUEUE_STAT("%s-%u.bytes", stats.bytes),
};
/**
* iavf_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 iavf_add_ethtool_stats and
* iavf_add_queue_stats. If the pointer is null, data will be zero'd.
*/
static void
iavf_add_one_ethtool_stat(u64 *data, void *pointer,
const struct iavf_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;
}
}
/**
* __iavf_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 __iavf_add_ethtool_stats.
* If pointer is null, set the data values to zero and update the pointer to
* skip these stats.
*/
static void
__iavf_add_ethtool_stats(u64 **data, void *pointer,
const struct iavf_stats stats[],
const unsigned int size)
{
unsigned int i;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/uaccess.h`, `net/netdev_lock.h`, `iavf.h`.
- Detected declarations: `struct iavf_stats`, `function iavf_add_one_ethtool_stat`, `function __iavf_add_ethtool_stats`, `function ARRAY_SIZE`, `function __iavf_add_stat_strings`, `function iavf_get_link_ksettings`, `function iavf_get_sset_count`, `function iavf_get_ethtool_stats`, `function iavf_get_stat_strings`, `function iavf_get_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.