drivers/net/ethernet/3com/3c509.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/3com/3c509.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/3com/3c509.c- Extension
.c- Size
- 39966 bytes
- Lines
- 1544
- 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/bitops.hlinux/delay.hlinux/device.hlinux/eisa.hlinux/errno.hlinux/etherdevice.hlinux/ethtool.hlinux/in.hlinux/init.hlinux/interrupt.hlinux/io.hlinux/ioport.hlinux/isa.hlinux/module.hlinux/netdevice.hlinux/pm.hlinux/pnp.hlinux/skbuff.hlinux/spinlock.hlinux/string.hlinux/uaccess.hasm/irq.h
Detected Declarations
struct el3_privateenum c509cmdenum c509statusenum rx_filterenum el3_cardtypefunction el3_isa_id_sequencefunction el3_dev_fillfunction el3_isa_matchfunction el3_isa_removefunction el3_isa_suspendfunction el3_isa_resumefunction el3_pnp_probefunction el3_pnp_removefunction el3_pnp_suspendfunction el3_pnp_resumefunction el3_common_initfunction el3_common_removefunction el3_eisa_probefunction el3_device_removefunction read_eepromfunction id_read_eepromfunction el3_openfunction el3_tx_timeoutfunction el3_start_xmitfunction el3_interruptfunction el3_poll_controllerfunction update_statsfunction el3_rxfunction set_multicast_listfunction el3_closefunction el3_link_okfunction el3_netdev_get_ecmdfunction el3_netdev_set_ecmdfunction el3_get_drvinfofunction el3_get_link_ksettingsfunction el3_set_link_ksettingsfunction el3_get_linkfunction el3_get_msglevelfunction el3_set_msglevelfunction el3_downfunction el3_upfunction el3_suspendfunction el3_resumefunction el3_init_modulefunction el3_cleanup_modulemodule init el3_init_module
Annotated Snippet
static const struct net_device_ops netdev_ops = {
.ndo_open = el3_open,
.ndo_stop = el3_close,
.ndo_start_xmit = el3_start_xmit,
.ndo_get_stats = el3_get_stats,
.ndo_set_rx_mode = set_multicast_list,
.ndo_tx_timeout = el3_tx_timeout,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = el3_poll_controller,
#endif
};
static int el3_common_init(struct net_device *dev)
{
static const char *const if_names[] = {
"10baseT", "AUI", "undefined", "BNC"
};
struct el3_private *lp = netdev_priv(dev);
int err;
spin_lock_init(&lp->lock);
if (dev->mem_start & 0x05) { /* xcvr codes 1/3/4/12 */
dev->if_port = (dev->mem_start & 0x0f);
} else { /* xcvr codes 0/8 */
/* use eeprom value, but save user's full-duplex selection */
dev->if_port |= (dev->mem_start & 0x08);
}
/* The EL3-specific entries in the device structure. */
dev->netdev_ops = &netdev_ops;
dev->watchdog_timeo = TX_TIMEOUT;
dev->ethtool_ops = ðtool_ops;
err = register_netdev(dev);
if (err) {
pr_err("Failed to register 3c5x9 at %#3.3lx, IRQ %d.\n",
dev->base_addr, dev->irq);
release_region(dev->base_addr, EL3_IO_EXTENT);
return err;
}
pr_info("%s: 3c5x9 found at %#3.3lx, %s port, address %pM, IRQ %d.\n",
dev->name, dev->base_addr, if_names[(dev->if_port & 0x03)],
dev->dev_addr, dev->irq);
return 0;
}
static void el3_common_remove(struct net_device *dev)
{
unregister_netdev(dev);
release_region(dev->base_addr, EL3_IO_EXTENT);
free_netdev(dev);
}
#ifdef CONFIG_EISA
static int el3_eisa_probe(struct device *device)
{
struct net_device *dev = NULL;
struct eisa_device *edev;
int ioaddr, irq, if_port;
__be16 phys_addr[3];
short i;
int err;
/* Yeepee, The driver framework is calling us ! */
edev = to_eisa_device(device);
ioaddr = edev->base_addr;
if (!request_region(ioaddr, EL3_IO_EXTENT, "3c579-eisa"))
return -EBUSY;
/* Change the register set to the configuration window 0. */
outw(SELECT_WINDOW | 0, ioaddr + 0xC80 + EL3_CMD);
irq = inw(ioaddr + WN0_IRQ) >> 12;
if_port = inw(ioaddr + 6) >> 14;
for (i = 0; i < 3; i++)
phys_addr[i] = htons(read_eeprom(ioaddr, i));
/* Restore the "Product ID" to the EEPROM read register. */
read_eeprom(ioaddr, 3);
dev = alloc_etherdev(sizeof(struct el3_private));
if (!dev) {
release_region(ioaddr, EL3_IO_EXTENT);
return -ENOMEM;
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/delay.h`, `linux/device.h`, `linux/eisa.h`, `linux/errno.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/in.h`.
- Detected declarations: `struct el3_private`, `enum c509cmd`, `enum c509status`, `enum rx_filter`, `enum el3_cardtype`, `function el3_isa_id_sequence`, `function el3_dev_fill`, `function el3_isa_match`, `function el3_isa_remove`, `function el3_isa_suspend`.
- 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.