drivers/net/ethernet/adaptec/starfire.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/adaptec/starfire.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/adaptec/starfire.c
Extension
.c
Size
62815 bytes
Lines
2067
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		= netdev_open,
	.ndo_stop		= netdev_close,
	.ndo_start_xmit		= start_tx,
	.ndo_tx_timeout		= tx_timeout,
	.ndo_get_stats		= get_stats,
	.ndo_set_rx_mode	= set_rx_mode,
	.ndo_eth_ioctl		= netdev_ioctl,
	.ndo_set_mac_address	= eth_mac_addr,
	.ndo_validate_addr	= eth_validate_addr,
#ifdef VLAN_SUPPORT
	.ndo_vlan_rx_add_vid	= netdev_vlan_rx_add_vid,
	.ndo_vlan_rx_kill_vid	= netdev_vlan_rx_kill_vid,
#endif
};

static int starfire_init_one(struct pci_dev *pdev,
			     const struct pci_device_id *ent)
{
	struct device *d = &pdev->dev;
	struct netdev_private *np;
	int i, irq, chip_idx = ent->driver_data;
	struct net_device *dev;
	u8 addr[ETH_ALEN];
	long ioaddr;
	void __iomem *base;
	int drv_flags, io_size;
	int boguscnt;

	if (pci_enable_device (pdev))
		return -EIO;

	ioaddr = pci_resource_start(pdev, 0);
	io_size = pci_resource_len(pdev, 0);
	if (!ioaddr || ((pci_resource_flags(pdev, 0) & IORESOURCE_MEM) == 0)) {
		dev_err(d, "no PCI MEM resources, aborting\n");
		return -ENODEV;
	}

	dev = alloc_etherdev(sizeof(*np));
	if (!dev)
		return -ENOMEM;

	SET_NETDEV_DEV(dev, &pdev->dev);

	irq = pdev->irq;

	if (pci_request_regions (pdev, DRV_NAME)) {
		dev_err(d, "cannot reserve PCI resources, aborting\n");
		goto err_out_free_netdev;
	}

	base = ioremap(ioaddr, io_size);
	if (!base) {
		dev_err(d, "cannot remap %#x @ %#lx, aborting\n",
			io_size, ioaddr);
		goto err_out_free_res;
	}

	pci_set_master(pdev);

	/* enable MWI -- it vastly improves Rx performance on sparc64 */
	pci_try_set_mwi(pdev);

#ifdef ZEROCOPY
	/* Starfire can do TCP/UDP checksumming */
	if (enable_hw_cksum)
		dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
#endif /* ZEROCOPY */

#ifdef VLAN_SUPPORT
	dev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_CTAG_FILTER;
#endif /* VLAN_RX_KILL_VID */
#ifdef ADDR_64BITS
	dev->features |= NETIF_F_HIGHDMA;
#endif /* ADDR_64BITS */

	/* Serial EEPROM reads are hidden by the hardware. */
	for (i = 0; i < 6; i++)
		addr[i] = readb(base + EEPROMCtrl + 20 - i);
	eth_hw_addr_set(dev, addr);

#if ! defined(final_version) /* Dump the EEPROM contents during development. */
	if (debug > 4)
		for (i = 0; i < 0x20; i++)
			printk("%2.2x%s",
			       (unsigned int)readb(base + EEPROMCtrl + i),
			       i % 16 != 15 ? " " : "\n");
#endif

Annotation

Implementation Notes