drivers/net/ethernet/lantiq_xrx200.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/lantiq_xrx200.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/lantiq_xrx200.c- Extension
.c- Size
- 16483 bytes
- Lines
- 684
- 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/etherdevice.hlinux/module.hlinux/platform_device.hlinux/interrupt.hlinux/clk.hlinux/delay.hlinux/if_vlan.hlinux/of_net.hlinux/of_platform.hxway_dma.h
Detected Declarations
struct xrx200_chanstruct xrx200_privfunction xrx200_pmac_r32function xrx200_pmac_w32function xrx200_pmac_maskfunction xrx200_max_frame_lenfunction xrx200_buffer_sizefunction xrx200_skb_sizefunction xrx200_flush_dmafunction xrx200_openfunction xrx200_closefunction xrx200_alloc_buffunction xrx200_hw_receivefunction xrx200_poll_rxfunction xrx200_tx_housekeepingfunction xrx200_start_xmitfunction xrx200_change_mtufunction xrx200_dma_irqfunction xrx200_dma_initfunction xrx200_hw_cleanupfunction xrx200_probefunction xrx200_remove
Annotated Snippet
static const struct net_device_ops xrx200_netdev_ops = {
.ndo_open = xrx200_open,
.ndo_stop = xrx200_close,
.ndo_start_xmit = xrx200_start_xmit,
.ndo_change_mtu = xrx200_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_validate_addr = eth_validate_addr,
};
static irqreturn_t xrx200_dma_irq(int irq, void *ptr)
{
struct xrx200_chan *ch = ptr;
if (napi_schedule_prep(&ch->napi)) {
ltq_dma_disable_irq(&ch->dma);
__napi_schedule(&ch->napi);
}
ltq_dma_ack_irq(&ch->dma);
return IRQ_HANDLED;
}
static int xrx200_dma_init(struct xrx200_priv *priv)
{
struct xrx200_chan *ch_rx = &priv->chan_rx;
struct xrx200_chan *ch_tx = &priv->chan_tx;
int ret = 0;
int i;
ltq_dma_init_port(DMA_PORT_ETOP, XRX200_DMA_BURST_LEN,
XRX200_DMA_BURST_LEN);
ch_rx->dma.nr = XRX200_DMA_RX;
ch_rx->dma.dev = priv->dev;
ch_rx->priv = priv;
ltq_dma_alloc_rx(&ch_rx->dma);
for (ch_rx->dma.desc = 0; ch_rx->dma.desc < LTQ_DESC_NUM;
ch_rx->dma.desc++) {
ret = xrx200_alloc_buf(ch_rx, netdev_alloc_frag);
if (ret)
goto rx_free;
}
ch_rx->dma.desc = 0;
ret = devm_request_irq(priv->dev, ch_rx->dma.irq, xrx200_dma_irq, 0,
"xrx200_net_rx", &priv->chan_rx);
if (ret) {
dev_err(priv->dev, "failed to request RX irq %d\n",
ch_rx->dma.irq);
goto rx_ring_free;
}
ch_tx->dma.nr = XRX200_DMA_TX;
ch_tx->dma.dev = priv->dev;
ch_tx->priv = priv;
ltq_dma_alloc_tx(&ch_tx->dma);
ret = devm_request_irq(priv->dev, ch_tx->dma.irq, xrx200_dma_irq, 0,
"xrx200_net_tx", &priv->chan_tx);
if (ret) {
dev_err(priv->dev, "failed to request TX irq %d\n",
ch_tx->dma.irq);
goto tx_free;
}
return ret;
tx_free:
ltq_dma_free(&ch_tx->dma);
rx_ring_free:
/* free the allocated RX ring */
for (i = 0; i < LTQ_DESC_NUM; i++) {
if (priv->chan_rx.skb[i])
skb_free_frag(priv->chan_rx.rx_buff[i]);
}
rx_free:
ltq_dma_free(&ch_rx->dma);
return ret;
}
static void xrx200_hw_cleanup(struct xrx200_priv *priv)
{
int i;
ltq_dma_free(&priv->chan_tx.dma);
ltq_dma_free(&priv->chan_rx.dma);
Annotation
- Immediate include surface: `linux/etherdevice.h`, `linux/module.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/clk.h`, `linux/delay.h`, `linux/if_vlan.h`, `linux/of_net.h`.
- Detected declarations: `struct xrx200_chan`, `struct xrx200_priv`, `function xrx200_pmac_r32`, `function xrx200_pmac_w32`, `function xrx200_pmac_mask`, `function xrx200_max_frame_len`, `function xrx200_buffer_size`, `function xrx200_skb_size`, `function xrx200_flush_dma`, `function xrx200_open`.
- 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.