drivers/net/ethernet/rdc/r6040.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/rdc/r6040.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/rdc/r6040.c- Extension
.c- Size
- 32343 bytes
- Lines
- 1216
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/module.hlinux/moduleparam.hlinux/string.hlinux/timer.hlinux/errno.hlinux/ioport.hlinux/interrupt.hlinux/pci.hlinux/netdevice.hlinux/etherdevice.hlinux/skbuff.hlinux/delay.hlinux/mii.hlinux/ethtool.hlinux/crc32.hlinux/spinlock.hlinux/bitops.hlinux/io.hlinux/irq.hlinux/uaccess.hlinux/phy.hasm/processor.h
Detected Declarations
struct r6040_descriptorstruct r6040_privatefunction r6040_phy_readfunction r6040_phy_writefunction r6040_mdiobus_readfunction r6040_mdiobus_writefunction r6040_free_txbufsfunction r6040_free_rxbufsfunction r6040_init_ring_descfunction r6040_init_txbufsfunction r6040_alloc_rxbufsfunction r6040_reset_macfunction r6040_init_mac_regsfunction r6040_tx_timeoutfunction r6040_downfunction r6040_closefunction r6040_rxfunction r6040_txfunction r6040_pollfunction r6040_interruptfunction r6040_poll_controllerfunction r6040_upfunction r6040_mac_addressfunction r6040_openfunction r6040_start_xmitfunction r6040_multicast_listfunction netdev_for_each_mc_addrfunction netdev_for_each_mc_addrfunction netdev_get_drvinfofunction r6040_adjust_linkfunction r6040_mii_probefunction r6040_init_onefunction r6040_remove_one
Annotated Snippet
static const struct net_device_ops r6040_netdev_ops = {
.ndo_open = r6040_open,
.ndo_stop = r6040_close,
.ndo_start_xmit = r6040_start_xmit,
.ndo_get_stats = r6040_get_stats,
.ndo_set_rx_mode = r6040_multicast_list,
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = eth_mac_addr,
.ndo_eth_ioctl = phy_do_ioctl,
.ndo_tx_timeout = r6040_tx_timeout,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = r6040_poll_controller,
#endif
};
static void r6040_adjust_link(struct net_device *dev)
{
struct r6040_private *lp = netdev_priv(dev);
struct phy_device *phydev = dev->phydev;
int status_changed = 0;
void __iomem *ioaddr = lp->base;
BUG_ON(!phydev);
if (lp->old_link != phydev->link) {
status_changed = 1;
lp->old_link = phydev->link;
}
/* reflect duplex change */
if (phydev->link && (lp->old_duplex != phydev->duplex)) {
lp->mcr0 |= (phydev->duplex == DUPLEX_FULL ? MCR0_FD : 0);
iowrite16(lp->mcr0, ioaddr);
status_changed = 1;
lp->old_duplex = phydev->duplex;
}
if (status_changed)
phy_print_status(phydev);
}
static int r6040_mii_probe(struct net_device *dev)
{
struct r6040_private *lp = netdev_priv(dev);
struct phy_device *phydev = NULL;
phydev = phy_find_first(lp->mii_bus);
if (!phydev) {
dev_err(&lp->pdev->dev, "no PHY found\n");
return -ENODEV;
}
phydev = phy_connect(dev, phydev_name(phydev), &r6040_adjust_link,
PHY_INTERFACE_MODE_MII);
if (IS_ERR(phydev)) {
dev_err(&lp->pdev->dev, "could not attach to PHY\n");
return PTR_ERR(phydev);
}
phy_set_max_speed(phydev, SPEED_100);
lp->old_link = 0;
lp->old_duplex = -1;
phy_attached_info(phydev);
return 0;
}
static int r6040_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
{
struct net_device *dev;
struct r6040_private *lp;
void __iomem *ioaddr;
int err, io_size = R6040_IO_SIZE;
static int card_idx = -1;
u16 addr[ETH_ALEN / 2];
int bar = 0;
pr_info("%s\n", version);
err = pci_enable_device(pdev);
if (err)
goto err_out;
/* this should always be supported */
err = dma_set_mask(&pdev->dev, DMA_BIT_MASK(32));
if (err) {
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/moduleparam.h`, `linux/string.h`, `linux/timer.h`, `linux/errno.h`, `linux/ioport.h`, `linux/interrupt.h`.
- Detected declarations: `struct r6040_descriptor`, `struct r6040_private`, `function r6040_phy_read`, `function r6040_phy_write`, `function r6040_mdiobus_read`, `function r6040_mdiobus_write`, `function r6040_free_txbufs`, `function r6040_free_rxbufs`, `function r6040_init_ring_desc`, `function r6040_init_txbufs`.
- 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.