drivers/net/ethernet/ibm/emac/core.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ibm/emac/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ibm/emac/core.c- Extension
.c- Size
- 89423 bytes
- Lines
- 3358
- 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/sched.hlinux/string.hlinux/errno.hlinux/delay.hlinux/types.hlinux/pci.hlinux/etherdevice.hlinux/skbuff.hlinux/crc32.hlinux/ethtool.hlinux/if_vlan.hlinux/mii.hlinux/bitops.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/of_net.hlinux/of_mdio.hlinux/of_platform.hlinux/platform_device.hlinux/slab.hasm/processor.hasm/io.hasm/dma.hlinux/uaccess.hasm/dcr.hasm/dcr-regs.hcore.h
Detected Declarations
struct emac_depentryfunction emac_report_timeout_errorfunction emac_rx_clk_txfunction emac_rx_clk_defaultfunction emac_phy_supports_gigefunction emac_phy_gpcsfunction emac_tx_enablefunction emac_tx_disablefunction emac_rx_enablefunction emac_rx_disablefunction emac_netif_stopfunction emac_netif_startfunction emac_rx_disable_asyncfunction emac_resetfunction emac_init_phyfunction emac_hash_mcfunction netdev_for_each_mc_addrfunction emac_iff2rmrfunction __emac_calc_base_mr1function __emac4_calc_base_mr1function emac_calc_base_mr1function emac_calc_trtrfunction emac_calc_rwmrfunction emac_configurefunction emac_reinitializefunction emac_full_tx_resetfunction emac_reset_workfunction emac_tx_timeoutfunction emac_phy_donefunction __emac_mdio_readfunction __emac_mdio_writefunction emac_mdio_readfunction emac_mdio_writefunction __emac_set_multicast_listfunction emac_set_multicast_listfunction emac_set_mac_addressfunction emac_resize_rx_ringfunction emac_change_mtufunction emac_clean_tx_ringfunction emac_clean_rx_ringfunction emac_clear_mal_descfunction __emac_prepare_rx_skbfunction emac_alloc_rx_skbfunction emac_alloc_rx_skb_napifunction emac_print_link_statusfunction emac_openfunction emac_link_differsfunction emac_link_timer
Annotated Snippet
static const struct net_device_ops emac_netdev_ops = {
.ndo_open = emac_open,
.ndo_stop = emac_close,
.ndo_get_stats = emac_stats,
.ndo_set_rx_mode = emac_set_multicast_list,
.ndo_eth_ioctl = emac_ioctl,
.ndo_tx_timeout = emac_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = emac_set_mac_address,
.ndo_start_xmit = emac_start_xmit,
};
static const struct net_device_ops emac_gige_netdev_ops = {
.ndo_open = emac_open,
.ndo_stop = emac_close,
.ndo_get_stats = emac_stats,
.ndo_set_rx_mode = emac_set_multicast_list,
.ndo_eth_ioctl = emac_ioctl,
.ndo_tx_timeout = emac_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = emac_set_mac_address,
.ndo_start_xmit = emac_start_xmit_sg,
.ndo_change_mtu = emac_change_mtu,
};
static int emac_probe(struct platform_device *ofdev)
{
struct net_device *ndev;
struct emac_instance *dev;
struct device_node *np = ofdev->dev.of_node;
struct device_node **blist = NULL;
int err, i;
/* Skip unused/unwired EMACS. We leave the check for an unused
* property here for now, but new flat device trees should set a
* status property to "disabled" instead.
*/
if (of_property_read_bool(np, "unused") || !of_device_is_available(np))
return -ENODEV;
/* Find ourselves in the bootlist if we are there */
for (i = 0; i < EMAC_BOOT_LIST_SIZE; i++)
if (emac_boot_list[i] == np)
blist = &emac_boot_list[i];
/* Allocate our net_device structure */
err = -ENOMEM;
ndev = devm_alloc_etherdev(&ofdev->dev, sizeof(struct emac_instance));
if (!ndev)
goto err_gone;
dev = netdev_priv(ndev);
dev->ndev = ndev;
dev->ofdev = ofdev;
dev->blist = blist;
SET_NETDEV_DEV(ndev, &ofdev->dev);
/* Initialize some embedded data structures */
err = devm_mutex_init(&ofdev->dev, &dev->mdio_lock);
if (err)
goto err_gone;
err = devm_mutex_init(&ofdev->dev, &dev->link_lock);
if (err)
goto err_gone;
spin_lock_init(&dev->lock);
INIT_WORK(&dev->reset_work, emac_reset_work);
/* Init various config data based on device-tree */
err = emac_init_config(dev);
if (err)
goto err_gone;
/* Setup error IRQ handler */
dev->emac_irq = platform_get_irq(ofdev, 0);
if (dev->emac_irq < 0) {
err = dev->emac_irq;
goto err_gone;
}
err = devm_request_irq(&ofdev->dev, dev->emac_irq, emac_irq, 0, "EMAC",
dev);
if (err) {
dev_err_probe(&ofdev->dev, err, "failed to request IRQ %d",
dev->emac_irq);
goto err_gone;
}
ndev->irq = dev->emac_irq;
Annotation
- Immediate include surface: `linux/module.h`, `linux/sched.h`, `linux/string.h`, `linux/errno.h`, `linux/delay.h`, `linux/types.h`, `linux/pci.h`, `linux/etherdevice.h`.
- Detected declarations: `struct emac_depentry`, `function emac_report_timeout_error`, `function emac_rx_clk_tx`, `function emac_rx_clk_default`, `function emac_phy_supports_gige`, `function emac_phy_gpcs`, `function emac_tx_enable`, `function emac_tx_disable`, `function emac_rx_enable`, `function emac_rx_disable`.
- 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.