drivers/net/ethernet/sfc/ethtool_common.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/ethtool_common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/ethtool_common.c- Extension
.c- Size
- 38810 bytes
- Lines
- 1333
- 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.
- 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/module.hlinux/netdevice.hnet_driver.hmcdi.hnic.hselftest.hrx_common.hethtool_common.hmcdi_port_common.h
Detected Declarations
struct efx_sw_stat_descfunction offsetoffunction efx_get_atomic_statfunction efx_ethtool_get_drvinfofunction efx_ethtool_get_msglevelfunction efx_ethtool_set_msglevelfunction efx_ethtool_self_testfunction efx_ethtool_get_pauseparamfunction efx_ethtool_set_pauseparamfunction efx_fill_testfunction efx_fill_loopback_testfunction efx_for_each_channel_tx_queuefunction stringsfunction efx_describe_per_queue_statsfunction efx_for_each_channelfunction efx_ethtool_get_sset_countfunction efx_ethtool_get_stringsfunction efx_ethtool_get_statsfunction efx_for_each_channelfunction efx_for_each_channelfunction efx_for_each_channel_tx_queuefunction efx_for_each_channel_rx_queuefunction efx_ethtool_get_link_ksettingsfunction efx_ethtool_set_link_ksettingsfunction efx_ethtool_get_fecparamfunction efx_ethtool_set_fecparamfunction ip6_fill_maskfunction efx_ethtool_get_class_rulefunction efx_ethtool_get_rxfh_fieldsfunction efx_ethtool_get_rx_ring_countfunction efx_ethtool_get_rxnfcfunction ip6_mask_is_fullfunction ip6_mask_is_emptyfunction efx_ethtool_set_class_rulefunction efx_ethtool_set_rxnfcfunction efx_ethtool_get_rxfh_indir_sizefunction efx_ethtool_get_rxfh_key_sizefunction efx_ethtool_get_rxfhfunction efx_ethtool_modify_rxfh_contextfunction efx_ethtool_create_rxfh_contextfunction efx_ethtool_remove_rxfh_contextfunction efx_ethtool_set_rxfhfunction efx_ethtool_resetfunction efx_ethtool_get_module_eepromfunction efx_ethtool_get_module_info
Annotated Snippet
struct efx_sw_stat_desc {
const char *name;
enum {
EFX_ETHTOOL_STAT_SOURCE_nic,
EFX_ETHTOOL_STAT_SOURCE_channel,
EFX_ETHTOOL_STAT_SOURCE_tx_queue
} source;
unsigned int offset;
u64 (*get_stat)(void *field); /* Reader function */
};
/* Initialiser for a struct efx_sw_stat_desc with type-checking */
#define EFX_ETHTOOL_STAT(stat_name, source_name, field, field_type, \
get_stat_function) { \
.name = #stat_name, \
.source = EFX_ETHTOOL_STAT_SOURCE_##source_name, \
.offset = ((((field_type *) 0) == \
&((struct efx_##source_name *)0)->field) ? \
offsetof(struct efx_##source_name, field) : \
offsetof(struct efx_##source_name, field)), \
.get_stat = get_stat_function, \
}
static u64 efx_get_uint_stat(void *field)
{
return *(unsigned int *)field;
}
static u64 efx_get_atomic_stat(void *field)
{
return atomic_read((atomic_t *) field);
}
#define EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(field) \
EFX_ETHTOOL_STAT(field, nic, field, \
atomic_t, efx_get_atomic_stat)
#define EFX_ETHTOOL_UINT_CHANNEL_STAT(field) \
EFX_ETHTOOL_STAT(field, channel, n_##field, \
unsigned int, efx_get_uint_stat)
#define EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(field) \
EFX_ETHTOOL_STAT(field, channel, field, \
unsigned int, efx_get_uint_stat)
#define EFX_ETHTOOL_UINT_TXQ_STAT(field) \
EFX_ETHTOOL_STAT(tx_##field, tx_queue, field, \
unsigned int, efx_get_uint_stat)
static const struct efx_sw_stat_desc efx_sw_stat_desc[] = {
EFX_ETHTOOL_UINT_TXQ_STAT(merge_events),
EFX_ETHTOOL_UINT_TXQ_STAT(tso_bursts),
EFX_ETHTOOL_UINT_TXQ_STAT(tso_long_headers),
EFX_ETHTOOL_UINT_TXQ_STAT(tso_packets),
EFX_ETHTOOL_UINT_TXQ_STAT(tso_fallbacks),
EFX_ETHTOOL_UINT_TXQ_STAT(pushes),
EFX_ETHTOOL_UINT_TXQ_STAT(pio_packets),
EFX_ETHTOOL_UINT_TXQ_STAT(cb_packets),
EFX_ETHTOOL_ATOMIC_NIC_ERROR_STAT(rx_reset),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_ip_hdr_chksum_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_tcp_udp_chksum_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_ip_hdr_chksum_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_inner_tcp_udp_chksum_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_ip_hdr_chksum_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_outer_tcp_udp_chksum_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_eth_crc_err),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_frm_trunc),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_overlength),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_events),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_merge_packets),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_drops),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_bad_drops),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_tx),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_xdp_redirect),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rx_mport_bad),
#ifdef CONFIG_RFS_ACCEL
EFX_ETHTOOL_UINT_CHANNEL_STAT_NO_N(rfs_filter_count),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_succeeded),
EFX_ETHTOOL_UINT_CHANNEL_STAT(rfs_failed),
#endif
};
#define EFX_ETHTOOL_SW_STAT_COUNT ARRAY_SIZE(efx_sw_stat_desc)
void efx_ethtool_get_drvinfo(struct net_device *net_dev,
struct ethtool_drvinfo *info)
{
struct efx_nic *efx = efx_netdev_priv(net_dev);
strscpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
efx_mcdi_print_fwver(efx, info->fw_version,
Annotation
- Immediate include surface: `linux/module.h`, `linux/netdevice.h`, `net_driver.h`, `mcdi.h`, `nic.h`, `selftest.h`, `rx_common.h`, `ethtool_common.h`.
- Detected declarations: `struct efx_sw_stat_desc`, `function offsetof`, `function efx_get_atomic_stat`, `function efx_ethtool_get_drvinfo`, `function efx_ethtool_get_msglevel`, `function efx_ethtool_set_msglevel`, `function efx_ethtool_self_test`, `function efx_ethtool_get_pauseparam`, `function efx_ethtool_set_pauseparam`, `function efx_fill_test`.
- 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.
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.