drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c- Extension
.c- Size
- 16518 bytes
- Lines
- 610
- 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
linux/crc32.hlinux/slab.hlinux/ethtool.hlinux/io.hlinux/string_choices.hstmmac.hstmmac_pcs.hstmmac_ptp.hdwmac1000.h
Detected Declarations
function dwmac1000_pcs_initfunction dwmac1000_core_initfunction dwmac1000_irq_modifyfunction dwmac1000_rx_ipc_enablefunction dwmac1000_dump_regsfunction dwmac1000_set_umac_addrfunction dwmac1000_get_umac_addrfunction dwmac1000_set_mchashfunction dwmac1000_set_filterfunction netdev_for_each_mc_addrfunction netdev_for_each_uc_addrfunction dwmac1000_flow_ctrlfunction dwmac1000_pmtfunction dwmac1000_irq_statusfunction dwmac1000_set_lpi_modefunction dwmac1000_set_eee_plsfunction dwmac1000_set_eee_timerfunction dwmac1000_ctrl_anefunction dwmac1000_debugfunction dwmac1000_set_mac_loopbackfunction dwmac1000_setupfunction dwmac1000_get_ptptimefunction dwmac1000_timestamp_interruptfunction dwmac1000_timestamp_interrupt_cfgfunction dwmac1000_ptp_enable
Annotated Snippet
netdev_for_each_mc_addr(ha, dev) {
/* The upper n bits of the calculated CRC are used to
* index the contents of the hash table. The number of
* bits used depends on the hardware configuration
* selected at core configuration time.
*/
int bit_nr = bitrev32(~crc32_le(~0, ha->addr,
ETH_ALEN)) >>
(32 - mcbitslog2);
/* The most significant bit determines the register to
* use (H/L) while the other 5 bits determine the bit
* within the register.
*/
mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
}
}
value |= GMAC_FRAME_FILTER_HPF;
dwmac1000_set_mchash(ioaddr, mc_filter, mcbitslog2);
/* Handle multiple unicast addresses (perfect filtering) */
if (netdev_uc_count(dev) > perfect_addr_number)
/* Switch to promiscuous mode if more than unicast
* addresses are requested than supported by hardware.
*/
value |= GMAC_FRAME_FILTER_PR;
else {
int reg = 1;
struct netdev_hw_addr *ha;
netdev_for_each_uc_addr(ha, dev) {
stmmac_set_mac_addr(ioaddr, ha->addr,
GMAC_ADDR_HIGH(reg),
GMAC_ADDR_LOW(reg));
reg++;
}
while (reg < perfect_addr_number) {
writel(0, ioaddr + GMAC_ADDR_HIGH(reg));
writel(0, ioaddr + GMAC_ADDR_LOW(reg));
reg++;
}
}
#ifdef FRAME_FILTER_DEBUG
/* Enable Receive all mode (to debug filtering_fail errors) */
value |= GMAC_FRAME_FILTER_RA;
#endif
writel(value, ioaddr + GMAC_FRAME_FILTER);
}
static void dwmac1000_flow_ctrl(struct mac_device_info *hw, unsigned int duplex,
unsigned int fc, unsigned int pause_time,
u8 tx_cnt)
{
void __iomem *ioaddr = hw->pcsr;
/* Set flow such that DZPQ in Mac Register 6 is 0,
* and unicast pause detect is enabled.
*/
unsigned int flow = GMAC_FLOW_CTRL_UP;
pr_debug("GMAC Flow-Control:\n");
if (fc & FLOW_RX) {
pr_debug("\tReceive Flow-Control ON\n");
flow |= GMAC_FLOW_CTRL_RFE;
}
if (fc & FLOW_TX) {
pr_debug("\tTransmit Flow-Control ON\n");
flow |= GMAC_FLOW_CTRL_TFE;
}
if (duplex) {
pr_debug("\tduplex mode: PAUSE %d\n", pause_time);
flow |= FIELD_PREP(GMAC_FLOW_CTRL_PT_MASK, pause_time);
}
writel(flow, ioaddr + GMAC_FLOW_CTRL);
}
static void dwmac1000_pmt(struct mac_device_info *hw, unsigned long mode)
{
void __iomem *ioaddr = hw->pcsr;
unsigned int pmt = 0;
if (mode & WAKE_MAGIC) {
pr_debug("GMAC: WOL Magic frame\n");
pmt |= power_down | magic_pkt_en;
}
if (mode & WAKE_UCAST) {
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/slab.h`, `linux/ethtool.h`, `linux/io.h`, `linux/string_choices.h`, `stmmac.h`, `stmmac_pcs.h`, `stmmac_ptp.h`.
- Detected declarations: `function dwmac1000_pcs_init`, `function dwmac1000_core_init`, `function dwmac1000_irq_modify`, `function dwmac1000_rx_ipc_enable`, `function dwmac1000_dump_regs`, `function dwmac1000_set_umac_addr`, `function dwmac1000_get_umac_addr`, `function dwmac1000_set_mchash`, `function dwmac1000_set_filter`, `function netdev_for_each_mc_addr`.
- 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.