drivers/net/ethernet/amd/declance.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amd/declance.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amd/declance.c- Extension
.c- Size
- 35629 bytes
- Lines
- 1385
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/crc32.hlinux/delay.hlinux/errno.hlinux/if_ether.hlinux/init.hlinux/kernel.hlinux/module.hlinux/netdevice.hlinux/etherdevice.hlinux/spinlock.hlinux/stddef.hlinux/string.hlinux/tc.hlinux/types.hasm/addrspace.hasm/dec/interrupts.hasm/dec/ioasic.hasm/dec/ioasic_addrs.hasm/dec/kn01.hasm/dec/machtype.hasm/dec/system.h
Detected Declarations
struct lance_rx_descstruct lance_tx_descstruct lance_init_blockstruct lance_privatestruct lance_regsfunction writeregfunction load_csrsfunction cp_to_buffunction cp_from_buffunction lance_init_ringfunction init_restart_lancefunction lance_rxfunction lance_txfunction lance_dma_merr_intfunction lance_interruptfunction lance_openfunction lance_closefunction lance_resetfunction lance_tx_timeoutfunction lance_start_xmitfunction lance_load_multicastfunction lance_set_multicastfunction lance_set_multicast_retryfunction dec_lance_probefunction dec_lance_platform_probefunction dec_lance_platform_removefunction dec_lance_tc_probefunction dec_lance_removefunction dec_lance_tc_removefunction dec_lance_initfunction dec_lance_exitmodule init dec_lance_init
Annotated Snippet
static const struct net_device_ops lance_netdev_ops = {
.ndo_open = lance_open,
.ndo_stop = lance_close,
.ndo_start_xmit = lance_start_xmit,
.ndo_tx_timeout = lance_tx_timeout,
.ndo_set_rx_mode = lance_set_multicast,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};
static int dec_lance_probe(struct device *bdev, const int type)
{
static unsigned version_printed;
static const char fmt[] = "declance%d";
char name[10];
struct net_device *dev;
struct lance_private *lp;
volatile struct lance_regs *ll;
resource_size_t start = 0, len = 0;
int i, ret;
unsigned long esar_base;
unsigned char *esar;
u8 addr[ETH_ALEN];
const char *desc;
if (dec_lance_debug && version_printed++ == 0)
printk(version);
if (bdev)
snprintf(name, sizeof(name), "%s", dev_name(bdev));
else {
i = 0;
dev = root_lance_dev;
while (dev) {
i++;
lp = netdev_priv(dev);
dev = lp->next;
}
snprintf(name, sizeof(name), fmt, i);
}
dev = alloc_etherdev(sizeof(struct lance_private));
if (!dev) {
ret = -ENOMEM;
goto err_out;
}
/*
* alloc_etherdev ensures the data structures used by the LANCE
* are aligned.
*/
lp = netdev_priv(dev);
spin_lock_init(&lp->lock);
lp->type = type;
switch (type) {
case ASIC_LANCE:
dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE);
/* buffer space for the on-board LANCE shared memory */
/*
* FIXME: ugly hack!
*/
dev->mem_start = CKSEG1ADDR(0x00020000);
dev->mem_end = dev->mem_start + 0x00020000;
dev->irq = dec_interrupt[DEC_IRQ_LANCE];
esar_base = CKSEG1ADDR(dec_kn_slot_base + IOASIC_ESAR);
/* Workaround crash with booting KN04 2.1k from Disk */
memset((void *)dev->mem_start, 0,
dev->mem_end - dev->mem_start);
/*
* setup the pointer arrays, this sucks [tm] :-(
*/
for (i = 0; i < RX_RING_SIZE; i++) {
lp->rx_buf_ptr_cpu[i] =
(char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
2 * i * RX_BUFF_SIZE);
lp->rx_buf_ptr_lnc[i] =
(BUF_OFFSET_LNC + i * RX_BUFF_SIZE);
}
for (i = 0; i < TX_RING_SIZE; i++) {
lp->tx_buf_ptr_cpu[i] =
(char *)(dev->mem_start + 2 * BUF_OFFSET_CPU +
2 * RX_RING_SIZE * RX_BUFF_SIZE +
2 * i * TX_BUFF_SIZE);
lp->tx_buf_ptr_lnc[i] =
(BUF_OFFSET_LNC +
RX_RING_SIZE * RX_BUFF_SIZE +
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/delay.h`, `linux/errno.h`, `linux/if_ether.h`, `linux/init.h`, `linux/kernel.h`, `linux/module.h`, `linux/netdevice.h`.
- Detected declarations: `struct lance_rx_desc`, `struct lance_tx_desc`, `struct lance_init_block`, `struct lance_private`, `struct lance_regs`, `function writereg`, `function load_csrs`, `function cp_to_buf`, `function cp_from_buf`, `function lance_init_ring`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern 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.