drivers/net/ethernet/intel/e1000e/phy.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/e1000e/phy.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/e1000e/phy.c- Extension
.c- Size
- 89762 bytes
- Lines
- 3285
- 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
e1000.hlinux/ethtool.h
Detected Declarations
function ARRAY_SIZEfunction e1000e_get_phy_idfunction e1000e_phy_reset_dspfunction e1000e_disable_phy_retryfunction e1000e_enable_phy_retryfunction e1000e_read_phy_reg_mdicfunction e1000e_write_phy_reg_mdicfunction e1000e_read_phy_reg_m88function e1000e_write_phy_reg_m88function appropriatelyfunction __e1000e_read_phy_reg_igpfunction e1000e_read_phy_reg_igpfunction e1000e_read_phy_reg_igp_lockedfunction __e1000e_write_phy_reg_igpfunction e1000e_write_phy_reg_igpfunction e1000e_write_phy_reg_igp_lockedfunction __e1000_read_kmrn_regfunction e1000e_read_kmrn_regfunction e1000e_read_kmrn_reg_lockedfunction __e1000_write_kmrn_regfunction e1000e_write_kmrn_regfunction e1000e_write_kmrn_reg_lockedfunction e1000_set_master_slave_modefunction e1000_copper_link_setup_82577function e1000e_copper_link_setup_m88function e1000e_copper_link_setup_igpfunction e1000_phy_setup_autonegfunction Registerfunction e1000_copper_link_autonegfunction timefunction e1000e_setup_copper_linkfunction e1000e_phy_force_speed_duplex_igpfunction e1000e_phy_force_speed_duplex_m88function e1000_phy_force_speed_duplex_ifefunction e1000e_phy_force_speed_duplex_setupfunction upfunction e1000e_check_downshiftfunction e1000_check_polarity_m88function speedfunction e1000_check_polarity_ifefunction e1000_wait_autonegfunction e1000e_phy_has_link_genericfunction e1000e_get_cable_length_m88function controlfunction e1000e_get_phy_info_m88function e1000e_get_phy_info_igpfunction e1000_get_phy_info_ifefunction e1000e_phy_sw_reset
Annotated Snippet
if (!(mdic & E1000_MDIC_READY)) {
e_dbg("MDI Read PHY Reg Address %d did not complete\n",
offset);
success = false;
}
if (mdic & E1000_MDIC_ERROR) {
e_dbg("MDI Read PHY Reg Address %d Error\n", offset);
success = false;
}
if (FIELD_GET(E1000_MDIC_REG_MASK, mdic) != offset) {
e_dbg("MDI Read offset error - requested %d, returned %d\n",
offset, FIELD_GET(E1000_MDIC_REG_MASK, mdic));
success = false;
}
/* Allow some time after each MDIC transaction to avoid
* reading duplicate data in the next MDIC transaction.
*/
if (hw->mac.type == e1000_pch2lan)
udelay(100);
if (success) {
*data = (u16)mdic;
return 0;
}
if (retry_counter != retry_max) {
e_dbg("Perform retry on PHY transaction...\n");
mdelay(10);
}
}
return -E1000_ERR_PHY;
}
/**
* e1000e_write_phy_reg_mdic - Write MDI control register
* @hw: pointer to the HW structure
* @offset: register offset to write to
* @data: data to write to register at offset
*
* Writes data to MDI control register in the PHY at offset.
**/
s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data)
{
u32 i, mdic = 0, retry_counter, retry_max;
struct e1000_phy_info *phy = &hw->phy;
bool success;
if (offset > MAX_PHY_REG_ADDRESS) {
e_dbg("PHY Address %d is out of range\n", offset);
return -E1000_ERR_PARAM;
}
retry_max = phy->retry_enabled ? phy->retry_count : 0;
/* Set up Op-code, Phy Address, and register offset in the MDI
* Control register. The MAC will take care of interfacing with the
* PHY to retrieve the desired data.
*/
for (retry_counter = 0; retry_counter <= retry_max; retry_counter++) {
success = true;
mdic = (((u32)data) |
(offset << E1000_MDIC_REG_SHIFT) |
(phy->addr << E1000_MDIC_PHY_SHIFT) |
(E1000_MDIC_OP_WRITE));
ew32(MDIC, mdic);
/* Poll the ready bit to see if the MDI read completed
* Increasing the time out as testing showed failures with
* the lower time out
*/
for (i = 0; i < (E1000_GEN_POLL_TIMEOUT * 3); i++) {
udelay(50);
mdic = er32(MDIC);
if (mdic & E1000_MDIC_READY)
break;
}
if (!(mdic & E1000_MDIC_READY)) {
e_dbg("MDI Write PHY Reg Address %d did not complete\n",
offset);
success = false;
}
if (mdic & E1000_MDIC_ERROR) {
e_dbg("MDI Write PHY Reg Address %d Error\n", offset);
success = false;
}
if (FIELD_GET(E1000_MDIC_REG_MASK, mdic) != offset) {
Annotation
- Immediate include surface: `e1000.h`, `linux/ethtool.h`.
- Detected declarations: `function ARRAY_SIZE`, `function e1000e_get_phy_id`, `function e1000e_phy_reset_dsp`, `function e1000e_disable_phy_retry`, `function e1000e_enable_phy_retry`, `function e1000e_read_phy_reg_mdic`, `function e1000e_write_phy_reg_mdic`, `function e1000e_read_phy_reg_m88`, `function e1000e_write_phy_reg_m88`, `function appropriately`.
- 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.