drivers/net/ethernet/atheros/alx/main.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/atheros/alx/main.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/atheros/alx/main.c- Extension
.c- Size
- 48459 bytes
- Lines
- 2058
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/pci.hlinux/interrupt.hlinux/ip.hlinux/ipv6.hlinux/if_vlan.hlinux/mdio.hlinux/bitops.hlinux/netdevice.hlinux/etherdevice.hnet/ip6_checksum.hlinux/crc32.halx.hhw.hreg.h
Detected Declarations
function alx_free_txbuffunction alx_refill_rx_ringfunction alx_tpd_availfunction alx_clean_tx_irqfunction alx_schedule_link_checkfunction alx_schedule_resetfunction alx_clean_rx_irqfunction alx_pollfunction alx_intr_handle_miscfunction alx_intr_handlefunction alx_intr_msix_ringfunction alx_intr_msix_miscfunction alx_intr_msifunction alx_intr_legacyfunction alx_init_ring_ptrsfunction alx_free_txring_buffunction alx_free_rxring_buffunction alx_free_buffersfunction alx_reinit_ringsfunction alx_add_mc_addrfunction __alx_set_rx_modefunction alx_set_rx_modefunction alx_set_mac_addressfunction alx_alloc_tx_ringfunction alx_alloc_rx_ringfunction alx_alloc_ringsfunction alx_free_ringsfunction alx_free_napisfunction alx_alloc_napisfunction alx_config_vector_mappingfunction alx_enable_msixfunction alx_request_msixfunction alx_init_intrfunction alx_irq_enablefunction alx_irq_disablefunction alx_realloc_resourcesfunction alx_request_irqfunction alx_free_irqfunction alx_identify_hwfunction alx_init_swfunction alx_fix_featuresfunction alx_netif_stopfunction alx_haltfunction alx_configurefunction alx_activatefunction alx_reinitfunction alx_change_mtufunction alx_netif_start
Annotated Snippet
static const struct net_device_ops alx_netdev_ops = {
.ndo_open = alx_open,
.ndo_stop = alx_stop,
.ndo_start_xmit = alx_start_xmit,
.ndo_get_stats64 = alx_get_stats64,
.ndo_set_rx_mode = alx_set_rx_mode,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = alx_set_mac_address,
.ndo_change_mtu = alx_change_mtu,
.ndo_eth_ioctl = alx_ioctl,
.ndo_tx_timeout = alx_tx_timeout,
.ndo_fix_features = alx_fix_features,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = alx_poll_controller,
#endif
};
static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *netdev;
struct alx_priv *alx;
struct alx_hw *hw;
bool phy_configured;
int err;
err = pci_enable_device_mem(pdev);
if (err)
return err;
/* The alx chip can DMA to 64-bit addresses, but it uses a single
* shared register for the high 32 bits, so only a single, aligned,
* 4 GB physical address range can be used for descriptors.
*/
if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) {
dev_dbg(&pdev->dev, "DMA to 64-BIT addresses\n");
} else {
err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
dev_err(&pdev->dev, "No usable DMA config, aborting\n");
goto out_pci_disable;
}
}
err = pci_request_mem_regions(pdev, alx_drv_name);
if (err) {
dev_err(&pdev->dev,
"pci_request_mem_regions failed\n");
goto out_pci_disable;
}
pci_set_master(pdev);
if (!pdev->pm_cap) {
dev_err(&pdev->dev,
"Can't find power management capability, aborting\n");
err = -EIO;
goto out_pci_release;
}
netdev = alloc_etherdev_mqs(sizeof(*alx),
ALX_MAX_TX_QUEUES, 1);
if (!netdev) {
err = -ENOMEM;
goto out_pci_release;
}
SET_NETDEV_DEV(netdev, &pdev->dev);
alx = netdev_priv(netdev);
spin_lock_init(&alx->hw.mdio_lock);
spin_lock_init(&alx->irq_lock);
spin_lock_init(&alx->stats_lock);
alx->dev = netdev;
alx->hw.pdev = pdev;
alx->msg_enable = NETIF_MSG_LINK | NETIF_MSG_HW | NETIF_MSG_IFUP |
NETIF_MSG_TX_ERR | NETIF_MSG_RX_ERR | NETIF_MSG_WOL;
hw = &alx->hw;
pci_set_drvdata(pdev, alx);
hw->hw_addr = pci_ioremap_bar(pdev, 0);
if (!hw->hw_addr) {
dev_err(&pdev->dev, "cannot map device registers\n");
err = -EIO;
goto out_free_netdev;
}
netdev->netdev_ops = &alx_netdev_ops;
netdev->ethtool_ops = &alx_ethtool_ops;
netdev->irq = pci_irq_vector(pdev, 0);
netdev->watchdog_timeo = ALX_WATCHDOG_TIME;
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/interrupt.h`, `linux/ip.h`, `linux/ipv6.h`, `linux/if_vlan.h`, `linux/mdio.h`, `linux/bitops.h`.
- Detected declarations: `function alx_free_txbuf`, `function alx_refill_rx_ring`, `function alx_tpd_avail`, `function alx_clean_tx_irq`, `function alx_schedule_link_check`, `function alx_schedule_reset`, `function alx_clean_rx_irq`, `function alx_poll`, `function alx_intr_handle_misc`, `function alx_intr_handle`.
- 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.