drivers/net/ethernet/ec_bhf.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/ec_bhf.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/ec_bhf.c- Extension
.c- Size
- 14207 bytes
- Lines
- 595
- 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/moduleparam.hlinux/pci.hlinux/init.hlinux/netdevice.hlinux/etherdevice.hlinux/ip.hlinux/skbuff.hlinux/hrtimer.hlinux/interrupt.hlinux/stat.h
Detected Declarations
struct rx_headerstruct rx_descstruct tx_headerstruct tx_descstruct bhf_dmastruct ec_bhf_privfunction ec_bhf_resetfunction ec_bhf_send_packetfunction ec_bhf_desc_sentfunction ec_bhf_process_txfunction ec_bhf_pkt_receivedfunction ec_bhf_add_rx_descfunction ec_bhf_process_rxfunction ec_bhf_timer_funfunction ec_bhf_setup_offsetsfunction ec_bhf_start_xmitfunction ec_bhf_alloc_dma_memfunction ec_bhf_setup_tx_descsfunction ec_bhf_setup_rx_descsfunction ec_bhf_openfunction ec_bhf_stopfunction ec_bhf_get_statsfunction ec_bhf_probefunction ec_bhf_remove
Annotated Snippet
static const struct net_device_ops ec_bhf_netdev_ops = {
.ndo_start_xmit = ec_bhf_start_xmit,
.ndo_open = ec_bhf_open,
.ndo_stop = ec_bhf_stop,
.ndo_get_stats64 = ec_bhf_get_stats,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr
};
static int ec_bhf_probe(struct pci_dev *dev, const struct pci_device_id *id)
{
struct net_device *net_dev;
struct ec_bhf_priv *priv;
void __iomem *dma_io;
u8 addr[ETH_ALEN];
void __iomem *io;
int err = 0;
err = pci_enable_device(dev);
if (err)
return err;
pci_set_master(dev);
err = dma_set_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32));
if (err) {
dev_err(&dev->dev,
"Required dma mask not supported, failed to initialize device\n");
goto err_disable_dev;
}
err = pci_request_regions(dev, "ec_bhf");
if (err) {
dev_err(&dev->dev, "Failed to request pci memory regions\n");
goto err_disable_dev;
}
io = pci_iomap(dev, 0, 0);
if (!io) {
dev_err(&dev->dev, "Failed to map pci card memory bar 0");
err = -EIO;
goto err_release_regions;
}
dma_io = pci_iomap(dev, 2, 0);
if (!dma_io) {
dev_err(&dev->dev, "Failed to map pci card memory bar 2");
err = -EIO;
goto err_unmap;
}
net_dev = alloc_etherdev(sizeof(struct ec_bhf_priv));
if (net_dev == NULL) {
err = -ENOMEM;
goto err_unmap_dma_io;
}
pci_set_drvdata(dev, net_dev);
SET_NETDEV_DEV(net_dev, &dev->dev);
net_dev->features = 0;
net_dev->flags |= IFF_NOARP;
net_dev->netdev_ops = &ec_bhf_netdev_ops;
priv = netdev_priv(net_dev);
priv->net_dev = net_dev;
priv->io = io;
priv->dma_io = dma_io;
priv->dev = dev;
err = ec_bhf_setup_offsets(priv);
if (err < 0)
goto err_free_net_dev;
memcpy_fromio(addr, priv->mii_io + MII_MAC_ADDR, ETH_ALEN);
eth_hw_addr_set(net_dev, addr);
err = register_netdev(net_dev);
if (err < 0)
goto err_free_net_dev;
return 0;
err_free_net_dev:
free_netdev(net_dev);
err_unmap_dma_io:
pci_iounmap(dev, dma_io);
err_unmap:
pci_iounmap(dev, io);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/pci.h`, `linux/init.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ip.h`.
- Detected declarations: `struct rx_header`, `struct rx_desc`, `struct tx_header`, `struct tx_desc`, `struct bhf_dma`, `struct ec_bhf_priv`, `function ec_bhf_reset`, `function ec_bhf_send_packet`, `function ec_bhf_desc_sent`, `function ec_bhf_process_tx`.
- 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.