drivers/net/ethernet/natsemi/xtsonic.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/natsemi/xtsonic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/natsemi/xtsonic.c- Extension
.c- Size
- 6565 bytes
- Lines
- 274
- 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.
- 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/kernel.hlinux/module.hlinux/types.hlinux/fcntl.hlinux/gfp.hlinux/interrupt.hlinux/init.hlinux/ioport.hlinux/in.hlinux/string.hlinux/delay.hlinux/errno.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/platform_device.hlinux/dma-mapping.hlinux/slab.hlinux/pgtable.hasm/io.hasm/dma.hsonic.hsonic.c
Detected Declarations
function xtsonic_openfunction xtsonic_closefunction sonic_probe1function xtsonic_probefunction xtsonic_device_remove
Annotated Snippet
static const struct net_device_ops xtsonic_netdev_ops = {
.ndo_open = xtsonic_open,
.ndo_stop = xtsonic_close,
.ndo_start_xmit = sonic_send_packet,
.ndo_get_stats = sonic_get_stats,
.ndo_set_rx_mode = sonic_multicast_list,
.ndo_tx_timeout = sonic_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
};
static int sonic_probe1(struct net_device *dev)
{
unsigned int silicon_revision;
struct sonic_local *lp = netdev_priv(dev);
unsigned int base_addr = dev->base_addr;
int i;
int err = 0;
unsigned char addr[ETH_ALEN];
if (!request_mem_region(base_addr, 0x100, xtsonic_string))
return -EBUSY;
/*
* get the Silicon Revision ID. If this is one of the known
* one assume that we found a SONIC ethernet controller at
* the expected location.
*/
silicon_revision = SONIC_READ(SONIC_SR);
i = 0;
while ((known_revisions[i] != 0xffff) &&
(known_revisions[i] != silicon_revision))
i++;
if (known_revisions[i] == 0xffff) {
pr_info("SONIC ethernet controller not found (0x%4x)\n",
silicon_revision);
return -ENODEV;
}
/*
* Put the sonic into software reset, then retrieve ethernet address.
* Note: we are assuming that the boot-loader has initialized the cam.
*/
SONIC_WRITE(SONIC_CMD,SONIC_CR_RST);
SONIC_WRITE(SONIC_DCR,
SONIC_DCR_WC0|SONIC_DCR_DW|SONIC_DCR_LBR|SONIC_DCR_SBUS);
SONIC_WRITE(SONIC_CEP,0);
SONIC_WRITE(SONIC_IMR,0);
SONIC_WRITE(SONIC_CMD,SONIC_CR_RST);
SONIC_WRITE(SONIC_CEP,0);
for (i=0; i<3; i++) {
unsigned int val = SONIC_READ(SONIC_CAP0-i);
addr[i*2] = val;
addr[i*2+1] = val >> 8;
}
eth_hw_addr_set(dev, addr);
lp->dma_bitmode = SONIC_BITMODE32;
err = sonic_alloc_descriptors(dev);
if (err)
goto out;
dev->netdev_ops = &xtsonic_netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
/*
* clear tally counter
*/
SONIC_WRITE(SONIC_CRCT,0xffff);
SONIC_WRITE(SONIC_FAET,0xffff);
SONIC_WRITE(SONIC_MPT,0xffff);
return 0;
out:
release_region(dev->base_addr, SONIC_MEM_SIZE);
return err;
}
/*
* Probe for a SONIC ethernet controller on an XT2000 board.
* Actually probing is superfluous but we're paranoid.
*/
int xtsonic_probe(struct platform_device *pdev)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/types.h`, `linux/fcntl.h`, `linux/gfp.h`, `linux/interrupt.h`, `linux/init.h`, `linux/ioport.h`.
- Detected declarations: `function xtsonic_open`, `function xtsonic_close`, `function sonic_probe1`, `function xtsonic_probe`, `function xtsonic_device_remove`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.