drivers/net/ethernet/hisilicon/hip04_eth.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hip04_eth.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hip04_eth.c- Extension
.c- Size
- 27115 bytes
- Lines
- 1058
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/etherdevice.hlinux/platform_device.hlinux/interrupt.hlinux/ktime.hlinux/of_address.hlinux/phy.hlinux/of_mdio.hlinux/of_net.hlinux/mfd/syscon.hlinux/regmap.h
Detected Declarations
struct tx_descstruct rx_descstruct hip04_privfunction tx_countfunction hip04_config_portfunction hip04_reset_dreqfunction hip04_reset_ppefunction hip04_config_fifofunction hip04_mac_enablefunction hip04_mac_disablefunction hip04_set_xmit_descfunction hip04_set_recv_descfunction hip04_recv_cntfunction hip04_update_mac_addressfunction hip04_set_mac_addressfunction hip04_tx_reclaimfunction hip04_start_tx_timerfunction hip04_mac_start_xmitfunction hip04_rx_pollfunction hip04_mac_interruptfunction tx_donefunction hip04_adjust_linkfunction hip04_mac_openfunction hip04_mac_stopfunction hip04_timeoutfunction hip04_tx_timeout_taskfunction hip04_get_coalescefunction hip04_set_coalescefunction hip04_get_drvinfofunction hip04_alloc_ringfunction hip04_free_ringfunction hip04_mac_probefunction hip04_remove
Annotated Snippet
static const struct net_device_ops hip04_netdev_ops = {
.ndo_open = hip04_mac_open,
.ndo_stop = hip04_mac_stop,
.ndo_start_xmit = hip04_mac_start_xmit,
.ndo_set_mac_address = hip04_set_mac_address,
.ndo_tx_timeout = hip04_timeout,
.ndo_validate_addr = eth_validate_addr,
};
static int hip04_alloc_ring(struct net_device *ndev, struct device *d)
{
struct hip04_priv *priv = netdev_priv(ndev);
int i;
priv->tx_desc = dma_alloc_coherent(d,
TX_DESC_NUM * sizeof(struct tx_desc),
&priv->tx_desc_dma, GFP_KERNEL);
if (!priv->tx_desc)
return -ENOMEM;
priv->rx_buf_size = RX_BUF_SIZE +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
for (i = 0; i < RX_DESC_NUM; i++) {
priv->rx_buf[i] = netdev_alloc_frag(priv->rx_buf_size);
if (!priv->rx_buf[i])
return -ENOMEM;
}
return 0;
}
static void hip04_free_ring(struct net_device *ndev, struct device *d)
{
struct hip04_priv *priv = netdev_priv(ndev);
int i;
for (i = 0; i < RX_DESC_NUM; i++)
if (priv->rx_buf[i])
skb_free_frag(priv->rx_buf[i]);
for (i = 0; i < TX_DESC_NUM; i++)
if (priv->tx_skb[i])
dev_kfree_skb_any(priv->tx_skb[i]);
dma_free_coherent(d, TX_DESC_NUM * sizeof(struct tx_desc),
priv->tx_desc, priv->tx_desc_dma);
}
static int hip04_mac_probe(struct platform_device *pdev)
{
struct device *d = &pdev->dev;
struct device_node *node = d->of_node;
struct of_phandle_args arg;
struct net_device *ndev;
struct hip04_priv *priv;
int irq;
int ret;
ndev = alloc_etherdev(sizeof(struct hip04_priv));
if (!ndev)
return -ENOMEM;
priv = netdev_priv(ndev);
priv->dev = d;
priv->ndev = ndev;
platform_set_drvdata(pdev, ndev);
SET_NETDEV_DEV(ndev, &pdev->dev);
priv->base = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(priv->base)) {
ret = PTR_ERR(priv->base);
goto init_fail;
}
#if defined(CONFIG_HI13X1_GMAC)
priv->sysctrl_base = devm_platform_ioremap_resource(pdev, 1);
if (IS_ERR(priv->sysctrl_base)) {
ret = PTR_ERR(priv->sysctrl_base);
goto init_fail;
}
#endif
ret = of_parse_phandle_with_fixed_args(node, "port-handle", 3, 0, &arg);
if (ret < 0) {
dev_warn(d, "no port-handle\n");
goto init_fail;
}
priv->port = arg.args[0];
priv->chan = arg.args[1] * RX_DESC_NUM;
Annotation
- Immediate include surface: `linux/module.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `linux/interrupt.h`, `linux/ktime.h`, `linux/of_address.h`, `linux/phy.h`, `linux/of_mdio.h`.
- Detected declarations: `struct tx_desc`, `struct rx_desc`, `struct hip04_priv`, `function tx_count`, `function hip04_config_port`, `function hip04_reset_dreq`, `function hip04_reset_ppe`, `function hip04_config_fifo`, `function hip04_mac_enable`, `function hip04_mac_disable`.
- 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.