drivers/net/ethernet/marvell/mv643xx_eth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/marvell/mv643xx_eth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/marvell/mv643xx_eth.c- Extension
.c- Size
- 81374 bytes
- Lines
- 3332
- 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/init.hlinux/dma-mapping.hlinux/in.hlinux/ip.hnet/tso.hlinux/tcp.hlinux/udp.hlinux/etherdevice.hlinux/delay.hlinux/ethtool.hlinux/platform_device.hlinux/module.hlinux/kernel.hlinux/spinlock.hlinux/workqueue.hlinux/phy.hlinux/mv643xx_eth.hlinux/io.hlinux/interrupt.hlinux/types.hlinux/slab.hlinux/clk.hlinux/of.hlinux/of_irq.hlinux/of_net.hlinux/of_mdio.h
Detected Declarations
struct rx_descstruct tx_descstruct rx_descstruct tx_descstruct mv643xx_eth_shared_privatestruct mib_countersstruct rx_queuestruct tx_queuestruct mv643xx_eth_privatestruct mv643xx_eth_statsfunction rdlfunction rdlpfunction wrlfunction wrlpfunction rxq_enablefunction rxq_disablefunction txq_reset_hw_ptrfunction txq_enablefunction txq_disablefunction txq_maybe_wakefunction rxq_processfunction rxq_refillfunction has_tiny_unaligned_fragsfunction skb_tx_csumfunction txq_put_data_tsofunction txq_put_hdr_tsofunction txq_submit_tsofunction txq_submit_frag_skbfunction txq_submit_skbfunction mv643xx_eth_xmitfunction txq_kickfunction txq_reclaimfunction ratefunction txq_set_ratefunction txq_set_fixed_prio_modefunction mv643xx_eth_adjust_linkfunction mib_readfunction mib_counters_clearfunction mib_counters_updatefunction mib_counters_timer_wrapperfunction get_rx_coalfunction set_rx_coalfunction get_tx_coalfunction set_tx_coalfunction mv643xx_eth_get_link_ksettings_phyfunction mv643xx_eth_get_link_ksettings_phylessfunction mv643xx_eth_get_wolfunction mv643xx_eth_set_wol
Annotated Snippet
static const struct net_device_ops mv643xx_eth_netdev_ops = {
.ndo_open = mv643xx_eth_open,
.ndo_stop = mv643xx_eth_stop,
.ndo_start_xmit = mv643xx_eth_xmit,
.ndo_set_rx_mode = mv643xx_eth_set_rx_mode,
.ndo_set_mac_address = mv643xx_eth_set_mac_address,
.ndo_validate_addr = eth_validate_addr,
.ndo_eth_ioctl = mv643xx_eth_ioctl,
.ndo_change_mtu = mv643xx_eth_change_mtu,
.ndo_set_features = mv643xx_eth_set_features,
.ndo_tx_timeout = mv643xx_eth_tx_timeout,
.ndo_get_stats = mv643xx_eth_get_stats,
#ifdef CONFIG_NET_POLL_CONTROLLER
.ndo_poll_controller = mv643xx_eth_netpoll,
#endif
};
static int mv643xx_eth_probe(struct platform_device *pdev)
{
struct mv643xx_eth_platform_data *pd;
struct mv643xx_eth_private *mp;
struct net_device *dev;
struct phy_device *phydev = NULL;
u32 psc1r;
int err, irq;
pd = dev_get_platdata(&pdev->dev);
if (pd == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data\n");
return -ENODEV;
}
if (pd->shared == NULL) {
dev_err(&pdev->dev, "no mv643xx_eth_platform_data->shared\n");
return -ENODEV;
}
dev = alloc_etherdev_mq(sizeof(struct mv643xx_eth_private), 8);
if (!dev)
return -ENOMEM;
SET_NETDEV_DEV(dev, &pdev->dev);
mp = netdev_priv(dev);
platform_set_drvdata(pdev, mp);
mp->shared = platform_get_drvdata(pd->shared);
mp->base = mp->shared->base + 0x0400 + (pd->port_number << 10);
mp->port_num = pd->port_number;
mp->dev = dev;
if (of_device_is_compatible(pdev->dev.of_node,
"marvell,kirkwood-eth-port")) {
psc1r = rdlp(mp, PORT_SERIAL_CONTROL1);
/* Kirkwood resets some registers on gated clocks. Especially
* CLK125_BYPASS_EN must be cleared but is not available on
* all other SoCs/System Controllers using this driver.
*/
psc1r &= ~CLK125_BYPASS_EN;
/* On Kirkwood with two Ethernet controllers, if both of them
* have RGMII_EN disabled, the first controller will be in GMII
* mode and the second one is effectively disabled, instead of
* two MII interfaces.
*
* To enable GMII in the first controller, the second one must
* also be configured (and may be enabled) with RGMII_EN
* disabled too, even though it cannot be used at all.
*/
switch (pd->interface) {
/* Use internal to denote second controller being disabled */
case PHY_INTERFACE_MODE_INTERNAL:
case PHY_INTERFACE_MODE_MII:
case PHY_INTERFACE_MODE_GMII:
psc1r &= ~RGMII_EN;
break;
case PHY_INTERFACE_MODE_RGMII:
case PHY_INTERFACE_MODE_RGMII_ID:
case PHY_INTERFACE_MODE_RGMII_RXID:
case PHY_INTERFACE_MODE_RGMII_TXID:
psc1r |= RGMII_EN;
break;
default:
/* Unknown; don't touch */
break;
}
wrlp(mp, PORT_SERIAL_CONTROL1, psc1r);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/dma-mapping.h`, `linux/in.h`, `linux/ip.h`, `net/tso.h`, `linux/tcp.h`, `linux/udp.h`, `linux/etherdevice.h`.
- Detected declarations: `struct rx_desc`, `struct tx_desc`, `struct rx_desc`, `struct tx_desc`, `struct mv643xx_eth_shared_private`, `struct mib_counters`, `struct rx_queue`, `struct tx_queue`, `struct mv643xx_eth_private`, `struct mv643xx_eth_stats`.
- 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.