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.

Dependency Surface

Detected Declarations

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

Implementation Notes