drivers/net/ethernet/intel/e1000e/mac.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/e1000e/mac.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/e1000e/mac.c- Extension
.c- Size
- 52203 bytes
- Lines
- 1794
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.he1000.h
Detected Declarations
function e1000e_get_bus_info_pciefunction e1000_set_lan_id_multi_port_pciefunction e1000_set_lan_id_single_portfunction e1000_clear_vfta_genericfunction e1000_write_vfta_genericfunction e1000e_init_rx_addrsfunction e1000_check_alt_mac_addr_genericfunction e1000e_rar_get_count_genericfunction e1000e_rar_set_genericfunction e1000_hash_mc_addrfunction e1000e_update_mc_addr_list_genericfunction e1000e_clear_hw_cntrs_basefunction e1000e_check_for_copper_linkfunction e1000e_check_for_fiber_linkfunction e1000e_check_for_serdes_linkfunction e1000_set_default_fc_genericfunction e1000e_setup_link_genericfunction Registerfunction Registerfunction e1000_poll_fiber_serdes_link_genericfunction e1000e_setup_fiber_serdes_linkfunction e1000e_config_collision_dist_genericfunction e1000e_set_fc_watermarksfunction e1000e_force_mac_fcfunction e1000e_config_fc_after_link_upfunction Registerfunction Registerfunction e1000e_get_speed_and_duplex_copperfunction duplexfunction e1000e_get_hw_semaphorefunction e1000e_put_hw_semaphorefunction e1000e_get_auto_rd_donefunction e1000e_valid_led_defaultfunction e1000e_id_led_init_genericfunction e1000e_setup_led_genericfunction e1000e_cleanup_led_genericfunction e1000e_blink_led_genericfunction e1000e_led_on_genericfunction e1000e_led_off_genericfunction e1000e_set_pcie_no_snoopfunction e1000e_disable_pcie_masterfunction e1000e_reset_adaptivefunction e1000e_update_adaptive
Annotated Snippet
if (ret_val) {
e_dbg("NVM Read Error\n");
return ret_val;
}
alt_mac_addr[i] = (u8)(nvm_data & 0xFF);
alt_mac_addr[i + 1] = (u8)(nvm_data >> 8);
}
/* if multicast bit is set, the alternate address will not be used */
if (is_multicast_ether_addr(alt_mac_addr)) {
e_dbg("Ignoring Alternate Mac Address with MC bit set\n");
return 0;
}
/* We have a valid alternate MAC address, and we want to treat it the
* same as the normal permanent MAC address stored by the HW into the
* RAR. Do this by mapping this address into RAR0.
*/
hw->mac.ops.rar_set(hw, alt_mac_addr, 0);
return 0;
}
u32 e1000e_rar_get_count_generic(struct e1000_hw *hw)
{
return hw->mac.rar_entry_count;
}
/**
* e1000e_rar_set_generic - Set receive address register
* @hw: pointer to the HW structure
* @addr: pointer to the receive address
* @index: receive address array register
*
* Sets the receive address array register at index to the address passed
* in by addr.
**/
int e1000e_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index)
{
u32 rar_low, rar_high;
/* HW expects these in little endian so we reverse the byte order
* from network order (big endian) to little endian
*/
rar_low = ((u32)addr[0] | ((u32)addr[1] << 8) |
((u32)addr[2] << 16) | ((u32)addr[3] << 24));
rar_high = ((u32)addr[4] | ((u32)addr[5] << 8));
/* If MAC address zero, no need to set the AV bit */
if (rar_low || rar_high)
rar_high |= E1000_RAH_AV;
/* Some bridges will combine consecutive 32-bit writes into
* a single burst write, which will malfunction on some parts.
* The flushes avoid this.
*/
ew32(RAL(index), rar_low);
e1e_flush();
ew32(RAH(index), rar_high);
e1e_flush();
return 0;
}
/**
* e1000_hash_mc_addr - Generate a multicast hash value
* @hw: pointer to the HW structure
* @mc_addr: pointer to a multicast address
*
* Generates a multicast address hash value which is used to determine
* the multicast filter table array address and new table value.
**/
static u32 e1000_hash_mc_addr(struct e1000_hw *hw, u8 *mc_addr)
{
u32 hash_value, hash_mask;
u8 bit_shift = 0;
/* Register count multiplied by bits per register */
hash_mask = (hw->mac.mta_reg_count * 32) - 1;
/* For a mc_filter_type of 0, bit_shift is the number of left-shifts
* where 0xFF would still fall within the hash mask.
*/
while (hash_mask >> bit_shift != 0xFF)
bit_shift++;
/* The portion of the address that is used for the hash table
* is determined by the mc_filter_type setting.
Annotation
- Immediate include surface: `linux/bitfield.h`, `e1000.h`.
- Detected declarations: `function e1000e_get_bus_info_pcie`, `function e1000_set_lan_id_multi_port_pcie`, `function e1000_set_lan_id_single_port`, `function e1000_clear_vfta_generic`, `function e1000_write_vfta_generic`, `function e1000e_init_rx_addrs`, `function e1000_check_alt_mac_addr_generic`, `function e1000e_rar_get_count_generic`, `function e1000e_rar_set_generic`, `function e1000_hash_mc_addr`.
- Atlas domain: Driver Families / drivers/net.
- Implementation status: source implementation candidate.
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.