drivers/net/ethernet/socionext/sni_ave.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/socionext/sni_ave.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/socionext/sni_ave.c- Extension
.c- Size
- 49713 bytes
- Lines
- 1985
- 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.
- 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/bitops.hlinux/clk.hlinux/etherdevice.hlinux/interrupt.hlinux/io.hlinux/iopoll.hlinux/mfd/syscon.hlinux/mii.hlinux/module.hlinux/netdevice.hlinux/of.hlinux/of_net.hlinux/of_mdio.hlinux/phy.hlinux/platform_device.hlinux/regmap.hlinux/reset.hlinux/types.hlinux/u64_stats_sync.h
Detected Declarations
struct ave_descstruct ave_desc_infostruct ave_statsstruct ave_privatestruct ave_soc_dataenum desc_idenum desc_statefunction ave_desc_readfunction ave_desc_read_cmdstsfunction ave_desc_writefunction ave_desc_write_cmdstsfunction ave_desc_write_addrfunction ave_irq_disable_allfunction ave_irq_restorefunction ave_irq_enablefunction ave_hw_write_macaddrfunction ave_hw_read_versionfunction ave_ethtool_get_drvinfofunction ave_ethtool_get_msglevelfunction ave_ethtool_set_msglevelfunction ave_ethtool_get_wolfunction __ave_ethtool_set_wolfunction ave_ethtool_set_wolfunction ave_ethtool_get_pauseparamfunction ave_ethtool_set_pauseparamfunction ave_mdiobus_readfunction ave_mdiobus_writefunction ave_dma_mapfunction ave_dma_unmapfunction ave_rxdesc_preparefunction ave_desc_switchfunction ave_tx_completefunction ave_rx_receivefunction ave_napi_poll_rxfunction ave_napi_poll_txfunction ave_global_resetfunction ave_rxfifo_resetfunction ave_irq_handlerfunction ave_pfsel_startfunction ave_pfsel_stopfunction ave_pfsel_set_macaddrfunction ave_pfsel_set_promiscfunction ave_pfsel_initfunction ave_phy_adjust_linkfunction ave_macaddr_initfunction ave_initfunction ave_uninitfunction ave_open
Annotated Snippet
static const struct net_device_ops ave_netdev_ops = {
.ndo_init = ave_init,
.ndo_uninit = ave_uninit,
.ndo_open = ave_open,
.ndo_stop = ave_stop,
.ndo_start_xmit = ave_start_xmit,
.ndo_eth_ioctl = ave_ioctl,
.ndo_set_rx_mode = ave_set_rx_mode,
.ndo_get_stats64 = ave_get_stats64,
.ndo_set_mac_address = ave_set_mac_address,
};
static int ave_probe(struct platform_device *pdev)
{
const struct ave_soc_data *data;
struct device *dev = &pdev->dev;
char buf[ETHTOOL_FWVERS_LEN];
struct of_phandle_args args;
phy_interface_t phy_mode;
struct ave_private *priv;
struct net_device *ndev;
struct device_node *np;
void __iomem *base;
const char *name;
int i, irq, ret;
u64 dma_mask;
u32 ave_id;
data = of_device_get_match_data(dev);
if (WARN_ON(!data))
return -EINVAL;
np = dev->of_node;
ret = of_get_phy_mode(np, &phy_mode);
if (ret) {
dev_err(dev, "phy-mode not found\n");
return ret;
}
irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(base))
return PTR_ERR(base);
ndev = devm_alloc_etherdev(dev, sizeof(struct ave_private));
if (!ndev) {
dev_err(dev, "can't allocate ethernet device\n");
return -ENOMEM;
}
ndev->netdev_ops = &ave_netdev_ops;
ndev->ethtool_ops = &ave_ethtool_ops;
SET_NETDEV_DEV(ndev, dev);
ndev->features |= (NETIF_F_IP_CSUM | NETIF_F_RXCSUM);
ndev->hw_features |= (NETIF_F_IP_CSUM | NETIF_F_RXCSUM);
ndev->max_mtu = AVE_MAX_ETHFRAME - (ETH_HLEN + ETH_FCS_LEN);
ret = of_get_ethdev_address(np, ndev);
if (ret) {
/* if the mac address is invalid, use random mac address */
eth_hw_addr_random(ndev);
dev_warn(dev, "Using random MAC address: %pM\n",
ndev->dev_addr);
}
priv = netdev_priv(ndev);
priv->base = base;
priv->irq = irq;
priv->ndev = ndev;
priv->msg_enable = netif_msg_init(-1, AVE_DEFAULT_MSG_ENABLE);
priv->phy_mode = phy_mode;
priv->data = data;
if (IS_DESC_64BIT(priv)) {
priv->desc_size = AVE_DESC_SIZE_64;
priv->tx.daddr = AVE_TXDM_64;
priv->rx.daddr = AVE_RXDM_64;
dma_mask = DMA_BIT_MASK(64);
} else {
priv->desc_size = AVE_DESC_SIZE_32;
priv->tx.daddr = AVE_TXDM_32;
priv->rx.daddr = AVE_RXDM_32;
dma_mask = DMA_BIT_MASK(32);
}
ret = dma_set_mask(dev, dma_mask);
Annotation
- Immediate include surface: `linux/bitops.h`, `linux/clk.h`, `linux/etherdevice.h`, `linux/interrupt.h`, `linux/io.h`, `linux/iopoll.h`, `linux/mfd/syscon.h`, `linux/mii.h`.
- Detected declarations: `struct ave_desc`, `struct ave_desc_info`, `struct ave_stats`, `struct ave_private`, `struct ave_soc_data`, `enum desc_id`, `enum desc_state`, `function ave_desc_read`, `function ave_desc_read_cmdsts`, `function ave_desc_write`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: pattern implementation candidate.
- 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.