drivers/net/ethernet/lantiq_etop.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/lantiq_etop.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/lantiq_etop.c- Extension
.c- Size
- 17824 bytes
- Lines
- 746
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/slab.hlinux/errno.hlinux/types.hlinux/interrupt.hlinux/uaccess.hlinux/in.hlinux/netdevice.hlinux/etherdevice.hlinux/phy.hlinux/ip.hlinux/tcp.hlinux/skbuff.hlinux/mm.hlinux/platform_device.hlinux/ethtool.hlinux/init.hlinux/delay.hlinux/io.hlinux/dma-mapping.hlinux/module.hlinux/property.hasm/checksum.hlantiq_soc.hxway_dma.hlantiq_platform.h
Detected Declarations
struct ltq_etop_chanstruct ltq_etop_privfunction ltq_etop_alloc_skbfunction ltq_etop_hw_receivefunction ltq_etop_poll_rxfunction ltq_etop_poll_txfunction ltq_etop_dma_irqfunction ltq_etop_free_channelfunction ltq_etop_hw_exitfunction ltq_etop_hw_initfunction ltq_etop_get_drvinfofunction ltq_etop_mdio_wrfunction ltq_etop_mdio_rdfunction ltq_etop_mdio_linkfunction ltq_etop_mdio_initfunction ltq_etop_mdio_cleanupfunction ltq_etop_openfunction ltq_etop_stopfunction ltq_etop_txfunction ltq_etop_change_mtufunction ltq_etop_set_mac_addressfunction ltq_etop_set_multicast_listfunction ltq_etop_initfunction ltq_etop_tx_timeoutfunction ltq_etop_probefunction ltq_etop_removefunction init_ltq_etopfunction exit_ltq_etopmodule init init_ltq_etop
Annotated Snippet
static const struct net_device_ops ltq_eth_netdev_ops = {
.ndo_open = ltq_etop_open,
.ndo_stop = ltq_etop_stop,
.ndo_start_xmit = ltq_etop_tx,
.ndo_change_mtu = ltq_etop_change_mtu,
.ndo_eth_ioctl = phy_do_ioctl,
.ndo_set_mac_address = ltq_etop_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_rx_mode = ltq_etop_set_multicast_list,
.ndo_select_queue = dev_pick_tx_zero,
.ndo_init = ltq_etop_init,
.ndo_tx_timeout = ltq_etop_tx_timeout,
};
static int __init
ltq_etop_probe(struct platform_device *pdev)
{
struct net_device *dev;
struct ltq_etop_priv *priv;
int err;
int i;
ltq_etop_membase = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(ltq_etop_membase)) {
dev_err(&pdev->dev, "failed to remap etop engine %d\n",
pdev->id);
err = PTR_ERR(ltq_etop_membase);
goto err_out;
}
dev = alloc_etherdev_mq(sizeof(struct ltq_etop_priv), 4);
if (!dev) {
err = -ENOMEM;
goto err_out;
}
dev->netdev_ops = <q_eth_netdev_ops;
dev->ethtool_ops = <q_etop_ethtool_ops;
priv = netdev_priv(dev);
priv->pdev = pdev;
priv->pldata = dev_get_platdata(&pdev->dev);
priv->netdev = dev;
spin_lock_init(&priv->lock);
SET_NETDEV_DEV(dev, &pdev->dev);
err = device_property_read_u32(&pdev->dev, "lantiq,tx-burst-length", &priv->tx_burst_len);
if (err < 0) {
dev_err(&pdev->dev, "unable to read tx-burst-length property\n");
goto err_free;
}
err = device_property_read_u32(&pdev->dev, "lantiq,rx-burst-length", &priv->rx_burst_len);
if (err < 0) {
dev_err(&pdev->dev, "unable to read rx-burst-length property\n");
goto err_free;
}
for (i = 0; i < MAX_DMA_CHAN; i++) {
if (IS_TX(i))
netif_napi_add_weight(dev, &priv->ch[i].napi,
ltq_etop_poll_tx, 8);
else if (IS_RX(i))
netif_napi_add_weight(dev, &priv->ch[i].napi,
ltq_etop_poll_rx, 32);
priv->ch[i].netdev = dev;
}
err = register_netdev(dev);
if (err)
goto err_free;
platform_set_drvdata(pdev, dev);
return 0;
err_free:
free_netdev(dev);
err_out:
return err;
}
static void ltq_etop_remove(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
if (dev) {
netif_tx_stop_all_queues(dev);
ltq_etop_hw_exit(dev);
ltq_etop_mdio_cleanup(dev);
unregister_netdev(dev);
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/errno.h`, `linux/types.h`, `linux/interrupt.h`, `linux/uaccess.h`, `linux/in.h`, `linux/netdevice.h`.
- Detected declarations: `struct ltq_etop_chan`, `struct ltq_etop_priv`, `function ltq_etop_alloc_skb`, `function ltq_etop_hw_receive`, `function ltq_etop_poll_rx`, `function ltq_etop_poll_tx`, `function ltq_etop_dma_irq`, `function ltq_etop_free_channel`, `function ltq_etop_hw_exit`, `function ltq_etop_hw_init`.
- 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.