drivers/net/ethernet/realtek/8139too.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/realtek/8139too.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/realtek/8139too.c- Extension
.c- Size
- 71625 bytes
- Lines
- 2643
- 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/compiler.hlinux/pci.hlinux/init.hlinux/interrupt.hlinux/netdevice.hlinux/etherdevice.hlinux/rtnetlink.hlinux/delay.hlinux/ethtool.hlinux/mii.hlinux/completion.hlinux/crc32.hlinux/io.hlinux/uaccess.hlinux/gfp.hlinux/if_vlan.hasm/irq.h
Detected Declarations
struct rtl_extra_statsstruct rtl8139_statsstruct rtl8139_privateenum RTL8139_registersenum ClearBitMasksenum ChipCmdBitsenum IntrStatusBitsenum TxStatusBitsenum RxStatusBitsenum rx_mode_bitsenum tx_config_bitsenum Config1Bitsenum Config3Bitsenum Config4Bitsenum Config5Bitsenum RxConfigBitsenum CSCRBitsenum Cfg9346Bitsenum chip_flagsenum TwisterParamValsfunction Licensefunction __rtl8139_cleanup_devfunction rtl8139_chip_resetfunction rtl8139_set_featuresfunction rtl8139_init_onefunction openfunction rtl8139_remove_onefunction read_eepromfunction mdio_syncfunction mdio_readfunction mdio_writefunction rtl8139_openfunction rtl_check_mediafunction rtl8139_hw_startfunction rtl8139_init_ringfunction rtl8139_tune_twisterfunction rtl8139_tune_twisterfunction rtl8139_thread_iterfunction rtl8139_threadfunction rtl8139_start_threadfunction rtl8139_tx_clearfunction rtl8139_tx_timeout_taskfunction rtl8139_tx_timeoutfunction rtl8139_start_xmitfunction rtl8139_tx_interruptfunction rtl8139_rx_errfunction wrap_copyfunction rtl8139_isr_ack
Annotated Snippet
static const struct net_device_ops rtl8139_netdev_ops = {
.ndo_open = rtl8139_open,
.ndo_stop = rtl8139_close,
.ndo_get_stats64 = rtl8139_get_stats64,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = rtl8139_set_mac_address,
.ndo_start_xmit = rtl8139_start_xmit,
.ndo_set_rx_mode = rtl8139_set_rx_mode,
.ndo_eth_ioctl = netdev_ioctl,
.ndo_tx_timeout = rtl8139_tx_timeout,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = rtl8139_poll_controller,
#endif
.ndo_set_features = rtl8139_set_features,
};
static int rtl8139_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct net_device *dev = NULL;
struct rtl8139_private *tp;
__le16 addr[ETH_ALEN / 2];
int i, addr_len, option;
void __iomem *ioaddr;
static int board_idx = -1;
assert (pdev != NULL);
assert (ent != NULL);
board_idx++;
if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
pdev->device == PCI_DEVICE_ID_REALTEK_8139 && pdev->revision >= 0x20) {
dev_info(&pdev->dev,
"This (id %04x:%04x rev %02x) is an enhanced 8139C+ chip, use 8139cp\n",
pdev->vendor, pdev->device, pdev->revision);
return -ENODEV;
}
if (pdev->vendor == PCI_VENDOR_ID_REALTEK &&
pdev->device == PCI_DEVICE_ID_REALTEK_8139 &&
pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS &&
pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) {
pr_info("OQO Model 2 detected. Forcing PIO\n");
use_io = true;
}
dev = rtl8139_init_board (pdev);
if (IS_ERR(dev))
return PTR_ERR(dev);
assert (dev != NULL);
tp = netdev_priv(dev);
tp->dev = dev;
ioaddr = tp->mmio_addr;
assert (ioaddr != NULL);
addr_len = read_eeprom (ioaddr, 0, 8) == 0x8129 ? 8 : 6;
for (i = 0; i < 3; i++)
addr[i] = cpu_to_le16(read_eeprom (ioaddr, i + 7, addr_len));
eth_hw_addr_set(dev, (u8 *)addr);
/* The Rtl8139-specific entries in the device structure. */
dev->netdev_ops = &rtl8139_netdev_ops;
dev->ethtool_ops = &rtl8139_ethtool_ops;
dev->watchdog_timeo = TX_TIMEOUT;
netif_napi_add(dev, &tp->napi, rtl8139_poll);
/* note: the hardware is not capable of sg/csum/highdma, however
* through the use of skb_copy_and_csum_dev we enable these
* features
*/
dev->features |= NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA;
dev->vlan_features = dev->features;
dev->hw_features |= NETIF_F_RXALL;
dev->hw_features |= NETIF_F_RXFCS;
/* MTU range: 68 - 1770 */
dev->min_mtu = ETH_MIN_MTU;
dev->max_mtu = MAX_ETH_DATA_SIZE;
/* tp zeroed and aligned in alloc_etherdev */
tp = netdev_priv(dev);
/* note: tp->chipset set in rtl8139_init_board */
tp->drv_flags = board_info[ent->driver_data].hw_flags;
tp->mmio_addr = ioaddr;
tp->msg_enable =
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/compiler.h`, `linux/pci.h`, `linux/init.h`, `linux/interrupt.h`, `linux/netdevice.h`, `linux/etherdevice.h`.
- Detected declarations: `struct rtl_extra_stats`, `struct rtl8139_stats`, `struct rtl8139_private`, `enum RTL8139_registers`, `enum ClearBitMasks`, `enum ChipCmdBits`, `enum IntrStatusBits`, `enum TxStatusBits`, `enum RxStatusBits`, `enum rx_mode_bits`.
- 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.