drivers/net/ethernet/cortina/gemini.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/cortina/gemini.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/cortina/gemini.c- Extension
.c- Size
- 72523 bytes
- Lines
- 2709
- 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/kernel.hlinux/init.hlinux/module.hlinux/platform_device.hlinux/spinlock.hlinux/slab.hlinux/dma-mapping.hlinux/cache.hlinux/interrupt.hlinux/reset.hlinux/clk.hlinux/of.hlinux/of_mdio.hlinux/of_net.hlinux/of_platform.hlinux/etherdevice.hlinux/if_vlan.hlinux/skbuff.hlinux/phy.hlinux/crc32.hlinux/ethtool.hlinux/tcp.hlinux/u64_stats_sync.hlinux/in.hlinux/ip.hlinux/ipv6.hnet/gro.hgemini.h
Detected Declarations
struct gmac_queue_pagestruct gmac_txqstruct gemini_ethernetstruct gemini_ethernet_portstruct gemini_ethernetstruct gmac_max_framelenfunction gmac_update_config0_regfunction gmac_enable_tx_rxfunction gmac_disable_tx_rxfunction gmac_set_flow_controlfunction gmac_adjust_linkfunction gmac_setup_phyfunction gmac_pick_rx_max_lenfunction gmac_initfunction gmac_setup_txqsfunction gmac_clean_txqfunction gmac_cleanup_txqsfunction gmac_setup_rxqfunction gmac_get_queue_pagefunction gmac_cleanup_rxqfunction geth_fill_freeqfunction geth_setup_freeqfunction geth_cleanup_freeqfunction geth_resize_freeqfunction gmac_tx_irq_enablefunction gmac_tx_irqfunction gmac_map_tx_bufsfunction gmac_start_xmitfunction gmac_tx_timeoutfunction gmac_enable_irqfunction gmac_enable_rx_irqfunction gmac_rxfunction gmac_napi_pollfunction gmac_dump_dma_statefunction gmac_update_hw_statsfunction gmac_get_intr_flagsfunction gmac_coalesce_delay_expiredfunction gmac_irqfunction gmac_start_dmafunction gmac_stop_dmafunction gmac_openfunction gmac_stopfunction gmac_set_rx_modefunction netdev_for_each_mc_addrfunction gmac_write_mac_addressfunction gmac_set_mac_addressfunction gmac_clear_hw_statsfunction gmac_get_stats64
Annotated Snippet
static const struct net_device_ops gmac_351x_ops = {
.ndo_init = gmac_init,
.ndo_open = gmac_open,
.ndo_stop = gmac_stop,
.ndo_start_xmit = gmac_start_xmit,
.ndo_tx_timeout = gmac_tx_timeout,
.ndo_set_rx_mode = gmac_set_rx_mode,
.ndo_set_mac_address = gmac_set_mac_address,
.ndo_get_stats64 = gmac_get_stats64,
.ndo_change_mtu = gmac_change_mtu,
.ndo_set_features = gmac_set_features,
};
static const struct ethtool_ops gmac_351x_ethtool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS |
ETHTOOL_COALESCE_MAX_FRAMES,
.get_sset_count = gmac_get_sset_count,
.get_strings = gmac_get_strings,
.get_ethtool_stats = gmac_get_ethtool_stats,
.get_link = ethtool_op_get_link,
.get_link_ksettings = gmac_get_ksettings,
.set_link_ksettings = gmac_set_ksettings,
.nway_reset = gmac_nway_reset,
.get_pauseparam = gmac_get_pauseparam,
.set_pauseparam = gmac_set_pauseparam,
.get_ringparam = gmac_get_ringparam,
.set_ringparam = gmac_set_ringparam,
.get_coalesce = gmac_get_coalesce,
.set_coalesce = gmac_set_coalesce,
.get_msglevel = gmac_get_msglevel,
.set_msglevel = gmac_set_msglevel,
.get_drvinfo = gmac_get_drvinfo,
};
static irqreturn_t gemini_port_irq_thread(int irq, void *data)
{
unsigned long irqmask = SWFQ_EMPTY_INT_BIT;
struct gemini_ethernet_port *port = data;
struct gemini_ethernet *geth;
unsigned long flags;
geth = port->geth;
/* The queue is half empty so refill it */
geth_fill_freeq(geth, true);
spin_lock_irqsave(&geth->irq_lock, flags);
/* ACK queue interrupt */
writel(irqmask, geth->base + GLOBAL_INTERRUPT_STATUS_4_REG);
/* Enable queue interrupt again */
irqmask |= readl(geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
writel(irqmask, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
spin_unlock_irqrestore(&geth->irq_lock, flags);
return IRQ_HANDLED;
}
static irqreturn_t gemini_port_irq(int irq, void *data)
{
struct gemini_ethernet_port *port = data;
struct gemini_ethernet *geth;
irqreturn_t ret = IRQ_NONE;
u32 val, en;
geth = port->geth;
spin_lock(&geth->irq_lock);
val = readl(geth->base + GLOBAL_INTERRUPT_STATUS_4_REG);
en = readl(geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
if (val & en & SWFQ_EMPTY_INT_BIT) {
/* Disable the queue empty interrupt while we work on
* processing the queue. Also disable overrun interrupts
* as there is not much we can do about it here.
*/
en &= ~(SWFQ_EMPTY_INT_BIT | GMAC0_RX_OVERRUN_INT_BIT
| GMAC1_RX_OVERRUN_INT_BIT);
writel(en, geth->base + GLOBAL_INTERRUPT_ENABLE_4_REG);
ret = IRQ_WAKE_THREAD;
}
spin_unlock(&geth->irq_lock);
return ret;
}
static void gemini_port_remove(struct gemini_ethernet_port *port)
{
if (port->netdev) {
phy_disconnect(port->netdev->phydev);
unregister_netdev(port->netdev);
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/module.h`, `linux/platform_device.h`, `linux/spinlock.h`, `linux/slab.h`, `linux/dma-mapping.h`, `linux/cache.h`.
- Detected declarations: `struct gmac_queue_page`, `struct gmac_txq`, `struct gemini_ethernet`, `struct gemini_ethernet_port`, `struct gemini_ethernet`, `struct gmac_max_framelen`, `function gmac_update_config0_reg`, `function gmac_enable_tx_rx`, `function gmac_disable_tx_rx`, `function gmac_set_flow_control`.
- 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.