drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/synopsys/dwc-xlgmac-hw.c- Extension
.c- Size
- 88038 bytes
- Lines
- 3148
- 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/phy.hlinux/mdio.hlinux/clk.hlinux/bitrev.hlinux/crc32.hlinux/crc32poly.hlinux/dcbnl.hdwc-xlgmac.hdwc-xlgmac-reg.h
Detected Declarations
function Licensefunction xlgmac_disable_rx_csumfunction xlgmac_enable_rx_csumfunction xlgmac_set_mac_addressfunction xlgmac_set_mac_regfunction xlgmac_enable_rx_vlan_strippingfunction xlgmac_disable_rx_vlan_strippingfunction xlgmac_enable_rx_vlan_filteringfunction xlgmac_disable_rx_vlan_filteringfunction xlgmac_vid_crc32_lefunction xlgmac_update_vlan_hash_tablefunction xlgmac_set_promiscuous_modefunction xlgmac_set_all_multicast_modefunction xlgmac_set_mac_addn_addrsfunction netdev_for_each_uc_addrfunction netdev_for_each_mc_addrfunction xlgmac_set_mac_hash_tablefunction netdev_for_each_mc_addrfunction xlgmac_add_mac_addressesfunction xlgmac_config_mac_addressfunction xlgmac_config_jumbo_enablefunction xlgmac_config_checksum_offloadfunction xlgmac_config_vlan_supportfunction xlgmac_config_rx_modefunction xlgmac_prepare_tx_stopfunction xlgmac_enable_txfunction xlgmac_disable_txfunction xlgmac_prepare_rx_stopfunction xlgmac_enable_rxfunction xlgmac_disable_rxfunction xlgmac_tx_start_xmitfunction xlgmac_dev_xmitfunction xlgmac_get_rx_tstampfunction xlgmac_tx_desc_resetfunction xlgmac_tx_desc_initfunction xlgmac_rx_desc_resetfunction xlgmac_rx_desc_initfunction xlgmac_is_context_descfunction xlgmac_is_last_descfunction xlgmac_disable_tx_flow_controlfunction xlgmac_enable_tx_flow_controlfunction xlgmac_disable_rx_flow_controlfunction xlgmac_enable_rx_flow_controlfunction xlgmac_config_tx_flow_controlfunction xlgmac_config_rx_flow_controlfunction xlgmac_config_rx_coalescefunction xlgmac_config_flow_controlfunction xlgmac_config_rx_fep_enable
Annotated Snippet
netdev_for_each_uc_addr(ha, netdev) {
xlgmac_set_mac_reg(pdata, ha, &mac_reg);
addn_macs--;
}
if (netdev_mc_count(netdev) > addn_macs) {
xlgmac_set_all_multicast_mode(pdata, 1);
} else {
netdev_for_each_mc_addr(ha, netdev) {
xlgmac_set_mac_reg(pdata, ha, &mac_reg);
addn_macs--;
}
}
}
/* Clear remaining additional MAC address entries */
while (addn_macs--)
xlgmac_set_mac_reg(pdata, NULL, &mac_reg);
}
static void xlgmac_set_mac_hash_table(struct xlgmac_pdata *pdata)
{
unsigned int hash_table_shift, hash_table_count;
u32 hash_table[XLGMAC_MAC_HASH_TABLE_SIZE];
struct net_device *netdev = pdata->netdev;
struct netdev_hw_addr *ha;
unsigned int hash_reg;
unsigned int i;
u32 crc;
hash_table_shift = 26 - (pdata->hw_feat.hash_table_size >> 7);
hash_table_count = pdata->hw_feat.hash_table_size / 32;
memset(hash_table, 0, sizeof(hash_table));
/* Build the MAC Hash Table register values */
netdev_for_each_uc_addr(ha, netdev) {
crc = bitrev32(~crc32_le(~0, ha->addr, ETH_ALEN));
crc >>= hash_table_shift;
hash_table[crc >> 5] |= (1 << (crc & 0x1f));
}
netdev_for_each_mc_addr(ha, netdev) {
crc = bitrev32(~crc32_le(~0, ha->addr, ETH_ALEN));
crc >>= hash_table_shift;
hash_table[crc >> 5] |= (1 << (crc & 0x1f));
}
/* Set the MAC Hash Table registers */
hash_reg = MAC_HTR0;
for (i = 0; i < hash_table_count; i++) {
writel(hash_table[i], pdata->mac_regs + hash_reg);
hash_reg += MAC_HTR_INC;
}
}
static int xlgmac_add_mac_addresses(struct xlgmac_pdata *pdata)
{
if (pdata->hw_feat.hash_table_size)
xlgmac_set_mac_hash_table(pdata);
else
xlgmac_set_mac_addn_addrs(pdata);
return 0;
}
static void xlgmac_config_mac_address(struct xlgmac_pdata *pdata)
{
u32 regval;
xlgmac_set_mac_address(pdata, pdata->netdev->dev_addr);
/* Filtering is done using perfect filtering and hash filtering */
if (pdata->hw_feat.hash_table_size) {
regval = readl(pdata->mac_regs + MAC_PFR);
regval = XLGMAC_SET_REG_BITS(regval, MAC_PFR_HPF_POS,
MAC_PFR_HPF_LEN, 1);
regval = XLGMAC_SET_REG_BITS(regval, MAC_PFR_HUC_POS,
MAC_PFR_HUC_LEN, 1);
regval = XLGMAC_SET_REG_BITS(regval, MAC_PFR_HMC_POS,
MAC_PFR_HMC_LEN, 1);
writel(regval, pdata->mac_regs + MAC_PFR);
}
}
static void xlgmac_config_jumbo_enable(struct xlgmac_pdata *pdata)
{
unsigned int val;
u32 regval;
val = (pdata->netdev->mtu > XLGMAC_STD_PACKET_MTU) ? 1 : 0;
Annotation
- Immediate include surface: `linux/phy.h`, `linux/mdio.h`, `linux/clk.h`, `linux/bitrev.h`, `linux/crc32.h`, `linux/crc32poly.h`, `linux/dcbnl.h`, `dwc-xlgmac.h`.
- Detected declarations: `function License`, `function xlgmac_disable_rx_csum`, `function xlgmac_enable_rx_csum`, `function xlgmac_set_mac_address`, `function xlgmac_set_mac_reg`, `function xlgmac_enable_rx_vlan_stripping`, `function xlgmac_disable_rx_vlan_stripping`, `function xlgmac_enable_rx_vlan_filtering`, `function xlgmac_disable_rx_vlan_filtering`, `function xlgmac_vid_crc32_le`.
- 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.