drivers/net/ethernet/intel/ice/ice_ptp_hw.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_ptp_hw.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_ptp_hw.c- Extension
.c- Size
- 173820 bytes
- Lines
- 6271
- 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/delay.hlinux/iopoll.hice_common.hice_ptp_hw.hice_ptp_consts.h
Detected Declarations
function ice_get_ptp_src_clock_indexfunction ice_ptp_read_src_incvalfunction ice_ptp_tmr_cmd_to_src_regfunction ice_ptp_tmr_cmd_to_port_regfunction ice_ptp_src_cmdfunction ice_ptp_exec_tmr_cmdfunction ice_ptp_cfg_sync_delayfunction ice_ptp_init_phc_e825cfunction ice_ptp_get_dest_dev_e825function ice_write_phy_eth56gfunction ice_read_phy_eth56gfunction ice_get_serdes_ref_sel_e825cfunction ice_phy_res_address_eth56gfunction ice_write_port_eth56gfunction ice_read_port_eth56gfunction ice_write_ptp_reg_eth56gfunction ice_write_mac_reg_eth56gfunction ice_write_xpcs_reg_eth56gfunction ice_read_ptp_reg_eth56gfunction ice_read_mac_reg_eth56gfunction ice_read_gpcs_reg_eth56gfunction ice_read_port_mem_eth56gfunction ice_write_port_mem_eth56gfunction ice_write_quad_ptp_reg_eth56gfunction ice_read_quad_ptp_reg_eth56gfunction ice_is_64b_phy_reg_eth56gfunction ice_is_40b_phy_reg_eth56gfunction ice_read_64b_phy_reg_eth56gfunction ice_read_64b_ptp_reg_eth56gfunction ice_write_40b_phy_reg_eth56gfunction ice_write_40b_ptp_reg_eth56gfunction ice_write_64b_phy_reg_eth56gfunction ice_write_64b_ptp_reg_eth56gfunction ice_read_ptp_tstamp_eth56gfunction ice_ptp_reset_ts_memory_quad_eth56gfunction ice_ptp_reset_ts_memory_eth56gfunction ice_ptp_prep_port_time_eth56gfunction ice_ptp_prep_phy_time_eth56gfunction ice_ptp_prep_port_adj_eth56gfunction ice_ptp_prep_phy_adj_eth56gfunction ice_ptp_prep_phy_incval_eth56gfunction ice_ptp_read_port_capture_eth56gfunction ice_ptp_write_port_cmd_eth56gfunction ice_phy_get_speed_eth56gfunction ice_phy_cfg_parpcs_eth56gfunction ice_phy_cfg_ptp_1step_eth56gfunction mul_u32_u32_fx_q9function add_u32_u32_fx
Annotated Snippet
if (err) {
ice_debug(hw, ICE_DBG_PTP, "Failed to soft reset port %d, err %d\n",
port, err);
return err;
}
}
return 0;
}
/**
* ice_ptp_get_dest_dev_e825 - get destination PHY for given port number
* @hw: pointer to the HW struct
* @port: destination port
*
* Return: destination sideband queue PHY device.
*/
static enum ice_sbq_dev_id ice_ptp_get_dest_dev_e825(struct ice_hw *hw,
u8 port)
{
u8 curr_phy, tgt_phy;
tgt_phy = port >= hw->ptp.ports_per_phy;
curr_phy = hw->lane_num >= hw->ptp.ports_per_phy;
/* In the driver, lanes 4..7 are in fact 0..3 on a second PHY.
* On a single complex E825C, PHY 0 is always destination device phy_0
* and PHY 1 is phy_0_peer.
* On dual complex E825C, device phy_0 points to PHY on a current
* complex and phy_0_peer to PHY on a different complex.
*/
if ((!ice_is_dual(hw) && tgt_phy == 1) ||
(ice_is_dual(hw) && tgt_phy != curr_phy))
return ice_sbq_dev_phy_0_peer;
else
return ice_sbq_dev_phy_0;
}
/**
* ice_write_phy_eth56g - Write a PHY port register
* @hw: pointer to the HW struct
* @port: destination port
* @addr: PHY register address
* @val: Value to write
*
* Return: 0 on success, other error codes when failed to write to PHY
*/
static int ice_write_phy_eth56g(struct ice_hw *hw, u8 port, u32 addr, u32 val)
{
struct ice_sbq_msg_input msg = {
.dest_dev = ice_ptp_get_dest_dev_e825(hw, port),
.opcode = ice_sbq_msg_wr,
.msg_addr_low = lower_16_bits(addr),
.msg_addr_high = upper_16_bits(addr),
.data = val
};
int err;
err = ice_sbq_rw_reg(hw, &msg, LIBIE_AQ_FLAG_RD);
if (err)
ice_debug(hw, ICE_DBG_PTP, "PTP failed to send msg to phy %d\n",
err);
return err;
}
/**
* ice_read_phy_eth56g - Read a PHY port register
* @hw: pointer to the HW struct
* @port: destination port
* @addr: PHY register address
* @val: Value to write
*
* Return: 0 on success, other error codes when failed to read from PHY
*/
static int ice_read_phy_eth56g(struct ice_hw *hw, u8 port, u32 addr, u32 *val)
{
struct ice_sbq_msg_input msg = {
.dest_dev = ice_ptp_get_dest_dev_e825(hw, port),
.opcode = ice_sbq_msg_rd,
.msg_addr_low = lower_16_bits(addr),
.msg_addr_high = upper_16_bits(addr)
};
int err;
err = ice_sbq_rw_reg(hw, &msg, LIBIE_AQ_FLAG_RD);
if (err)
ice_debug(hw, ICE_DBG_PTP, "PTP failed to send msg to phy %d\n",
err);
else
*val = msg.data;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/iopoll.h`, `ice_common.h`, `ice_ptp_hw.h`, `ice_ptp_consts.h`.
- Detected declarations: `function ice_get_ptp_src_clock_index`, `function ice_ptp_read_src_incval`, `function ice_ptp_tmr_cmd_to_src_reg`, `function ice_ptp_tmr_cmd_to_port_reg`, `function ice_ptp_src_cmd`, `function ice_ptp_exec_tmr_cmd`, `function ice_ptp_cfg_sync_delay`, `function ice_ptp_init_phc_e825c`, `function ice_ptp_get_dest_dev_e825`, `function ice_write_phy_eth56g`.
- 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.