drivers/net/ethernet/amd/sunlance.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/amd/sunlance.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/amd/sunlance.c- Extension
.c- Size
- 40355 bytes
- Lines
- 1521
- 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/module.hlinux/kernel.hlinux/types.hlinux/fcntl.hlinux/interrupt.hlinux/ioport.hlinux/in.hlinux/string.hlinux/delay.hlinux/crc32.hlinux/errno.hlinux/socket.hlinux/route.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/ethtool.hlinux/bitops.hlinux/dma-mapping.hlinux/of.hlinux/platform_device.hlinux/gfp.hlinux/pgtable.hasm/io.hasm/dma.hasm/byteorder.hasm/idprom.hasm/prom.hasm/auxio.hasm/irq.h
Detected Declarations
struct lance_rx_descstruct lance_tx_descstruct lance_init_blockstruct lance_privatefunction load_csrsfunction lance_init_ring_dvmafunction lance_init_ring_piofunction init_restart_ledmafunction init_restart_lancefunction lance_rx_dvmafunction lance_tx_dvmafunction lance_piocopy_to_skbfunction lance_rx_piofunction lance_tx_piofunction lance_interruptfunction build_fake_packetfunction lance_openfunction lance_init_ringfunction lance_closefunction lance_resetfunction lance_piocopy_from_skbfunction lance_piozerofunction lance_tx_timeoutfunction lance_start_xmitfunction lance_load_multicastfunction lance_set_multicastfunction lance_set_multicast_retryfunction lance_free_hwresourcesfunction sparc_lance_get_drvinfofunction sparc_lance_probe_onefunction sunlance_sbus_probefunction sunlance_sbus_remove
Annotated Snippet
static const struct net_device_ops sparc_lance_ops = {
.ndo_open = lance_open,
.ndo_stop = lance_close,
.ndo_start_xmit = lance_start_xmit,
.ndo_set_rx_mode = lance_set_multicast,
.ndo_tx_timeout = lance_tx_timeout,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
static int sparc_lance_probe_one(struct platform_device *op,
struct platform_device *ledma,
struct platform_device *lebuffer)
{
struct device_node *dp = op->dev.of_node;
struct lance_private *lp;
struct net_device *dev;
dev = alloc_etherdev(sizeof(struct lance_private) + 8);
if (!dev)
return -ENOMEM;
lp = netdev_priv(dev);
spin_lock_init(&lp->lock);
/* Copy the IDPROM ethernet address to the device structure, later we
* will copy the address in the device structure to the lance
* initialization block.
*/
eth_hw_addr_set(dev, idprom->id_ethaddr);
/* Get the IO region */
lp->lregs = of_ioremap(&op->resource[0], 0,
LANCE_REG_SIZE, lancestr);
if (!lp->lregs) {
printk(KERN_ERR "SunLance: Cannot map registers.\n");
goto fail;
}
lp->ledma = ledma;
if (lp->ledma) {
lp->dregs = of_ioremap(&ledma->resource[0], 0,
resource_size(&ledma->resource[0]),
"ledma");
if (!lp->dregs) {
printk(KERN_ERR "SunLance: Cannot map "
"ledma registers.\n");
goto fail;
}
}
lp->op = op;
lp->lebuffer = lebuffer;
if (lebuffer) {
/* sanity check */
if (lebuffer->resource[0].start & 7) {
printk(KERN_ERR "SunLance: ERROR: Rx and Tx rings not on even boundary.\n");
goto fail;
}
lp->init_block_iomem =
of_ioremap(&lebuffer->resource[0], 0,
sizeof(struct lance_init_block), "lebuffer");
if (!lp->init_block_iomem) {
printk(KERN_ERR "SunLance: Cannot map PIO buffer.\n");
goto fail;
}
lp->init_block_dvma = 0;
lp->pio_buffer = 1;
lp->init_ring = lance_init_ring_pio;
lp->rx = lance_rx_pio;
lp->tx = lance_tx_pio;
} else {
lp->init_block_mem =
dma_alloc_coherent(&op->dev,
sizeof(struct lance_init_block),
&lp->init_block_dvma, GFP_ATOMIC);
if (!lp->init_block_mem)
goto fail;
lp->pio_buffer = 0;
lp->init_ring = lance_init_ring_dvma;
lp->rx = lance_rx_dvma;
lp->tx = lance_tx_dvma;
}
lp->busmaster_regval = of_getintprop_default(dp, "busmaster-regval",
(LE_C3_BSWP |
LE_C3_ACON |
LE_C3_BCON));
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/types.h`, `linux/fcntl.h`, `linux/interrupt.h`, `linux/ioport.h`, `linux/in.h`, `linux/string.h`.
- Detected declarations: `struct lance_rx_desc`, `struct lance_tx_desc`, `struct lance_init_block`, `struct lance_private`, `function load_csrs`, `function lance_init_ring_dvma`, `function lance_init_ring_pio`, `function init_restart_ledma`, `function init_restart_lance`, `function lance_rx_dvma`.
- 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.