drivers/net/ethernet/8390/ne2k-pci.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/8390/ne2k-pci.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/8390/ne2k-pci.c- Extension
.c- Size
- 20683 bytes
- Lines
- 724
- 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/module.hlinux/kernel.hlinux/errno.hlinux/pci.hlinux/init.hlinux/interrupt.hlinux/ethtool.hlinux/netdevice.hlinux/etherdevice.hlinux/io.hasm/irq.hlinux/uaccess.h8390.h
Detected Declarations
enum ne2k_pci_chipsetsfunction ne2k_pci_init_onefunction set_realtek_fdxfunction set_holtek_fdxfunction ne2k_pci_set_fdxfunction ne2k_pci_openfunction ne2k_pci_closefunction ne2k_pci_reset_8390function ne2k_pci_get_8390_hdrfunction ne2k_pci_block_inputfunction ne2k_pci_block_outputfunction ne2k_pci_get_drvinfofunction ne2k_pci_get_msglevelfunction ne2k_pci_set_msglevelfunction ne2k_pci_remove_onefunction ne2k_pci_suspendfunction ne2k_pci_resume
Annotated Snippet
static const struct net_device_ops ne2k_netdev_ops = {
.ndo_open = ne2k_pci_open,
.ndo_stop = ne2k_pci_close,
.ndo_start_xmit = ei_start_xmit,
.ndo_tx_timeout = ei_tx_timeout,
.ndo_get_stats = ei_get_stats,
.ndo_set_rx_mode = ei_set_multicast_list,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = ei_poll,
#endif
};
static int ne2k_pci_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct net_device *dev;
int i;
unsigned char SA_prom[32];
int start_page, stop_page;
int irq, reg0, chip_idx = ent->driver_data;
static unsigned int fnd_cnt;
long ioaddr;
int flags = pci_clone_list[chip_idx].flags;
struct ei_device *ei_local;
fnd_cnt++;
i = pci_enable_device(pdev);
if (i)
return i;
ioaddr = pci_resource_start(pdev, 0);
irq = pdev->irq;
if (!ioaddr || ((pci_resource_flags(pdev, 0) & IORESOURCE_IO) == 0)) {
dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n");
goto err_out;
}
if (!request_region(ioaddr, NE_IO_EXTENT, DRV_NAME)) {
dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n",
NE_IO_EXTENT, ioaddr);
goto err_out;
}
reg0 = inb(ioaddr);
if (reg0 == 0xFF)
goto err_out_free_res;
/* Do a preliminary verification that we have a 8390. */
{
int regd;
outb(E8390_NODMA + E8390_PAGE1 + E8390_STOP, ioaddr + E8390_CMD);
regd = inb(ioaddr + 0x0d);
outb(0xff, ioaddr + 0x0d);
outb(E8390_NODMA + E8390_PAGE0, ioaddr + E8390_CMD);
/* Clear the counter by reading. */
inb(ioaddr + EN0_COUNTER0);
if (inb(ioaddr + EN0_COUNTER0) != 0) {
outb(reg0, ioaddr);
/* Restore the old values. */
outb(regd, ioaddr + 0x0d);
goto err_out_free_res;
}
}
/* Allocate net_device, dev->priv; fill in 8390 specific dev fields. */
dev = alloc_ei_netdev();
if (!dev) {
dev_err(&pdev->dev, "cannot allocate ethernet device\n");
goto err_out_free_res;
}
dev->netdev_ops = &ne2k_netdev_ops;
ei_local = netdev_priv(dev);
ei_local->msg_enable = netif_msg_init(ne2k_msg_enable, default_msg_level);
SET_NETDEV_DEV(dev, &pdev->dev);
/* Reset card. Who knows what dain-bramaged state it was left in. */
{
unsigned long reset_start_time = jiffies;
outb(inb(ioaddr + NE_RESET), ioaddr + NE_RESET);
/* This looks like a horrible timing loop, but it should never
* take more than a few cycles.
*/
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/errno.h`, `linux/pci.h`, `linux/init.h`, `linux/interrupt.h`, `linux/ethtool.h`, `linux/netdevice.h`.
- Detected declarations: `enum ne2k_pci_chipsets`, `function ne2k_pci_init_one`, `function set_realtek_fdx`, `function set_holtek_fdx`, `function ne2k_pci_set_fdx`, `function ne2k_pci_open`, `function ne2k_pci_close`, `function ne2k_pci_reset_8390`, `function ne2k_pci_get_8390_hdr`, `function ne2k_pci_block_input`.
- 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.