drivers/net/ethernet/korina.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/korina.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/korina.c- Extension
.c- Size
- 36718 bytes
- Lines
- 1418
- 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/module.hlinux/kernel.hlinux/moduleparam.hlinux/sched.hlinux/ctype.hlinux/types.hlinux/interrupt.hlinux/ioport.hlinux/iopoll.hlinux/in.hlinux/of.hlinux/of_net.hlinux/slab.hlinux/string.hlinux/delay.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/errno.hlinux/platform_device.hlinux/mii.hlinux/ethtool.hlinux/crc32.hlinux/pgtable.hlinux/clk.h
Detected Declarations
struct eth_regsstruct dma_descstruct dma_regstruct korina_privateenum chain_statusfunction korina_tx_dmafunction korina_rx_dmafunction korina_abort_dmafunction korina_abort_txfunction korina_abort_rxfunction korina_send_packetfunction korina_mdio_waitfunction korina_mdio_readfunction korina_mdio_writefunction korina_rx_dma_interruptfunction korina_rxfunction korina_pollfunction korina_multicast_listfunction netdev_for_each_mc_addrfunction korina_txfunction korina_tx_dma_interruptfunction korina_check_mediafunction korina_poll_mediafunction korina_set_carrierfunction korina_ioctlfunction netdev_get_drvinfofunction netdev_get_link_ksettingsfunction netdev_set_link_ksettingsfunction netdev_get_linkfunction korina_alloc_ringfunction korina_free_ringfunction korina_initfunction korina_restart_taskfunction korina_tx_timeoutfunction korina_poll_controllerfunction korina_openfunction korina_closefunction korina_probefunction korina_remove
Annotated Snippet
static const struct net_device_ops korina_netdev_ops = {
.ndo_open = korina_open,
.ndo_stop = korina_close,
.ndo_start_xmit = korina_send_packet,
.ndo_set_rx_mode = korina_multicast_list,
.ndo_tx_timeout = korina_tx_timeout,
.ndo_eth_ioctl = korina_ioctl,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = korina_poll_controller,
#endif
};
static int korina_probe(struct platform_device *pdev)
{
u8 *mac_addr = dev_get_platdata(&pdev->dev);
struct korina_private *lp;
struct net_device *dev;
struct clk *clk;
void __iomem *p;
int rc;
dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct korina_private));
if (!dev)
return -ENOMEM;
SET_NETDEV_DEV(dev, &pdev->dev);
lp = netdev_priv(dev);
if (mac_addr)
eth_hw_addr_set(dev, mac_addr);
else if (of_get_ethdev_address(pdev->dev.of_node, dev) < 0)
eth_hw_addr_random(dev);
clk = devm_clk_get_optional_enabled(&pdev->dev, "mdioclk");
if (IS_ERR(clk))
return PTR_ERR(clk);
if (clk) {
lp->mii_clock_freq = clk_get_rate(clk);
} else {
lp->mii_clock_freq = 200000000; /* max possible input clk */
}
lp->rx_irq = platform_get_irq_byname(pdev, "rx");
lp->tx_irq = platform_get_irq_byname(pdev, "tx");
p = devm_platform_ioremap_resource_byname(pdev, "emac");
if (IS_ERR(p)) {
printk(KERN_ERR DRV_NAME ": cannot remap registers\n");
return PTR_ERR(p);
}
lp->eth_regs = p;
p = devm_platform_ioremap_resource_byname(pdev, "dma_rx");
if (IS_ERR(p)) {
printk(KERN_ERR DRV_NAME ": cannot remap Rx DMA registers\n");
return PTR_ERR(p);
}
lp->rx_dma_regs = p;
p = devm_platform_ioremap_resource_byname(pdev, "dma_tx");
if (IS_ERR(p)) {
printk(KERN_ERR DRV_NAME ": cannot remap Tx DMA registers\n");
return PTR_ERR(p);
}
lp->tx_dma_regs = p;
lp->td_ring = dmam_alloc_coherent(&pdev->dev, TD_RING_SIZE,
&lp->td_dma, GFP_KERNEL);
if (!lp->td_ring)
return -ENOMEM;
lp->rd_ring = dmam_alloc_coherent(&pdev->dev, RD_RING_SIZE,
&lp->rd_dma, GFP_KERNEL);
if (!lp->rd_ring)
return -ENOMEM;
spin_lock_init(&lp->lock);
/* just use the rx dma irq */
dev->irq = lp->rx_irq;
lp->dev = dev;
lp->dmadev = &pdev->dev;
dev->netdev_ops = &korina_netdev_ops;
dev->ethtool_ops = &netdev_ethtool_ops;
dev->watchdog_timeo = TX_TIMEOUT;
netif_napi_add(dev, &lp->napi, korina_poll);
lp->mii_if.dev = dev;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/moduleparam.h`, `linux/sched.h`, `linux/ctype.h`, `linux/types.h`, `linux/interrupt.h`, `linux/ioport.h`.
- Detected declarations: `struct eth_regs`, `struct dma_desc`, `struct dma_reg`, `struct korina_private`, `enum chain_status`, `function korina_tx_dma`, `function korina_rx_dma`, `function korina_abort_dma`, `function korina_abort_tx`, `function korina_abort_rx`.
- 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.