drivers/net/ethernet/ethoc.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ethoc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ethoc.c- Extension
.c- Size
- 32446 bytes
- Lines
- 1314
- 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/dma-mapping.hlinux/etherdevice.hlinux/clk.hlinux/crc32.hlinux/interrupt.hlinux/io.hlinux/mii.hlinux/phy.hlinux/platform_device.hlinux/sched.hlinux/slab.hlinux/of.hlinux/of_net.hlinux/module.hnet/ethoc.h
Detected Declarations
struct ethocstruct ethoc_bdfunction ethoc_readfunction ethoc_writefunction ethoc_read_bdfunction ethoc_write_bdfunction ethoc_enable_irqfunction ethoc_disable_irqfunction ethoc_ack_irqfunction ethoc_enable_rx_and_txfunction ethoc_disable_rx_and_txfunction ethoc_init_ringfunction ethoc_resetfunction ethoc_update_rx_statsfunction ethoc_rxfunction ethoc_update_tx_statsfunction ethoc_txfunction ethoc_interruptfunction ethoc_get_mac_addressfunction ethoc_pollfunction ethoc_mdio_readfunction ethoc_mdio_writefunction ethoc_mdio_pollfunction ethoc_mdio_probefunction ethoc_openfunction ethoc_stopfunction ethoc_ioctlfunction ethoc_do_set_mac_addressfunction ethoc_set_mac_addressfunction ethoc_set_multicast_listfunction netdev_for_each_mc_addrfunction ethoc_change_mtufunction ethoc_tx_timeoutfunction ethoc_start_xmitfunction ethoc_get_regs_lenfunction ethoc_get_regsfunction ethoc_get_ringparamfunction ethoc_set_ringparamfunction ethoc_probefunction ethoc_removefunction ethoc_suspendfunction ethoc_resume
Annotated Snippet
static const struct net_device_ops ethoc_netdev_ops = {
.ndo_open = ethoc_open,
.ndo_stop = ethoc_stop,
.ndo_eth_ioctl = ethoc_ioctl,
.ndo_set_mac_address = ethoc_set_mac_address,
.ndo_set_rx_mode = ethoc_set_multicast_list,
.ndo_change_mtu = ethoc_change_mtu,
.ndo_tx_timeout = ethoc_tx_timeout,
.ndo_start_xmit = ethoc_start_xmit,
};
/**
* ethoc_probe - initialize OpenCores ethernet MAC
* @pdev: platform device
*/
static int ethoc_probe(struct platform_device *pdev)
{
struct net_device *netdev = NULL;
struct resource *res = NULL;
struct resource *mmio = NULL;
struct resource *mem = NULL;
struct ethoc *priv = NULL;
int num_bd;
int ret = 0;
struct ethoc_platform_data *pdata = dev_get_platdata(&pdev->dev);
u32 eth_clkfreq = pdata ? pdata->eth_clkfreq : 0;
/* allocate networking device */
netdev = alloc_etherdev(sizeof(struct ethoc));
if (!netdev) {
ret = -ENOMEM;
goto out;
}
SET_NETDEV_DEV(netdev, &pdev->dev);
platform_set_drvdata(pdev, netdev);
/* obtain I/O memory space */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "cannot obtain I/O memory space\n");
ret = -ENXIO;
goto free;
}
mmio = devm_request_mem_region(&pdev->dev, res->start,
resource_size(res), res->name);
if (!mmio) {
dev_err(&pdev->dev, "cannot request I/O memory space\n");
ret = -ENXIO;
goto free;
}
netdev->base_addr = mmio->start;
/* obtain buffer memory space */
res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
if (res) {
mem = devm_request_mem_region(&pdev->dev, res->start,
resource_size(res), res->name);
if (!mem) {
dev_err(&pdev->dev, "cannot request memory space\n");
ret = -ENXIO;
goto free;
}
netdev->mem_start = mem->start;
netdev->mem_end = mem->end;
}
/* obtain device IRQ number */
ret = platform_get_irq(pdev, 0);
if (ret < 0)
goto free;
netdev->irq = ret;
/* setup driver-private data */
priv = netdev_priv(netdev);
priv->netdev = netdev;
priv->iobase = devm_ioremap(&pdev->dev, netdev->base_addr,
resource_size(mmio));
if (!priv->iobase) {
dev_err(&pdev->dev, "cannot remap I/O memory space\n");
ret = -ENXIO;
goto free;
}
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/etherdevice.h`, `linux/clk.h`, `linux/crc32.h`, `linux/interrupt.h`, `linux/io.h`, `linux/mii.h`, `linux/phy.h`.
- Detected declarations: `struct ethoc`, `struct ethoc_bd`, `function ethoc_read`, `function ethoc_write`, `function ethoc_read_bd`, `function ethoc_write_bd`, `function ethoc_enable_irq`, `function ethoc_disable_irq`, `function ethoc_ack_irq`, `function ethoc_enable_rx_and_tx`.
- 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.