drivers/net/ethernet/pasemi/pasemi_mac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/pasemi/pasemi_mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/pasemi/pasemi_mac.c- Extension
.c- Size
- 46355 bytes
- Lines
- 1846
- 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/slab.hlinux/interrupt.hlinux/dmaengine.hlinux/delay.hlinux/hex.hlinux/netdevice.hlinux/of_mdio.hlinux/etherdevice.hasm/dma-mapping.hlinux/in.hlinux/skbuff.hlinux/ip.hnet/checksum.hlinux/prefetch.hasm/irq.hasm/firmware.hasm/pasemi_dma.hpasemi_mac.h
Detected Declarations
function translation_enabledfunction write_iob_regfunction read_mac_regfunction write_mac_regfunction read_dma_regfunction write_dma_regfunction prefetch_skbfunction mac_to_intffunction pasemi_mac_intf_disablefunction pasemi_mac_intf_enablefunction pasemi_get_mac_addrfunction pasemi_mac_set_mac_addrfunction pasemi_mac_unmap_tx_skbfunction pasemi_mac_setup_csringsfunction pasemi_mac_free_csringfunction pasemi_mac_setup_rx_resourcesfunction pasemi_mac_setup_tx_resourcesfunction pasemi_mac_free_tx_resourcesfunction pasemi_mac_free_rx_buffersfunction pasemi_mac_free_rx_resourcesfunction pasemi_mac_replenish_rx_ringfunction pasemi_mac_restart_rx_intrfunction pasemi_mac_restart_tx_intrfunction pasemi_mac_rx_errorfunction pasemi_mac_tx_errorfunction pasemi_mac_clean_rxfunction pasemi_mac_clean_txfunction pasemi_mac_rx_intrfunction pasemi_mac_tx_timerfunction pasemi_mac_tx_intrfunction pasemi_adjust_linkfunction pasemi_mac_phy_initfunction pasemi_mac_openfunction pasemi_mac_pause_txchanfunction pasemi_mac_pause_rxchanfunction pasemi_mac_pause_rxintfunction pasemi_mac_closefunction pasemi_mac_queue_csdescfunction pasemi_mac_start_txfunction pasemi_mac_set_rx_modefunction pasemi_mac_pollfunction pasemi_mac_netpollfunction pasemi_mac_change_mtufunction pasemi_mac_probefunction pasemi_mac_removefunction pasemi_mac_cleanup_modulefunction pasemi_mac_init_modulemodule init pasemi_mac_init_module
Annotated Snippet
static const struct net_device_ops pasemi_netdev_ops = {
.ndo_open = pasemi_mac_open,
.ndo_stop = pasemi_mac_close,
.ndo_start_xmit = pasemi_mac_start_tx,
.ndo_set_rx_mode = pasemi_mac_set_rx_mode,
.ndo_set_mac_address = pasemi_mac_set_mac_addr,
.ndo_change_mtu = pasemi_mac_change_mtu,
.ndo_validate_addr = eth_validate_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = pasemi_mac_netpoll,
#endif
};
static int
pasemi_mac_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct pasemi_mac *mac;
int err, ret;
err = pci_enable_device(pdev);
if (err)
return err;
dev = alloc_etherdev(sizeof(struct pasemi_mac));
if (dev == NULL) {
err = -ENOMEM;
goto out_disable_device;
}
pci_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
mac = netdev_priv(dev);
mac->pdev = pdev;
mac->netdev = dev;
netif_napi_add(dev, &mac->napi, pasemi_mac_poll);
dev->features = NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_HIGHDMA |
NETIF_F_GSO;
dev->lltx = true;
mac->dma_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa007, NULL);
if (!mac->dma_pdev) {
dev_err(&mac->pdev->dev, "Can't find DMA Controller\n");
err = -ENODEV;
goto out;
}
dma_set_mask(&mac->dma_pdev->dev, DMA_BIT_MASK(64));
mac->iob_pdev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa001, NULL);
if (!mac->iob_pdev) {
dev_err(&mac->pdev->dev, "Can't find I/O Bridge\n");
err = -ENODEV;
goto out;
}
/* get mac addr from device tree */
if (pasemi_get_mac_addr(mac) || !is_valid_ether_addr(mac->mac_addr)) {
err = -ENODEV;
goto out;
}
eth_hw_addr_set(dev, mac->mac_addr);
ret = mac_to_intf(mac);
if (ret < 0) {
dev_err(&mac->pdev->dev, "Can't map DMA interface\n");
err = -ENODEV;
goto out;
}
mac->dma_if = ret;
switch (pdev->device) {
case 0xa005:
mac->type = MAC_TYPE_GMAC;
break;
case 0xa006:
mac->type = MAC_TYPE_XAUI;
break;
default:
err = -ENODEV;
goto out;
}
dev->netdev_ops = &pasemi_netdev_ops;
dev->mtu = PE_DEF_MTU;
/* MTU range: 64 - 9000 */
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/slab.h`, `linux/interrupt.h`, `linux/dmaengine.h`, `linux/delay.h`, `linux/hex.h`, `linux/netdevice.h`.
- Detected declarations: `function translation_enabled`, `function write_iob_reg`, `function read_mac_reg`, `function write_mac_reg`, `function read_dma_reg`, `function write_dma_reg`, `function prefetch_skb`, `function mac_to_intf`, `function pasemi_mac_intf_disable`, `function pasemi_mac_intf_enable`.
- 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.