drivers/net/ethernet/sfc/falcon/selftest.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/sfc/falcon/selftest.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/sfc/falcon/selftest.c- Extension
.c- Size
- 22704 bytes
- Lines
- 816
- 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.hnic.hselftest.hworkarounds.h
Detected Declarations
struct ef4_loopback_payloadstruct ef4_loopback_statefunction ef4_test_phy_alivefunction ef4_test_nvramfunction ef4_test_interruptsfunction ef4_test_eventq_irqfunction ef4_for_each_channelfunction ef4_for_each_channelfunction ef4_for_each_channelfunction ef4_test_phyfunction ef4_loopback_rx_packetfunction ef4_iterate_statefunction ef4_begin_loopbackfunction ef4_poll_loopbackfunction ef4_end_loopbackfunction ef4_test_loopbackfunction lockfunction ef4_test_loopbacksfunction ef4_for_each_channel_tx_queuefunction ef4_selftestfunction ef4_selftest_async_startfunction ef4_selftest_async_cancelfunction ef4_selftest_async_workfunction ef4_for_each_channel
Annotated Snippet
struct ef4_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 EF4_LOOPBACK_PAYLOAD_LEN \
sizeof_field(struct ef4_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 ef4_interrupt_mode_max = EF4_INT_MODE_MAX;
static const char *const ef4_interrupt_mode_names[] = {
[EF4_INT_MODE_MSIX] = "MSI-X",
[EF4_INT_MODE_MSI] = "MSI",
[EF4_INT_MODE_LEGACY] = "legacy",
};
#define INT_MODE(efx) \
STRING_TABLE_LOOKUP(efx->interrupt_mode, ef4_interrupt_mode)
/**
* struct ef4_loopback_state - persistent state during a loopback selftest
* @flush: Drop all packets in ef4_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 ef4_loopback_state {
bool flush;
int packet_count;
struct sk_buff **skbs;
bool offload_csum;
atomic_t rx_good;
atomic_t rx_bad;
struct ef4_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 ef4_test_phy_alive(struct ef4_nic *efx, struct ef4_self_tests *tests)
{
int rc = 0;
if (efx->phy_op->test_alive) {
rc = efx->phy_op->test_alive(efx);
tests->phy_alive = rc ? -1 : 1;
}
return rc;
}
static int ef4_test_nvram(struct ef4_nic *efx, struct ef4_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 ef4_loopback_payload`, `struct ef4_loopback_state`, `function ef4_test_phy_alive`, `function ef4_test_nvram`, `function ef4_test_interrupts`, `function ef4_test_eventq_irq`, `function ef4_for_each_channel`, `function ef4_for_each_channel`, `function ef4_for_each_channel`, `function ef4_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.