drivers/net/ethernet/dlink/dl2k.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/dlink/dl2k.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/dlink/dl2k.c- Extension
.c- Size
- 48892 bytes
- Lines
- 1889
- 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
dl2k.hlinux/dma-mapping.h
Detected Declarations
enum phy_ctrl_bitsfunction dl2k_enable_intfunction is_support_rmon_mmiofunction rio_probe1function strcmpfunction strcmpfunction strcmpfunction strcmpfunction strcmpfunction strcmpfunction find_miiphyfunction parse_eepromfunction rio_set_led_modefunction desc_to_dmafunction free_listfunction rio_reset_ringfunction alloc_listfunction rio_hw_initfunction rio_hw_stopfunction rio_openfunction rio_timerfunction rio_tx_timeoutfunction start_xmitfunction rio_interruptfunction rio_free_txfunction netif_wake_queuefunction tx_errorfunction receive_packetfunction rio_errorfunction get_statsfunction clear_statsfunction set_multicastfunction netdev_for_each_mc_addrfunction rio_get_drvinfofunction rio_get_link_ksettingsfunction rio_set_link_ksettingsfunction rio_get_linkfunction rio_ioctlfunction read_eepromfunction mii_sendbitfunction mii_getbitfunction mii_send_bitsfunction mii_readfunction mii_writefunction mii_wait_linkfunction mii_get_mediafunction mii_set_mediafunction mii_get_media_pcs
Annotated Snippet
static const struct net_device_ops netdev_ops = {
.ndo_open = rio_open,
.ndo_start_xmit = start_xmit,
.ndo_stop = rio_close,
.ndo_get_stats = get_stats,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_set_rx_mode = set_multicast,
.ndo_eth_ioctl = rio_ioctl,
.ndo_tx_timeout = rio_tx_timeout,
};
static bool is_support_rmon_mmio(struct pci_dev *pdev)
{
return pdev->vendor == PCI_VENDOR_ID_DLINK &&
pdev->device == 0x4000 &&
pdev->revision == 0x0c;
}
static int
rio_probe1 (struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct netdev_private *np;
static int card_idx;
int chip_idx = ent->driver_data;
int err, irq;
void __iomem *ioaddr;
void *ring_space;
dma_addr_t ring_dma;
err = pci_enable_device (pdev);
if (err)
return err;
irq = pdev->irq;
err = pci_request_regions (pdev, "dl2k");
if (err)
goto err_out_disable;
pci_set_master (pdev);
err = -ENOMEM;
dev = alloc_etherdev (sizeof (*np));
if (!dev)
goto err_out_res;
SET_NETDEV_DEV(dev, &pdev->dev);
np = netdev_priv(dev);
if (is_support_rmon_mmio(pdev))
np->rmon_enable = true;
/* IO registers range. */
ioaddr = pci_iomap(pdev, 0, 0);
if (!ioaddr)
goto err_out_dev;
np->eeprom_addr = ioaddr;
if (np->rmon_enable) {
/* MM registers range. */
ioaddr = pci_iomap(pdev, 1, 0);
if (!ioaddr)
goto err_out_iounmap;
}
np->ioaddr = ioaddr;
np->chip_id = chip_idx;
np->pdev = pdev;
spin_lock_init(&np->stats_lock);
spin_lock_init (&np->tx_lock);
spin_lock_init (&np->rx_lock);
/* Parse manual configuration */
np->an_enable = 1;
np->tx_coalesce = 1;
if (card_idx < MAX_UNITS) {
if (media[card_idx] != NULL) {
np->an_enable = 0;
if (strcmp (media[card_idx], "auto") == 0 ||
strcmp (media[card_idx], "autosense") == 0 ||
strcmp (media[card_idx], "0") == 0 ) {
np->an_enable = 2;
} else if (strcmp (media[card_idx], "100mbps_fd") == 0 ||
strcmp (media[card_idx], "4") == 0) {
np->speed = 100;
np->full_duplex = 1;
} else if (strcmp (media[card_idx], "100mbps_hd") == 0 ||
Annotation
- Immediate include surface: `dl2k.h`, `linux/dma-mapping.h`.
- Detected declarations: `enum phy_ctrl_bits`, `function dl2k_enable_int`, `function is_support_rmon_mmio`, `function rio_probe1`, `function strcmp`, `function strcmp`, `function strcmp`, `function strcmp`, `function strcmp`, `function strcmp`.
- 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.