drivers/net/ethernet/wiznet/w5100.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/wiznet/w5100.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/wiznet/w5100.c- Extension
.c- Size
- 21046 bytes
- Lines
- 867
- 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/kernel.hlinux/module.hlinux/netdevice.hlinux/etherdevice.hlinux/platform_device.hlinux/ethtool.hlinux/skbuff.hlinux/types.hlinux/errno.hlinux/delay.hlinux/slab.hlinux/spinlock.hlinux/io.hlinux/ioport.hlinux/interrupt.hlinux/irq.hw5100.h
Detected Declarations
struct w5100_privfunction w5100_readfunction w5100_writefunction w5100_read16function w5100_write16function w5100_readbulkfunction w5100_writebulkfunction w5100_readbuffunction w5100_writebuffunction w5100_resetfunction w5100_commandfunction w5100_write_macaddrfunction w5100_socket_intr_maskfunction w5100_enable_intrfunction w5100_disable_intrfunction w5100_memory_configurefunction w5200_memory_configurefunction w5500_memory_configurefunction w5100_hw_resetfunction w5100_hw_startfunction w5100_hw_closefunction w5100_get_drvinfofunction w5100_get_msglevelfunction w5100_set_msglevelfunction w5100_get_regs_lenfunction w5100_get_regsfunction w5100_restartfunction w5100_restart_workfunction w5100_tx_timeoutfunction w5100_tx_skbfunction w5100_tx_workfunction w5100_start_txfunction w5100_rx_workfunction w5100_napi_pollfunction w5100_interruptfunction w5100_setrx_workfunction w5100_set_rx_modefunction w5100_set_macaddrfunction w5100_openfunction w5100_stopfunction w5100_probefunction w5100_removefunction w5100_suspendfunction w5100_resumeexport w5100_ops_privexport w5100_probeexport w5100_removeexport w5100_pm_ops
Annotated Snippet
static const struct net_device_ops w5100_netdev_ops = {
.ndo_open = w5100_open,
.ndo_stop = w5100_stop,
.ndo_start_xmit = w5100_start_tx,
.ndo_tx_timeout = w5100_tx_timeout,
.ndo_set_rx_mode = w5100_set_rx_mode,
.ndo_set_mac_address = w5100_set_macaddr,
.ndo_validate_addr = eth_validate_addr,
};
void *w5100_ops_priv(const struct net_device *ndev)
{
return netdev_priv(ndev) +
ALIGN(sizeof(struct w5100_priv), NETDEV_ALIGN);
}
EXPORT_SYMBOL_GPL(w5100_ops_priv);
int w5100_probe(struct device *dev, const struct w5100_ops *ops,
int sizeof_ops_priv, const void *mac_addr, int irq)
{
struct w5100_priv *priv;
struct net_device *ndev;
int err;
size_t alloc_size;
alloc_size = sizeof(*priv);
if (sizeof_ops_priv) {
alloc_size = ALIGN(alloc_size, NETDEV_ALIGN);
alloc_size += sizeof_ops_priv;
}
alloc_size += NETDEV_ALIGN - 1;
ndev = alloc_etherdev(alloc_size);
if (!ndev)
return -ENOMEM;
SET_NETDEV_DEV(ndev, dev);
dev_set_drvdata(dev, ndev);
priv = netdev_priv(ndev);
switch (ops->chip_id) {
case W5100:
priv->s0_regs = W5100_S0_REGS;
priv->s0_tx_buf = W5100_TX_MEM_START;
priv->s0_tx_buf_size = W5100_TX_MEM_SIZE;
priv->s0_rx_buf = W5100_RX_MEM_START;
priv->s0_rx_buf_size = W5100_RX_MEM_SIZE;
break;
case W5200:
priv->s0_regs = W5200_S0_REGS;
priv->s0_tx_buf = W5200_TX_MEM_START;
priv->s0_tx_buf_size = W5200_TX_MEM_SIZE;
priv->s0_rx_buf = W5200_RX_MEM_START;
priv->s0_rx_buf_size = W5200_RX_MEM_SIZE;
break;
case W5500:
priv->s0_regs = W5500_S0_REGS;
priv->s0_tx_buf = W5500_TX_MEM_START;
priv->s0_tx_buf_size = W5500_TX_MEM_SIZE;
priv->s0_rx_buf = W5500_RX_MEM_START;
priv->s0_rx_buf_size = W5500_RX_MEM_SIZE;
break;
default:
err = -EINVAL;
goto err_register;
}
priv->ndev = ndev;
priv->ops = ops;
priv->irq = irq;
ndev->netdev_ops = &w5100_netdev_ops;
ndev->ethtool_ops = &w5100_ethtool_ops;
netif_napi_add_weight(ndev, &priv->napi, w5100_napi_poll, 16);
/* This chip doesn't support VLAN packets with normal MTU,
* so disable VLAN for this device.
*/
ndev->features |= NETIF_F_VLAN_CHALLENGED;
err = register_netdev(ndev);
if (err < 0)
goto err_register;
priv->xfer_wq = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_PERCPU, 0,
netdev_name(ndev));
if (!priv->xfer_wq) {
err = -ENOMEM;
goto err_wq;
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `linux/ethtool.h`, `linux/skbuff.h`, `linux/types.h`.
- Detected declarations: `struct w5100_priv`, `function w5100_read`, `function w5100_write`, `function w5100_read16`, `function w5100_write16`, `function w5100_readbulk`, `function w5100_writebulk`, `function w5100_readbuf`, `function w5100_writebuf`, `function w5100_reset`.
- 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.