drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/apm/xgene/xgene_enet_hw.c- Extension
.c- Size
- 25836 bytes
- Lines
- 1024
- Domain
- Driver Families
- Bucket
- drivers/net
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
xgene_enet_main.hxgene_enet_hw.h
Detected Declarations
function Copyrightfunction xgene_enet_ring_set_typefunction xgene_enet_ring_set_recombbuffunction xgene_enet_ring_wr32function xgene_enet_ring_rd32function xgene_enet_write_ring_statefunction xgene_enet_clr_ring_statefunction xgene_enet_set_ring_statefunction xgene_enet_set_ring_idfunction xgene_enet_clr_desc_ring_idfunction xgene_enet_clear_ringfunction xgene_enet_wr_cmdfunction xgene_enet_ring_lenfunction xgene_enet_parse_errorfunction xgene_enet_wr_csrfunction xgene_enet_wr_ring_iffunction xgene_enet_wr_diag_csrfunction xgene_enet_wr_mcx_csrfunction xgene_enet_wr_macfunction xgene_enet_rd_csrfunction xgene_enet_rd_diag_csrfunction xgene_enet_rd_mcx_csrfunction xgene_enet_rd_macfunction xgene_enet_rd_statfunction xgene_gmac_set_mac_addrfunction xgene_enet_ecc_initfunction xgene_gmac_resetfunction xgene_enet_configure_clockfunction xgene_gmac_set_speedfunction xgene_enet_set_frame_sizefunction xgene_gmac_enable_tx_pausefunction xgene_gmac_flowctl_txfunction xgene_gmac_flowctl_rxfunction xgene_gmac_initfunction xgene_gmac_get_drop_cntfunction xgene_enet_config_ring_if_assocfunction xgene_enet_cle_bypassfunction xgene_gmac_rx_enablefunction xgene_gmac_tx_enablefunction xgene_gmac_rx_disablefunction xgene_gmac_tx_disablefunction xgene_ring_mgr_initfunction xgene_enet_resetfunction xgene_enet_clearfunction xgene_gport_shutdownfunction xgene_enet_flowctrl_cfgfunction xgene_enet_adjust_linkfunction xgene_enet_phy_connect
Annotated Snippet
phy_interface_mode_is_rgmii(pdata->phy_mode)) {
struct mii_bus *bus = ndev->phydev->mdio.bus;
return xgene_mdio_wr_mac(bus->priv, wr_addr, wr_data);
}
addr = pdata->mcx_mac_addr + MAC_ADDR_REG_OFFSET;
wr = pdata->mcx_mac_addr + MAC_WRITE_REG_OFFSET;
cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
spin_lock(&pdata->mac_lock);
iowrite32(wr_addr, addr);
iowrite32(wr_data, wr);
iowrite32(XGENE_ENET_WR_CMD, cmd);
while (!(done = ioread32(cmd_done)) && wait--)
udelay(1);
if (!done)
netdev_err(ndev, "mac write failed, addr: %04x data: %08x\n",
wr_addr, wr_data);
iowrite32(0, cmd);
spin_unlock(&pdata->mac_lock);
}
static void xgene_enet_rd_csr(struct xgene_enet_pdata *pdata,
u32 offset, u32 *val)
{
void __iomem *addr = pdata->eth_csr_addr + offset;
*val = ioread32(addr);
}
static void xgene_enet_rd_diag_csr(struct xgene_enet_pdata *pdata,
u32 offset, u32 *val)
{
void __iomem *addr = pdata->eth_diag_csr_addr + offset;
*val = ioread32(addr);
}
static void xgene_enet_rd_mcx_csr(struct xgene_enet_pdata *pdata,
u32 offset, u32 *val)
{
void __iomem *addr = pdata->mcx_mac_csr_addr + offset;
*val = ioread32(addr);
}
u32 xgene_enet_rd_mac(struct xgene_enet_pdata *pdata, u32 rd_addr)
{
void __iomem *addr, *rd, *cmd, *cmd_done;
struct net_device *ndev = pdata->ndev;
u32 done, rd_data;
u8 wait = 10;
if (pdata->mdio_driver && ndev->phydev &&
phy_interface_mode_is_rgmii(pdata->phy_mode)) {
struct mii_bus *bus = ndev->phydev->mdio.bus;
return xgene_mdio_rd_mac(bus->priv, rd_addr);
}
addr = pdata->mcx_mac_addr + MAC_ADDR_REG_OFFSET;
rd = pdata->mcx_mac_addr + MAC_READ_REG_OFFSET;
cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
spin_lock(&pdata->mac_lock);
iowrite32(rd_addr, addr);
iowrite32(XGENE_ENET_RD_CMD, cmd);
while (!(done = ioread32(cmd_done)) && wait--)
udelay(1);
if (!done)
netdev_err(ndev, "mac read failed, addr: %04x\n", rd_addr);
rd_data = ioread32(rd);
iowrite32(0, cmd);
spin_unlock(&pdata->mac_lock);
return rd_data;
}
u32 xgene_enet_rd_stat(struct xgene_enet_pdata *pdata, u32 rd_addr)
{
void __iomem *addr, *rd, *cmd, *cmd_done;
Annotation
- Immediate include surface: `xgene_enet_main.h`, `xgene_enet_hw.h`.
- Detected declarations: `function Copyright`, `function xgene_enet_ring_set_type`, `function xgene_enet_ring_set_recombbuf`, `function xgene_enet_ring_wr32`, `function xgene_enet_ring_rd32`, `function xgene_enet_write_ring_state`, `function xgene_enet_clr_ring_state`, `function xgene_enet_set_ring_state`, `function xgene_enet_set_ring_id`, `function xgene_enet_clr_desc_ring_id`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.