drivers/net/ethernet/airoha/airoha_eth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/airoha/airoha_eth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/airoha/airoha_eth.c- Extension
.c- Size
- 101394 bytes
- Lines
- 3716
- 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/of.hlinux/of_net.hlinux/of_reserved_mem.hlinux/platform_device.hlinux/tcp.hlinux/u64_stats_sync.hnet/dst_metadata.hnet/page_pool/helpers.hnet/pkt_cls.huapi/linux/ppp_defs.hairoha_regs.hairoha_eth.h
Detected Declarations
function Copyrightfunction airoha_wrfunction airoha_rmwfunction airoha_qdma_set_irqmaskfunction airoha_qdma_irq_enablefunction airoha_qdma_irq_disablefunction airoha_set_macaddrfunction airoha_set_gdm_port_fwd_cfgfunction airoha_set_vip_for_gdm_portfunction airoha_fe_maccr_initfunction airoha_fe_vip_setupfunction airoha_fe_get_pse_queue_rsv_pagesfunction airoha_fe_set_pse_queue_rsv_pagesfunction airoha_fe_get_pse_all_rsvfunction airoha_fe_set_pse_oq_rsvfunction airoha_fe_pse_ports_initfunction airoha_fe_mc_vlan_clearfunction airoha_fe_crsn_qsel_initfunction airoha_fe_initfunction airoha_qdma_fill_rx_queuefunction airoha_qdma_get_gdm_devfunction airoha_qdma_rx_processfunction airoha_qdma_rx_napi_pollfunction airoha_qdma_init_rx_queuefunction airoha_qdma_cleanup_rx_queuefunction airoha_qdma_init_rxfunction airoha_qdma_wake_netdev_txqsfunction airoha_qdma_tx_napi_pollfunction airoha_qdma_init_tx_queuefunction airoha_qdma_tx_irq_initfunction airoha_qdma_init_txfunction airoha_qdma_cleanup_tx_queuefunction airoha_qdma_init_hfwd_queuesfunction airoha_qdma_init_qosfunction airoha_qdma_init_qos_statsfunction airoha_qdma_hw_initfunction airoha_irq_handlerfunction airoha_qdma_init_irq_banksfunction airoha_qdma_initfunction airoha_qdma_cleanupfunction airoha_hw_initfunction airoha_hw_cleanupfunction airoha_qdma_start_napifunction airoha_qdma_stop_napifunction airoha_dev_get_hw_statsfunction airoha_update_hw_statsfunction airoha_dev_openfunction airoha_set_port_mtu
Annotated Snippet
static const struct net_device_ops airoha_netdev_ops = {
.ndo_init = airoha_dev_init,
.ndo_open = airoha_dev_open,
.ndo_stop = airoha_dev_stop,
.ndo_change_mtu = airoha_dev_change_mtu,
.ndo_select_queue = airoha_dev_select_queue,
.ndo_start_xmit = airoha_dev_xmit,
.ndo_get_stats64 = airoha_dev_get_stats64,
.ndo_set_mac_address = airoha_dev_set_macaddr,
.ndo_setup_tc = airoha_dev_tc_setup,
};
static const struct ethtool_ops airoha_ethtool_ops = {
.get_drvinfo = airoha_ethtool_get_drvinfo,
.get_eth_mac_stats = airoha_ethtool_get_mac_stats,
.get_rmon_stats = airoha_ethtool_get_rmon_stats,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.get_link = ethtool_op_get_link,
};
static int airoha_metadata_dst_alloc(struct airoha_gdm_port *port)
{
int i;
for (i = 0; i < ARRAY_SIZE(port->dsa_meta); i++) {
struct metadata_dst *md_dst;
md_dst = metadata_dst_alloc(0, METADATA_HW_PORT_MUX,
GFP_KERNEL);
if (!md_dst)
return -ENOMEM;
md_dst->u.port_info.port_id = i;
port->dsa_meta[i] = md_dst;
}
return 0;
}
static void airoha_metadata_dst_free(struct airoha_gdm_port *port)
{
int i;
for (i = 0; i < ARRAY_SIZE(port->dsa_meta); i++) {
if (!port->dsa_meta[i])
continue;
dst_release(&port->dsa_meta[i]->dst);
}
}
bool airoha_is_valid_gdm_dev(struct airoha_eth *eth,
struct airoha_gdm_dev *dev)
{
int i;
for (i = 0; i < ARRAY_SIZE(eth->ports); i++) {
struct airoha_gdm_port *port = eth->ports[i];
int j;
if (!port)
continue;
for (j = 0; j < ARRAY_SIZE(port->devs); j++) {
if (port->devs[j] == dev)
return true;
}
}
return false;
}
static int airoha_alloc_gdm_device(struct airoha_eth *eth,
struct airoha_gdm_port *port,
int nbq, struct device_node *np)
{
struct net_device *netdev;
struct airoha_gdm_dev *dev;
u8 index;
int err;
netdev = devm_alloc_etherdev_mqs(eth->dev, sizeof(*dev),
AIROHA_NUM_NETDEV_TX_RINGS,
AIROHA_NUM_RX_RING);
if (!netdev) {
dev_err(eth->dev, "alloc_etherdev failed\n");
return -ENOMEM;
}
netdev->netdev_ops = &airoha_netdev_ops;
Annotation
- Immediate include surface: `linux/of.h`, `linux/of_net.h`, `linux/of_reserved_mem.h`, `linux/platform_device.h`, `linux/tcp.h`, `linux/u64_stats_sync.h`, `net/dst_metadata.h`, `net/page_pool/helpers.h`.
- Detected declarations: `function Copyright`, `function airoha_wr`, `function airoha_rmw`, `function airoha_qdma_set_irqmask`, `function airoha_qdma_irq_enable`, `function airoha_qdma_irq_disable`, `function airoha_set_macaddr`, `function airoha_set_gdm_port_fwd_cfg`, `function airoha_set_vip_for_gdm_port`, `function airoha_fe_maccr_init`.
- 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.