drivers/net/ethernet/nvidia/forcedeth.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/nvidia/forcedeth.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/nvidia/forcedeth.c
Extension
.c
Size
195580 bytes
Lines
6492
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 nv_netdev_ops = {
	.ndo_open		= nv_open,
	.ndo_stop		= nv_close,
	.ndo_get_stats64	= nv_get_stats64,
	.ndo_start_xmit		= nv_start_xmit,
	.ndo_tx_timeout		= nv_tx_timeout,
	.ndo_change_mtu		= nv_change_mtu,
	.ndo_fix_features	= nv_fix_features,
	.ndo_set_features	= nv_set_features,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= nv_set_mac_address,
	.ndo_set_rx_mode	= nv_set_multicast,
#ifdef CONFIG_NET_POLL_CONTROLLER
	.ndo_poll_controller	= nv_poll_controller,
#endif
};

static const struct net_device_ops nv_netdev_ops_optimized = {
	.ndo_open		= nv_open,
	.ndo_stop		= nv_close,
	.ndo_get_stats64	= nv_get_stats64,
	.ndo_start_xmit		= nv_start_xmit_optimized,
	.ndo_tx_timeout		= nv_tx_timeout,
	.ndo_change_mtu		= nv_change_mtu,
	.ndo_fix_features	= nv_fix_features,
	.ndo_set_features	= nv_set_features,
	.ndo_validate_addr	= eth_validate_addr,
	.ndo_set_mac_address	= nv_set_mac_address,
	.ndo_set_rx_mode	= nv_set_multicast,
#ifdef CONFIG_NET_POLL_CONTROLLER
	.ndo_poll_controller	= nv_poll_controller,
#endif
};

static int nv_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
{
	struct net_device *dev;
	struct fe_priv *np;
	unsigned long addr;
	u8 __iomem *base;
	int err, i;
	u32 powerstate, txreg;
	u32 phystate_orig = 0, phystate;
	int phyinitialized = 0;
	static int printed_version;
	u8 mac[ETH_ALEN];

	if (!printed_version++)
		pr_info("Reverse Engineered nForce ethernet driver. Version %s.\n",
			FORCEDETH_VERSION);

	dev = alloc_etherdev(sizeof(struct fe_priv));
	err = -ENOMEM;
	if (!dev)
		goto out;

	np = netdev_priv(dev);
	np->dev = dev;
	np->pci_dev = pci_dev;
	spin_lock_init(&np->lock);
	spin_lock_init(&np->hwstats_lock);
	SET_NETDEV_DEV(dev, &pci_dev->dev);
	u64_stats_init(&np->swstats_rx_syncp);
	u64_stats_init(&np->swstats_tx_syncp);
	np->txrx_stats = alloc_percpu(struct nv_txrx_stats);
	if (!np->txrx_stats) {
		pr_err("np->txrx_stats, alloc memory error.\n");
		err = -ENOMEM;
		goto out_alloc_percpu;
	}

	timer_setup(&np->oom_kick, nv_do_rx_refill, 0);
	timer_setup(&np->nic_poll, nv_do_nic_poll, 0);
	timer_setup(&np->stats_poll, nv_do_stats_poll, TIMER_DEFERRABLE);

	err = pci_enable_device(pci_dev);
	if (err)
		goto out_free;

	pci_set_master(pci_dev);

	err = pci_request_regions(pci_dev, DRV_NAME);
	if (err < 0)
		goto out_disable;

	if (id->driver_data & (DEV_HAS_VLAN|DEV_HAS_MSI_X|DEV_HAS_POWER_CNTRL|DEV_HAS_STATISTICS_V2|DEV_HAS_STATISTICS_V3))
		np->register_size = NV_PCI_REGSZ_VER3;
	else if (id->driver_data & DEV_HAS_STATISTICS_V1)
		np->register_size = NV_PCI_REGSZ_VER2;
	else

Annotation

Implementation Notes