drivers/net/ethernet/marvell/mvneta.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/mvneta.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/mvneta.c- Extension
.c- Size
- 164327 bytes
- Lines
- 5976
- 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/clk.hlinux/cpu.hlinux/etherdevice.hlinux/if_vlan.hlinux/inetdevice.hlinux/interrupt.hlinux/io.hlinux/kernel.hlinux/mbus.hlinux/module.hlinux/netdevice.hlinux/of.hlinux/of_address.hlinux/of_irq.hlinux/of_mdio.hlinux/of_net.hlinux/phy/phy.hlinux/phy.hlinux/phylink.hlinux/platform_device.hlinux/skbuff.hnet/hwbm.hmvneta_bm.hnet/ip.hnet/ipv6.hnet/tso.hnet/page_pool/helpers.hnet/pkt_sched.hlinux/bpf_trace.h
Detected Declarations
struct mvneta_statisticstruct mvneta_statsstruct mvneta_ethtool_statsstruct mvneta_pcpu_statsstruct mvneta_pcpu_portstruct mvneta_portstruct mvneta_tx_descstruct mvneta_rx_descstruct mvneta_tx_descstruct mvneta_rx_descstruct mvneta_tx_bufstruct mvneta_tx_queuestruct mvneta_rx_queueenum mvneta_tx_buf_typefunction mvreg_writefunction mvreg_readfunction mvneta_txq_inc_getfunction mvneta_txq_inc_putfunction mvneta_mib_counters_clearfunction mvneta_get_stats64function for_each_possible_cpufunction mvneta_rxq_desc_is_first_lastfunction mvneta_rxq_non_occup_desc_addfunction mvneta_rxq_busy_desc_num_getfunction mvneta_rxq_drop_pktsfunction mvneta_rxq_next_desc_getfunction mvneta_max_rx_size_setfunction mvneta_rxq_offset_setfunction mvneta_txq_pend_desc_addfunction mvneta_txq_next_desc_getfunction mvneta_txq_desc_putfunction mvneta_rxq_buf_size_setfunction mvneta_rxq_bm_disablefunction mvneta_rxq_bm_enablefunction mvneta_rxq_long_pool_setfunction mvneta_rxq_short_pool_setfunction mvneta_bm_pool_bufsize_setfunction mvneta_mbus_io_win_setfunction mvneta_bm_port_mbus_initfunction mvneta_bm_port_initfunction mvneta_bm_update_mtufunction mvneta_port_upfunction mvneta_port_downfunction mvneta_port_enablefunction mvneta_port_disablefunction mvneta_set_ucast_tablefunction mvneta_set_special_mcast_tablefunction mvneta_set_other_mcast_table
Annotated Snippet
static const struct net_device_ops mvneta_netdev_ops = {
.ndo_open = mvneta_open,
.ndo_stop = mvneta_stop,
.ndo_start_xmit = mvneta_tx,
.ndo_set_rx_mode = mvneta_set_rx_mode,
.ndo_set_mac_address = mvneta_set_mac_addr,
.ndo_change_mtu = mvneta_change_mtu,
.ndo_fix_features = mvneta_fix_features,
.ndo_get_stats64 = mvneta_get_stats64,
.ndo_eth_ioctl = mvneta_ioctl,
.ndo_bpf = mvneta_xdp,
.ndo_xdp_xmit = mvneta_xdp_xmit,
.ndo_setup_tc = mvneta_setup_tc,
};
static const struct ethtool_ops mvneta_eth_tool_ops = {
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS |
ETHTOOL_COALESCE_MAX_FRAMES,
.nway_reset = mvneta_ethtool_nway_reset,
.get_link = ethtool_op_get_link,
.set_coalesce = mvneta_ethtool_set_coalesce,
.get_coalesce = mvneta_ethtool_get_coalesce,
.get_drvinfo = mvneta_ethtool_get_drvinfo,
.get_ringparam = mvneta_ethtool_get_ringparam,
.set_ringparam = mvneta_ethtool_set_ringparam,
.get_pauseparam = mvneta_ethtool_get_pauseparam,
.set_pauseparam = mvneta_ethtool_set_pauseparam,
.get_strings = mvneta_ethtool_get_strings,
.get_ethtool_stats = mvneta_ethtool_get_stats,
.get_sset_count = mvneta_ethtool_get_sset_count,
.get_rxfh_indir_size = mvneta_ethtool_get_rxfh_indir_size,
.get_rx_ring_count = mvneta_ethtool_get_rx_ring_count,
.get_rxfh = mvneta_ethtool_get_rxfh,
.set_rxfh = mvneta_ethtool_set_rxfh,
.get_link_ksettings = mvneta_ethtool_get_link_ksettings,
.set_link_ksettings = mvneta_ethtool_set_link_ksettings,
.get_wol = mvneta_ethtool_get_wol,
.set_wol = mvneta_ethtool_set_wol,
.get_ts_info = ethtool_op_get_ts_info,
.get_eee = mvneta_ethtool_get_eee,
.set_eee = mvneta_ethtool_set_eee,
};
/* Initialize hw */
static int mvneta_init(struct device *dev, struct mvneta_port *pp)
{
int queue;
/* Disable port */
mvneta_port_disable(pp);
/* Set port default values */
mvneta_defaults_set(pp);
pp->txqs = devm_kcalloc(dev, txq_number, sizeof(*pp->txqs), GFP_KERNEL);
if (!pp->txqs)
return -ENOMEM;
/* Initialize TX descriptor rings */
for (queue = 0; queue < txq_number; queue++) {
struct mvneta_tx_queue *txq = &pp->txqs[queue];
txq->id = queue;
txq->size = pp->tx_ring_size;
txq->done_pkts_coal = MVNETA_TXDONE_COAL_PKTS;
}
pp->rxqs = devm_kcalloc(dev, rxq_number, sizeof(*pp->rxqs), GFP_KERNEL);
if (!pp->rxqs)
return -ENOMEM;
/* Create Rx descriptor rings */
for (queue = 0; queue < rxq_number; queue++) {
struct mvneta_rx_queue *rxq = &pp->rxqs[queue];
rxq->id = queue;
rxq->size = pp->rx_ring_size;
rxq->pkts_coal = MVNETA_RX_COAL_PKTS;
rxq->time_coal = MVNETA_RX_COAL_USEC;
rxq->buf_virt_addr
= devm_kmalloc_array(pp->dev->dev.parent,
rxq->size,
sizeof(*rxq->buf_virt_addr),
GFP_KERNEL);
if (!rxq->buf_virt_addr)
return -ENOMEM;
}
return 0;
}
/* platform glue : initialize decoding windows */
Annotation
- Immediate include surface: `linux/clk.h`, `linux/cpu.h`, `linux/etherdevice.h`, `linux/if_vlan.h`, `linux/inetdevice.h`, `linux/interrupt.h`, `linux/io.h`, `linux/kernel.h`.
- Detected declarations: `struct mvneta_statistic`, `struct mvneta_stats`, `struct mvneta_ethtool_stats`, `struct mvneta_pcpu_stats`, `struct mvneta_pcpu_port`, `struct mvneta_port`, `struct mvneta_tx_desc`, `struct mvneta_rx_desc`, `struct mvneta_tx_desc`, `struct mvneta_rx_desc`.
- 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.