drivers/net/ethernet/ezchip/nps_enet.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ezchip/nps_enet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ezchip/nps_enet.c- Extension
.c- Size
- 18991 bytes
- Lines
- 666
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/etherdevice.hlinux/interrupt.hlinux/mod_devicetable.hlinux/of_net.hlinux/platform_device.hnps_enet.h
Detected Declarations
function Copyrightfunction nps_enet_clean_rx_fifofunction nps_enet_read_rx_fifofunction nps_enet_rx_handlerfunction nps_enet_tx_handlerfunction nps_enet_pollfunction TXfunction nps_enet_set_hw_mac_addressfunction nps_enet_hw_resetfunction nps_enet_hw_enable_controlfunction nps_enet_hw_disable_controlfunction nps_enet_send_framefunction nps_enet_set_mac_addressfunction nps_enet_set_rx_modefunction nps_enet_openfunction nps_enet_stopfunction nps_enet_start_xmitfunction nps_enet_poll_controllerfunction nps_enet_probefunction nps_enet_remove
Annotated Snippet
static const struct net_device_ops nps_netdev_ops = {
.ndo_open = nps_enet_open,
.ndo_stop = nps_enet_stop,
.ndo_start_xmit = nps_enet_start_xmit,
.ndo_set_mac_address = nps_enet_set_mac_address,
.ndo_set_rx_mode = nps_enet_set_rx_mode,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = nps_enet_poll_controller,
#endif
};
static s32 nps_enet_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct net_device *ndev;
struct nps_enet_priv *priv;
s32 err = 0;
if (!dev->of_node)
return -ENODEV;
ndev = alloc_etherdev(sizeof(struct nps_enet_priv));
if (!ndev)
return -ENOMEM;
platform_set_drvdata(pdev, ndev);
SET_NETDEV_DEV(ndev, dev);
priv = netdev_priv(ndev);
/* The EZ NET specific entries in the device structure. */
ndev->netdev_ops = &nps_netdev_ops;
ndev->watchdog_timeo = (400 * HZ / 1000);
/* FIXME :: no multicast support yet */
ndev->flags &= ~IFF_MULTICAST;
priv->regs_base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->regs_base)) {
err = PTR_ERR(priv->regs_base);
goto out_netdev;
}
dev_dbg(dev, "Registers base address is 0x%p\n", priv->regs_base);
/* set kernel MAC address to dev */
err = of_get_ethdev_address(dev->of_node, ndev);
if (err)
eth_hw_addr_random(ndev);
/* Get IRQ number */
priv->irq = platform_get_irq(pdev, 0);
if (priv->irq < 0) {
err = -ENODEV;
goto out_netdev;
}
netif_napi_add_weight(ndev, &priv->napi, nps_enet_poll,
NPS_ENET_NAPI_POLL_WEIGHT);
/* Register the driver. Should be the last thing in probe */
err = register_netdev(ndev);
if (err) {
dev_err(dev, "Failed to register ndev for %s, err = 0x%08x\n",
ndev->name, (s32)err);
goto out_netif_api;
}
dev_info(dev, "(rx/tx=%d)\n", priv->irq);
return 0;
out_netif_api:
netif_napi_del(&priv->napi);
out_netdev:
free_netdev(ndev);
return err;
}
static void nps_enet_remove(struct platform_device *pdev)
{
struct net_device *ndev = platform_get_drvdata(pdev);
struct nps_enet_priv *priv = netdev_priv(ndev);
unregister_netdev(ndev);
netif_napi_del(&priv->napi);
free_netdev(ndev);
}
static const struct of_device_id nps_enet_dt_ids[] = {
{ .compatible = "ezchip,nps-mgt-enet" },
{ /* Sentinel */ }
};
Annotation
- Immediate include surface: `linux/module.h`, `linux/etherdevice.h`, `linux/interrupt.h`, `linux/mod_devicetable.h`, `linux/of_net.h`, `linux/platform_device.h`, `nps_enet.h`.
- Detected declarations: `function Copyright`, `function nps_enet_clean_rx_fifo`, `function nps_enet_read_rx_fifo`, `function nps_enet_rx_handler`, `function nps_enet_tx_handler`, `function nps_enet_poll`, `function TX`, `function nps_enet_set_hw_mac_address`, `function nps_enet_hw_reset`, `function nps_enet_hw_enable_control`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.