drivers/net/ethernet/sfc/siena/selftest.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/siena/selftest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/siena/selftest.c- Extension
.c- Size
- 23008 bytes
- Lines
- 819
- 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/netdevice.hlinux/module.hlinux/delay.hlinux/kernel_stat.hlinux/pci.hlinux/ethtool.hlinux/ip.hlinux/in.hlinux/udp.hlinux/rtnetlink.hlinux/slab.hnet_driver.hefx.hefx_common.hefx_channels.hnic.hmcdi_port_common.hselftest.hworkarounds.h
Detected Declarations
struct efx_loopback_payloadstruct efx_loopback_statefunction efx_test_phy_alivefunction efx_test_nvramfunction efx_test_interruptsfunction efx_test_eventq_irqfunction efx_for_each_channelfunction efx_for_each_channelfunction efx_for_each_channelfunction efx_test_phyfunction efx_siena_loopback_rx_packetfunction efx_iterate_statefunction efx_begin_loopbackfunction efx_poll_loopbackfunction efx_end_loopbackfunction efx_test_loopbackfunction lockfunction efx_test_loopbacksfunction efx_for_each_channel_tx_queuefunction efx_siena_selftestfunction efx_siena_selftest_async_startfunction efx_siena_selftest_async_cancelfunction efx_siena_selftest_async_workfunction efx_for_each_channelfunction efx_siena_selftest_async_init
Annotated Snippet
struct efx_loopback_payload {
char pad[2]; /* Ensures ip is 4-byte aligned */
struct_group_attr(packet, __packed,
struct ethhdr header;
struct iphdr ip;
struct udphdr udp;
__be16 iteration;
char msg[64];
);
} __packed __aligned(4);
#define EFX_LOOPBACK_PAYLOAD_LEN \
sizeof_field(struct efx_loopback_payload, packet)
/* Loopback test source MAC address */
static const u8 payload_source[ETH_ALEN] __aligned(2) = {
0x00, 0x0f, 0x53, 0x1b, 0x1b, 0x1b,
};
static const char payload_msg[] =
"Hello world! This is an Efx loopback test in progress!";
/* Interrupt mode names */
static const unsigned int efx_siena_interrupt_mode_max = EFX_INT_MODE_MAX;
static const char *const efx_siena_interrupt_mode_names[] = {
[EFX_INT_MODE_MSIX] = "MSI-X",
[EFX_INT_MODE_MSI] = "MSI",
[EFX_INT_MODE_LEGACY] = "legacy",
};
#define INT_MODE(efx) \
STRING_TABLE_LOOKUP(efx->interrupt_mode, efx_siena_interrupt_mode)
/**
* struct efx_loopback_state - persistent state during a loopback selftest
* @flush: Drop all packets in efx_siena_loopback_rx_packet
* @packet_count: Number of packets being used in this test
* @skbs: An array of skbs transmitted
* @offload_csum: Checksums are being offloaded
* @rx_good: RX good packet count
* @rx_bad: RX bad packet count
* @payload: Payload used in tests
*/
struct efx_loopback_state {
bool flush;
int packet_count;
struct sk_buff **skbs;
bool offload_csum;
atomic_t rx_good;
atomic_t rx_bad;
struct efx_loopback_payload payload;
};
/* How long to wait for all the packets to arrive (in ms) */
#define LOOPBACK_TIMEOUT_MS 1000
/**************************************************************************
*
* MII, NVRAM and register tests
*
**************************************************************************/
static int efx_test_phy_alive(struct efx_nic *efx, struct efx_self_tests *tests)
{
int rc = 0;
rc = efx_siena_mcdi_phy_test_alive(efx);
tests->phy_alive = rc ? -1 : 1;
return rc;
}
static int efx_test_nvram(struct efx_nic *efx, struct efx_self_tests *tests)
{
int rc = 0;
if (efx->type->test_nvram) {
rc = efx->type->test_nvram(efx);
if (rc == -EPERM)
rc = 0;
else
tests->nvram = rc ? -1 : 1;
}
return rc;
}
/**************************************************************************
*
* Interrupt and event queue testing
*
**************************************************************************/
Annotation
- Immediate include surface: `linux/netdevice.h`, `linux/module.h`, `linux/delay.h`, `linux/kernel_stat.h`, `linux/pci.h`, `linux/ethtool.h`, `linux/ip.h`, `linux/in.h`.
- Detected declarations: `struct efx_loopback_payload`, `struct efx_loopback_state`, `function efx_test_phy_alive`, `function efx_test_nvram`, `function efx_test_interrupts`, `function efx_test_eventq_irq`, `function efx_for_each_channel`, `function efx_for_each_channel`, `function efx_for_each_channel`, `function efx_test_phy`.
- 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.