drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/hisilicon/hix5hd2_gmac.c- Extension
.c- Size
- 33918 bytes
- Lines
- 1323
- 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/interrupt.hlinux/etherdevice.hlinux/platform_device.hlinux/property.hlinux/of.hlinux/of_net.hlinux/of_mdio.hlinux/reset.hlinux/clk.hlinux/circ_buf.h
Detected Declarations
struct hix5hd2_descstruct hix5hd2_desc_swstruct hix5hd2_sg_desc_ringstruct frags_infostruct sg_descstruct hix5hd2_privenum phy_reset_delaysfunction hix5hd2_mac_interface_resetfunction hix5hd2_config_portfunction hix5hd2_set_desc_depthfunction hix5hd2_set_rx_fqfunction hix5hd2_set_rx_bqfunction hix5hd2_set_tx_bqfunction hix5hd2_set_tx_rqfunction hix5hd2_set_desc_addrfunction hix5hd2_hw_initfunction hix5hd2_irq_enablefunction hix5hd2_irq_disablefunction hix5hd2_port_enablefunction hix5hd2_port_disablefunction hix5hd2_hw_set_mac_addrfunction hix5hd2_net_set_mac_addressfunction hix5hd2_adjust_linkfunction hix5hd2_rx_refillfunction hix5hd2_rxfunction hix5hd2_clean_sg_descfunction hix5hd2_xmit_reclaimfunction hix5hd2_pollfunction hix5hd2_interruptfunction hix5hd2_get_desc_cmdfunction hix5hd2_fill_sg_descfunction hix5hd2_net_xmitfunction hix5hd2_free_dma_desc_ringsfunction hix5hd2_net_openfunction hix5hd2_net_closefunction hix5hd2_tx_timeout_taskfunction hix5hd2_net_timeoutfunction hix5hd2_mdio_wait_readyfunction hix5hd2_mdio_readfunction hix5hd2_mdio_writefunction hix5hd2_destroy_hw_desc_queuefunction hix5hd2_init_hw_desc_queuefunction hix5hd2_init_sg_desc_queuefunction hix5hd2_destroy_sg_desc_queuefunction hix5hd2_mac_core_resetfunction hix5hd2_sleep_usfunction hix5hd2_phy_resetfunction hix5hd2_dev_probe
Annotated Snippet
static const struct net_device_ops hix5hd2_netdev_ops = {
.ndo_open = hix5hd2_net_open,
.ndo_stop = hix5hd2_net_close,
.ndo_start_xmit = hix5hd2_net_xmit,
.ndo_tx_timeout = hix5hd2_net_timeout,
.ndo_set_mac_address = hix5hd2_net_set_mac_address,
};
static const struct ethtool_ops hix5hd2_ethtools_ops = {
.get_link = ethtool_op_get_link,
.get_link_ksettings = phy_ethtool_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
};
static int hix5hd2_mdio_wait_ready(struct mii_bus *bus)
{
struct hix5hd2_priv *priv = bus->priv;
void __iomem *base = priv->base;
int i, timeout = 10000;
for (i = 0; readl_relaxed(base + MDIO_SINGLE_CMD) & MDIO_START; i++) {
if (i == timeout)
return -ETIMEDOUT;
usleep_range(10, 20);
}
return 0;
}
static int hix5hd2_mdio_read(struct mii_bus *bus, int phy, int reg)
{
struct hix5hd2_priv *priv = bus->priv;
void __iomem *base = priv->base;
int val, ret;
ret = hix5hd2_mdio_wait_ready(bus);
if (ret < 0)
goto out;
writel_relaxed(MDIO_READ | phy << 8 | reg, base + MDIO_SINGLE_CMD);
ret = hix5hd2_mdio_wait_ready(bus);
if (ret < 0)
goto out;
val = readl_relaxed(base + MDIO_RDATA_STATUS);
if (val & MDIO_R_VALID) {
dev_err(bus->parent, "SMI bus read not valid\n");
ret = -ENODEV;
goto out;
}
val = readl_relaxed(priv->base + MDIO_SINGLE_DATA);
ret = (val >> 16) & 0xFFFF;
out:
return ret;
}
static int hix5hd2_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
{
struct hix5hd2_priv *priv = bus->priv;
void __iomem *base = priv->base;
int ret;
ret = hix5hd2_mdio_wait_ready(bus);
if (ret < 0)
goto out;
writel_relaxed(val, base + MDIO_SINGLE_DATA);
writel_relaxed(MDIO_WRITE | phy << 8 | reg, base + MDIO_SINGLE_CMD);
ret = hix5hd2_mdio_wait_ready(bus);
out:
return ret;
}
static void hix5hd2_destroy_hw_desc_queue(struct hix5hd2_priv *priv)
{
int i;
for (i = 0; i < QUEUE_NUMS; i++) {
if (priv->pool[i].desc) {
dma_free_coherent(priv->dev, priv->pool[i].size,
priv->pool[i].desc,
priv->pool[i].phys_addr);
priv->pool[i].desc = NULL;
}
}
}
static int hix5hd2_init_hw_desc_queue(struct hix5hd2_priv *priv)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/interrupt.h`, `linux/etherdevice.h`, `linux/platform_device.h`, `linux/property.h`, `linux/of.h`, `linux/of_net.h`, `linux/of_mdio.h`.
- Detected declarations: `struct hix5hd2_desc`, `struct hix5hd2_desc_sw`, `struct hix5hd2_sg_desc_ring`, `struct frags_info`, `struct sg_desc`, `struct hix5hd2_priv`, `enum phy_reset_delays`, `function hix5hd2_mac_interface_reset`, `function hix5hd2_config_port`, `function hix5hd2_set_desc_depth`.
- 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.