drivers/net/ethernet/aeroflex/greth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/aeroflex/greth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/aeroflex/greth.c- Extension
.c- Size
- 39427 bytes
- Lines
- 1576
- 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/dma-mapping.hlinux/module.hlinux/uaccess.hlinux/interrupt.hlinux/netdevice.hlinux/etherdevice.hlinux/ethtool.hlinux/skbuff.hlinux/io.hlinux/crc32.hlinux/mii.hlinux/of.hlinux/of_net.hlinux/platform_device.hlinux/slab.hasm/cacheflush.hasm/byteorder.hasm/idprom.hgreth.h
Detected Declarations
function greth_print_rx_packetfunction greth_print_tx_packetfunction greth_enable_txfunction greth_enable_tx_and_irqfunction greth_disable_txfunction greth_enable_rxfunction greth_disable_rxfunction greth_enable_irqsfunction greth_disable_irqsfunction greth_write_bdfunction greth_read_bdfunction greth_clean_ringsfunction greth_init_ringsfunction greth_openfunction greth_closefunction greth_start_xmitfunction greth_num_free_bdsfunction greth_start_xmit_gbitfunction greth_interruptfunction greth_clean_txfunction greth_update_tx_statsfunction greth_clean_tx_gbitfunction greth_rxfunction hw_checksummedfunction greth_rx_gbitfunction greth_pollfunction greth_set_mac_addfunction greth_hash_get_indexfunction greth_set_hash_filterfunction netdev_for_each_mc_addrfunction greth_set_multicast_listfunction greth_get_msglevelfunction greth_set_msglevelfunction greth_get_regs_lenfunction greth_get_drvinfofunction greth_get_regsfunction wait_for_mdiofunction greth_mdio_readfunction greth_mdio_writefunction greth_link_changefunction greth_mdio_probefunction greth_mdio_initfunction greth_of_probefunction greth_of_remove
Annotated Snippet
static struct net_device_ops greth_netdev_ops = {
.ndo_open = greth_open,
.ndo_stop = greth_close,
.ndo_start_xmit = greth_start_xmit,
.ndo_set_mac_address = greth_set_mac_add,
.ndo_validate_addr = eth_validate_addr,
};
static inline int wait_for_mdio(struct greth_private *greth)
{
unsigned long timeout = jiffies + 4*HZ/100;
while (GRETH_REGLOAD(greth->regs->mdio) & GRETH_MII_BUSY) {
if (time_after(jiffies, timeout))
return 0;
}
return 1;
}
static int greth_mdio_read(struct mii_bus *bus, int phy, int reg)
{
struct greth_private *greth = bus->priv;
int data;
if (!wait_for_mdio(greth))
return -EBUSY;
GRETH_REGSAVE(greth->regs->mdio, ((phy & 0x1F) << 11) | ((reg & 0x1F) << 6) | 2);
if (!wait_for_mdio(greth))
return -EBUSY;
if (!(GRETH_REGLOAD(greth->regs->mdio) & GRETH_MII_NVALID)) {
data = (GRETH_REGLOAD(greth->regs->mdio) >> 16) & 0xFFFF;
return data;
} else {
return -1;
}
}
static int greth_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
{
struct greth_private *greth = bus->priv;
if (!wait_for_mdio(greth))
return -EBUSY;
GRETH_REGSAVE(greth->regs->mdio,
((val & 0xFFFF) << 16) | ((phy & 0x1F) << 11) | ((reg & 0x1F) << 6) | 1);
if (!wait_for_mdio(greth))
return -EBUSY;
return 0;
}
static void greth_link_change(struct net_device *dev)
{
struct greth_private *greth = netdev_priv(dev);
struct phy_device *phydev = dev->phydev;
unsigned long flags;
int status_change = 0;
u32 ctrl;
spin_lock_irqsave(&greth->devlock, flags);
if (phydev->link) {
if ((greth->speed != phydev->speed) || (greth->duplex != phydev->duplex)) {
ctrl = GRETH_REGLOAD(greth->regs->control) &
~(GRETH_CTRL_FD | GRETH_CTRL_SP | GRETH_CTRL_GB);
if (phydev->duplex)
ctrl |= GRETH_CTRL_FD;
if (phydev->speed == SPEED_100)
ctrl |= GRETH_CTRL_SP;
else if (phydev->speed == SPEED_1000)
ctrl |= GRETH_CTRL_GB;
GRETH_REGSAVE(greth->regs->control, ctrl);
greth->speed = phydev->speed;
greth->duplex = phydev->duplex;
status_change = 1;
}
}
if (phydev->link != greth->link) {
if (!phydev->link) {
greth->speed = 0;
Annotation
- Immediate include surface: `linux/dma-mapping.h`, `linux/module.h`, `linux/uaccess.h`, `linux/interrupt.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/ethtool.h`, `linux/skbuff.h`.
- Detected declarations: `function greth_print_rx_packet`, `function greth_print_tx_packet`, `function greth_enable_tx`, `function greth_enable_tx_and_irq`, `function greth_disable_tx`, `function greth_enable_rx`, `function greth_disable_rx`, `function greth_enable_irqs`, `function greth_disable_irqs`, `function greth_write_bd`.
- 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.