drivers/net/ethernet/broadcom/bcm4908_enet.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/broadcom/bcm4908_enet.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/broadcom/bcm4908_enet.c- Extension
.c- Size
- 21896 bytes
- Lines
- 799
- 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.
- 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/delay.hlinux/etherdevice.hlinux/if_vlan.hlinux/interrupt.hlinux/module.hlinux/of.hlinux/of_net.hlinux/platform_device.hlinux/slab.hlinux/string.hbcm4908_enet.hunimac.h
Detected Declarations
struct bcm4908_enet_dma_ring_bdstruct bcm4908_enet_dma_ring_slotstruct bcm4908_enet_dma_ringstruct bcm4908_enetfunction enet_readfunction enet_writefunction enet_masksetfunction enet_setfunction enet_umac_readfunction enet_umac_writefunction enet_umac_setfunction bcm4908_enet_set_mtufunction bcm4908_enet_dma_ring_intrs_onfunction bcm4908_enet_dma_ring_intrs_offfunction bcm4908_enet_dma_ring_intrs_ackfunction bcm4908_dma_alloc_buf_descsfunction bcm4908_enet_dma_freefunction bcm4908_enet_dma_allocfunction bcm4908_enet_dma_resetfunction bcm4908_enet_dma_alloc_rx_buffunction bcm4908_enet_dma_ring_initfunction bcm4908_enet_dma_uninitfunction bcm4908_enet_dma_initfunction bcm4908_enet_dma_tx_ring_enablefunction bcm4908_enet_dma_tx_ring_disablefunction bcm4908_enet_dma_rx_ring_enablefunction bcm4908_enet_dma_rx_ring_disablefunction bcm4908_enet_gmac_initfunction bcm4908_enet_irq_handlerfunction bcm4908_enet_openfunction bcm4908_enet_stopfunction bcm4908_enet_start_xmitfunction bcm4908_enet_poll_rxfunction bcm4908_enet_poll_txfunction bcm4908_enet_change_mtufunction bcm4908_enet_probefunction bcm4908_enet_remove
Annotated Snippet
static const struct net_device_ops bcm4908_enet_netdev_ops = {
.ndo_open = bcm4908_enet_open,
.ndo_stop = bcm4908_enet_stop,
.ndo_start_xmit = bcm4908_enet_start_xmit,
.ndo_set_mac_address = eth_mac_addr,
.ndo_change_mtu = bcm4908_enet_change_mtu,
};
static int bcm4908_enet_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct net_device *netdev;
struct bcm4908_enet *enet;
int err;
netdev = devm_alloc_etherdev(dev, sizeof(*enet));
if (!netdev)
return -ENOMEM;
enet = netdev_priv(netdev);
enet->dev = dev;
enet->netdev = netdev;
enet->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(enet->base)) {
dev_err(dev, "Failed to map registers: %ld\n", PTR_ERR(enet->base));
return PTR_ERR(enet->base);
}
netdev->irq = platform_get_irq_byname(pdev, "rx");
if (netdev->irq < 0)
return netdev->irq;
enet->irq_tx = platform_get_irq_byname(pdev, "tx");
err = dma_set_coherent_mask(dev, DMA_BIT_MASK(32));
if (err)
return err;
err = bcm4908_enet_dma_alloc(enet);
if (err)
return err;
SET_NETDEV_DEV(netdev, &pdev->dev);
err = of_get_ethdev_address(dev->of_node, netdev);
if (err == -EPROBE_DEFER)
goto err_dma_free;
if (err)
eth_hw_addr_random(netdev);
netdev->netdev_ops = &bcm4908_enet_netdev_ops;
netdev->min_mtu = ETH_ZLEN;
netdev->mtu = ETH_DATA_LEN;
netdev->max_mtu = ENET_MTU_MAX;
netif_napi_add_tx(netdev, &enet->tx_ring.napi, bcm4908_enet_poll_tx);
netif_napi_add(netdev, &enet->rx_ring.napi, bcm4908_enet_poll_rx);
err = register_netdev(netdev);
if (err)
goto err_dma_free;
platform_set_drvdata(pdev, enet);
return 0;
err_dma_free:
bcm4908_enet_dma_free(enet);
return err;
}
static void bcm4908_enet_remove(struct platform_device *pdev)
{
struct bcm4908_enet *enet = platform_get_drvdata(pdev);
unregister_netdev(enet->netdev);
netif_napi_del(&enet->rx_ring.napi);
netif_napi_del(&enet->tx_ring.napi);
bcm4908_enet_dma_free(enet);
}
static const struct of_device_id bcm4908_enet_of_match[] = {
{ .compatible = "brcm,bcm4908-enet"},
{},
};
static struct platform_driver bcm4908_enet_driver = {
.driver = {
.name = "bcm4908_enet",
.of_match_table = bcm4908_enet_of_match,
},
Annotation
- Immediate include surface: `linux/delay.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/interrupt.h`, `linux/module.h`, `linux/of.h`, `linux/of_net.h`, `linux/platform_device.h`.
- Detected declarations: `struct bcm4908_enet_dma_ring_bd`, `struct bcm4908_enet_dma_ring_slot`, `struct bcm4908_enet_dma_ring`, `struct bcm4908_enet`, `function enet_read`, `function enet_write`, `function enet_maskset`, `function enet_set`, `function enet_umac_read`, `function enet_umac_write`.
- 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.