drivers/net/ethernet/stmicro/stmmac/hwif.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/hwif.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/hwif.c- Extension
.c- Size
- 9964 bytes
- Lines
- 404
- 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.
- 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
common.hstmmac.hstmmac_fpe.hstmmac_ptp.hstmmac_est.hstmmac_vlan.hdwmac4_descs.hdwxgmac2.h
Detected Declarations
struct stmmac_versionfunction stmmac_get_versionfunction stmmac_dwmac_mode_quirkfunction stmmac_dwmac1_quirksfunction stmmac_dwmac4_quirksfunction stmmac_resetfunction stmmac_hwif_findfunction stmmac_hwif_init
Annotated Snippet
struct stmmac_version {
u8 snpsver;
u8 dev_id;
};
static void stmmac_get_version(struct stmmac_priv *priv,
struct stmmac_version *ver)
{
enum dwmac_core_type core_type = priv->plat->core_type;
unsigned int version_offset;
u32 version;
ver->snpsver = 0;
ver->dev_id = 0;
if (core_type == DWMAC_CORE_MAC100)
return;
if (core_type == DWMAC_CORE_GMAC)
version_offset = GMAC_VERSION;
else
version_offset = GMAC4_VERSION;
version = readl(priv->ioaddr + version_offset);
if (version == 0) {
dev_info(priv->device, "Version ID not available\n");
return;
}
dev_info(priv->device, "User ID: 0x%x, Synopsys ID: 0x%x\n",
FIELD_GET(DWMAC_USERVER, version),
FIELD_GET(DWMAC_SNPSVER, version));
ver->snpsver = FIELD_GET(DWMAC_SNPSVER, version);
if (core_type == DWMAC_CORE_XGMAC)
ver->dev_id = FIELD_GET(DWMAC_USERVER, version);
}
static void stmmac_dwmac_mode_quirk(struct stmmac_priv *priv)
{
struct mac_device_info *mac = priv->hw;
if (priv->chain_mode) {
dev_info(priv->device, "Chain mode enabled\n");
priv->descriptor_mode = STMMAC_CHAIN_MODE;
mac->mode = &chain_mode_ops;
} else {
dev_info(priv->device, "Ring mode enabled\n");
priv->descriptor_mode = STMMAC_RING_MODE;
mac->mode = &ring_mode_ops;
}
}
static int stmmac_dwmac1_quirks(struct stmmac_priv *priv)
{
struct mac_device_info *mac = priv->hw;
if (priv->plat->enh_desc) {
dev_info(priv->device, "Enhanced/Alternate descriptors\n");
/* GMAC older than 3.50 has no extended descriptors */
if (priv->synopsys_id >= DWMAC_CORE_3_50) {
dev_info(priv->device, "Enabled extended descriptors\n");
priv->extend_desc = true;
} else {
dev_warn(priv->device, "Extended descriptors not supported\n");
}
mac->desc = &enh_desc_ops;
} else {
dev_info(priv->device, "Normal descriptors\n");
mac->desc = &ndesc_ops;
}
stmmac_dwmac_mode_quirk(priv);
return 0;
}
static int stmmac_dwmac4_quirks(struct stmmac_priv *priv)
{
stmmac_dwmac_mode_quirk(priv);
return 0;
}
int stmmac_reset(struct stmmac_priv *priv)
{
struct plat_stmmacenet_data *plat = priv->plat;
void __iomem *ioaddr = priv->ioaddr;
if (plat && plat->fix_soc_reset)
Annotation
- Immediate include surface: `common.h`, `stmmac.h`, `stmmac_fpe.h`, `stmmac_ptp.h`, `stmmac_est.h`, `stmmac_vlan.h`, `dwmac4_descs.h`, `dwxgmac2.h`.
- Detected declarations: `struct stmmac_version`, `function stmmac_get_version`, `function stmmac_dwmac_mode_quirk`, `function stmmac_dwmac1_quirks`, `function stmmac_dwmac4_quirks`, `function stmmac_reset`, `function stmmac_hwif_find`, `function stmmac_hwif_init`.
- 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.