drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c- Extension
.c- Size
- 29637 bytes
- Lines
- 1046
- 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/iopoll.hstmmac.hstmmac_fpe.hstmmac_pcs.hstmmac_vlan.hdwmac4.hdwmac5.h
Detected Declarations
function dwmac4_pcs_initfunction dwmac4_core_initfunction dwmac4_irq_modifyfunction dwmac4_update_capsfunction dwmac4_rx_queue_enablefunction dwmac4_rx_queue_priorityfunction dwmac4_tx_queue_priorityfunction dwmac4_rx_queue_routingfunction dwmac4_prog_mtl_rx_algorithmsfunction dwmac4_prog_mtl_tx_algorithmsfunction dwmac4_set_mtl_tx_queue_weightfunction dwmac4_map_mtl_dmafunction dwmac4_config_cbsfunction dwmac4_dump_regsfunction dwmac4_rx_ipc_enablefunction dwmac4_pmtfunction dwmac4_set_umac_addrfunction dwmac4_get_umac_addrfunction dwmac4_set_lpi_modefunction dwmac4_set_eee_plsfunction dwmac4_set_eee_timerfunction dwmac4_set_filterfunction netdev_for_each_mc_addrfunction netdev_for_each_uc_addrfunction dwmac4_flow_ctrlfunction dwmac4_ctrl_anefunction dwmac4_irq_mtl_statusfunction dwmac4_irq_statusfunction dwmac4_debugfunction dwmac4_set_mac_loopbackfunction dwmac4_sarc_configurefunction dwmac4_set_arp_offloadfunction dwmac4_config_l3_filterfunction dwmac4_config_l4_filterfunction dwmac4_setup
Annotated Snippet
if (mode == STMMAC_LPI_TIMER) {
/* Return ERANGE if the timer is larger than the
* register field.
*/
if (et > STMMAC_ET_MAX)
return -ERANGE;
/* Set the hardware LPI entry timer */
writel(et, ioaddr + GMAC4_LPI_ENTRY_TIMER);
/* Interpret a zero LPI entry timer to mean
* immediate entry into LPI mode.
*/
if (et)
value |= LPI_CTRL_STATUS_LPIATE;
}
if (en_tx_lpi_clockgating)
value |= LPI_CTRL_STATUS_LPITCSE;
}
mask = LPI_CTRL_STATUS_LPIATE | LPI_CTRL_STATUS_LPIEN |
LPI_CTRL_STATUS_LPITXA | LPI_CTRL_STATUS_LPITCSE;
value |= readl(ioaddr + GMAC4_LPI_CTRL_STATUS) & ~mask;
writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
return 0;
}
static void dwmac4_set_eee_pls(struct mac_device_info *hw, int link)
{
void __iomem *ioaddr = hw->pcsr;
u32 value;
value = readl(ioaddr + GMAC4_LPI_CTRL_STATUS);
if (link)
value |= LPI_CTRL_STATUS_PLS;
else
value &= ~LPI_CTRL_STATUS_PLS;
writel(value, ioaddr + GMAC4_LPI_CTRL_STATUS);
}
static void dwmac4_set_eee_timer(struct mac_device_info *hw, int ls, int tw)
{
void __iomem *ioaddr = hw->pcsr;
int value = ((tw & 0xffff)) | ((ls & 0x3ff) << 16);
/* Program the timers in the LPI timer control register:
* LS: minimum time (ms) for which the link
* status from PHY should be ok before transmitting
* the LPI pattern.
* TW: minimum time (us) for which the core waits
* after it has stopped transmitting the LPI pattern.
*/
writel(value, ioaddr + GMAC4_LPI_TIMER_CTRL);
}
static void dwmac4_set_filter(struct mac_device_info *hw,
struct net_device *dev)
{
void __iomem *ioaddr = (void __iomem *)dev->base_addr;
int numhashregs = (hw->multicast_filter_bins >> 5);
int mcbitslog2 = hw->mcast_bits_log2;
unsigned int value;
u32 mc_filter[8];
int i;
memset(mc_filter, 0, sizeof(mc_filter));
value = readl(ioaddr + GMAC_PACKET_FILTER);
value &= ~GMAC_PACKET_FILTER_HMC;
value &= ~GMAC_PACKET_FILTER_HPF;
value &= ~GMAC_PACKET_FILTER_PCF;
value &= ~GMAC_PACKET_FILTER_PM;
value &= ~GMAC_PACKET_FILTER_PR;
value &= ~GMAC_PACKET_FILTER_RA;
if (dev->flags & IFF_PROMISC) {
/* VLAN Tag Filter Fail Packets Queuing */
if (hw->vlan_fail_q_en) {
value = readl(ioaddr + GMAC_RXQ_CTRL4);
value &= ~GMAC_RXQCTRL_VFFQ_MASK;
value |= GMAC_RXQCTRL_VFFQE |
(hw->vlan_fail_q << GMAC_RXQCTRL_VFFQ_SHIFT);
writel(value, ioaddr + GMAC_RXQ_CTRL4);
value = GMAC_PACKET_FILTER_PR | GMAC_PACKET_FILTER_RA;
} else {
value = GMAC_PACKET_FILTER_PR | GMAC_PACKET_FILTER_PCF;
Annotation
- Immediate include surface: `linux/crc32.h`, `linux/slab.h`, `linux/ethtool.h`, `linux/io.h`, `linux/iopoll.h`, `stmmac.h`, `stmmac_fpe.h`, `stmmac_pcs.h`.
- Detected declarations: `function dwmac4_pcs_init`, `function dwmac4_core_init`, `function dwmac4_irq_modify`, `function dwmac4_update_caps`, `function dwmac4_rx_queue_enable`, `function dwmac4_rx_queue_priority`, `function dwmac4_tx_queue_priority`, `function dwmac4_rx_queue_routing`, `function dwmac4_prog_mtl_rx_algorithms`, `function dwmac4_prog_mtl_tx_algorithms`.
- 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.