drivers/net/ethernet/8390/lib8390.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/8390/lib8390.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/8390/lib8390.c- Extension
.c- Size
- 35478 bytes
- Lines
- 1092
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/build_bug.hlinux/module.hlinux/kernel.hlinux/jiffies.hlinux/fs.hlinux/types.hlinux/string.hlinux/bitops.hlinux/uaccess.hlinux/io.hasm/irq.hlinux/delay.hlinux/errno.hlinux/fcntl.hlinux/in.hlinux/interrupt.hlinux/init.hlinux/crc32.hlinux/netdevice.hlinux/etherdevice.h8390.h
Detected Declarations
function interruptsfunction ei_openfunction completedfunction __ei_start_xmitfunction __ei_interruptfunction __ei_pollfunction ei_tx_errfunction ei_tx_intrfunction packetfunction ei_rx_overrunfunction make_mc_bitsfunction netdev_for_each_mc_addrfunction do_set_multicast_listfunction __ei_set_multicast_listfunction ethdev_setupfunction __NS8390_initfunction NS8390_trigger_send
Annotated Snippet
if (output_page == ei_local->tx_start_page) {
ei_local->tx1 = -1;
ei_local->lasttx = -1;
} else {
ei_local->tx2 = -1;
ei_local->lasttx = -2;
}
} else
ei_local->txqueue++;
if (ei_local->tx1 && ei_local->tx2)
netif_stop_queue(dev);
else
netif_start_queue(dev);
/* Turn 8390 interrupts back on. */
ei_local->irqlock = 0;
ei_outb_p(ENISR_ALL, e8390_base + EN0_IMR);
spin_unlock(&ei_local->page_lock);
enable_irq_lockdep_irqrestore(dev->irq, &flags);
skb_tx_timestamp(skb);
dev_consume_skb_any(skb);
dev->stats.tx_bytes += send_length;
return NETDEV_TX_OK;
}
/**
* ei_interrupt - handle the interrupts from an 8390
* @irq: interrupt number
* @dev_id: a pointer to the net_device
*
* Handle the ether interface interrupts. We pull packets from
* the 8390 via the card specific functions and fire them at the networking
* stack. We also handle transmit completions and wake the transmit path if
* necessary. We also update the counters and do other housekeeping as
* needed.
*/
static irqreturn_t __ei_interrupt(int irq, void *dev_id)
{
struct net_device *dev = dev_id;
unsigned long e8390_base = dev->base_addr;
int interrupts, nr_serviced = 0;
struct ei_device *ei_local = netdev_priv(dev);
/*
* Protect the irq test too.
*/
spin_lock(&ei_local->page_lock);
if (ei_local->irqlock) {
/*
* This might just be an interrupt for a PCI device sharing
* this line
*/
netdev_err(dev, "Interrupted while interrupts are masked! isr=%#2x imr=%#2x\n",
ei_inb_p(e8390_base + EN0_ISR),
ei_inb_p(e8390_base + EN0_IMR));
spin_unlock(&ei_local->page_lock);
return IRQ_NONE;
}
/* Change to page 0 and read the intr status reg. */
ei_outb_p(E8390_NODMA+E8390_PAGE0, e8390_base + E8390_CMD);
netif_dbg(ei_local, intr, dev, "interrupt(isr=%#2.2x)\n",
ei_inb_p(e8390_base + EN0_ISR));
/* !!Assumption!! -- we stay in page 0. Don't break this. */
while ((interrupts = ei_inb_p(e8390_base + EN0_ISR)) != 0 &&
++nr_serviced < MAX_SERVICE) {
if (!netif_running(dev)) {
netdev_warn(dev, "interrupt from stopped card\n");
/* rmk - acknowledge the interrupts */
ei_outb_p(interrupts, e8390_base + EN0_ISR);
interrupts = 0;
break;
}
if (interrupts & ENISR_OVER)
ei_rx_overrun(dev);
else if (interrupts & (ENISR_RX+ENISR_RX_ERR)) {
/* Got a good (?) packet. */
ei_receive(dev);
}
/* Push the next to-transmit packet through. */
if (interrupts & ENISR_TX)
ei_tx_intr(dev);
else if (interrupts & ENISR_TX_ERR)
Annotation
- Immediate include surface: `linux/build_bug.h`, `linux/module.h`, `linux/kernel.h`, `linux/jiffies.h`, `linux/fs.h`, `linux/types.h`, `linux/string.h`, `linux/bitops.h`.
- Detected declarations: `function interrupts`, `function ei_open`, `function completed`, `function __ei_start_xmit`, `function __ei_interrupt`, `function __ei_poll`, `function ei_tx_err`, `function ei_tx_intr`, `function packet`, `function ei_rx_overrun`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source 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.