drivers/net/ethernet/apple/mace.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/apple/mace.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/apple/mace.c- Extension
.c- Size
- 28007 bytes
- Lines
- 1030
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/delay.hlinux/string.hlinux/timer.hlinux/init.hlinux/interrupt.hlinux/crc32.hlinux/spinlock.hlinux/bitrev.hlinux/slab.hlinux/pgtable.hasm/dbdma.hasm/io.hasm/macio.hmace.h
Detected Declarations
struct mace_datafunction mace_probefunction mace_removefunction dbdma_resetfunction mace_resetfunction __mace_set_addressfunction mace_set_addressfunction mace_clean_ringsfunction mace_openfunction mace_closefunction mace_set_timeoutfunction mace_xmit_startfunction mace_set_multicastfunction netdev_for_each_mc_addrfunction mace_handle_misc_intrsfunction mace_interruptfunction mace_tx_timeoutfunction mace_txdma_intrfunction mace_rxdma_intrfunction mace_initfunction mace_cleanupmodule init mace_init
Annotated Snippet
static const struct net_device_ops mace_netdev_ops = {
.ndo_open = mace_open,
.ndo_stop = mace_close,
.ndo_start_xmit = mace_xmit_start,
.ndo_set_rx_mode = mace_set_multicast,
.ndo_set_mac_address = mace_set_address,
.ndo_validate_addr = eth_validate_addr,
};
static int mace_probe(struct macio_dev *mdev, const struct of_device_id *match)
{
struct device_node *mace = macio_get_of_node(mdev);
struct net_device *dev;
struct mace_data *mp;
const unsigned char *addr;
u8 macaddr[ETH_ALEN];
int j, rev, rc = -EBUSY;
if (macio_resource_count(mdev) != 3 || macio_irq_count(mdev) != 3) {
printk(KERN_ERR "can't use MACE %pOF: need 3 addrs and 3 irqs\n",
mace);
return -ENODEV;
}
addr = of_get_property(mace, "mac-address", NULL);
if (addr == NULL) {
addr = of_get_property(mace, "local-mac-address", NULL);
if (addr == NULL) {
printk(KERN_ERR "Can't get mac-address for MACE %pOF\n",
mace);
return -ENODEV;
}
}
/*
* lazy allocate the driver-wide dummy buffer. (Note that we
* never have more than one MACE in the system anyway)
*/
if (dummy_buf == NULL) {
dummy_buf = kmalloc(RX_BUFLEN+2, GFP_KERNEL);
if (dummy_buf == NULL)
return -ENOMEM;
}
if (macio_request_resources(mdev, "mace")) {
printk(KERN_ERR "MACE: can't request IO resources !\n");
return -EBUSY;
}
dev = alloc_etherdev(PRIV_BYTES);
if (!dev) {
rc = -ENOMEM;
goto err_release;
}
SET_NETDEV_DEV(dev, &mdev->ofdev.dev);
mp = netdev_priv(dev);
mp->mdev = mdev;
macio_set_drvdata(mdev, dev);
dev->base_addr = macio_resource_start(mdev, 0);
mp->mace = ioremap(dev->base_addr, 0x1000);
if (mp->mace == NULL) {
printk(KERN_ERR "MACE: can't map IO resources !\n");
rc = -ENOMEM;
goto err_free;
}
dev->irq = macio_irq(mdev, 0);
rev = addr[0] == 0 && addr[1] == 0xA0;
for (j = 0; j < 6; ++j) {
macaddr[j] = rev ? bitrev8(addr[j]): addr[j];
}
eth_hw_addr_set(dev, macaddr);
mp->chipid = (in_8(&mp->mace->chipid_hi) << 8) |
in_8(&mp->mace->chipid_lo);
mp = netdev_priv(dev);
mp->maccc = ENXMT | ENRCV;
mp->tx_dma = ioremap(macio_resource_start(mdev, 1), 0x1000);
if (mp->tx_dma == NULL) {
printk(KERN_ERR "MACE: can't map TX DMA resources !\n");
rc = -ENOMEM;
goto err_unmap_io;
}
mp->tx_dma_intr = macio_irq(mdev, 1);
mp->rx_dma = ioremap(macio_resource_start(mdev, 2), 0x1000);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/delay.h`, `linux/string.h`, `linux/timer.h`, `linux/init.h`.
- Detected declarations: `struct mace_data`, `function mace_probe`, `function mace_remove`, `function dbdma_reset`, `function mace_reset`, `function __mace_set_address`, `function mace_set_address`, `function mace_clean_rings`, `function mace_open`, `function mace_close`.
- 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.