drivers/net/ethernet/intel/ice/ice_cpi.c
Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_cpi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/net/ethernet/intel/ice/ice_cpi.c- Extension
.c- Size
- 9510 bytes
- Lines
- 363
- 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
ice_type.hice_common.hice_ptp_hw.hice.hice_cpi.h
Detected Declarations
function ice_cpi_get_dest_devfunction ice_cpi_write_phyfunction ice_cpi_read_phyfunction ice_cpi_wait_req0_ack0function ice_cpi_wait_ackfunction ice_cpi_req0function ice_cpi_exec_cmdfunction ice_cpi_execfunction ice_cpi_set_cmdfunction ice_cpi_ena_dis_clk_ref
Annotated Snippet
if (asserted && FIELD_GET(CPI_PHY_CMD_ACK_M, phy_val)) {
if (data)
*data = phy_val;
return 0;
}
if (!asserted && !FIELD_GET(CPI_PHY_CMD_ACK_M, phy_val))
return 0;
msleep(CPI_RETRIES_CADENCE_MS);
}
return -ETIMEDOUT;
}
#define ice_cpi_wait_ack0(hw, port) \
ice_cpi_wait_ack(hw, port, false, NULL)
#define ice_cpi_wait_ack1(hw, port, data) \
ice_cpi_wait_ack(hw, port, true, data)
/**
* ice_cpi_req0 - deasserts LM.REQ bit
* @hw: pointer to the HW struct
* @phy: phy index of port the CPI action is taken on
* @data: the command data
*
* Return: 0 on success, negative on CPI write error
*/
static int ice_cpi_req0(struct ice_hw *hw, u8 phy, u32 data)
{
data &= ~CPI_LM_CMD_REQ_M;
return ice_cpi_write_phy(hw, phy, CPI0_LM1_CMD_DATA, data);
}
/**
* ice_cpi_exec_cmd - writes command data to CPI interface
* @hw: pointer to the HW struct
* @phy: phy index of port the CPI action is taken on
* @data: the command data
*
* Return: 0 on success, otherwise negative on error
*/
static int ice_cpi_exec_cmd(struct ice_hw *hw, int phy, u32 data)
{
return ice_cpi_write_phy(hw, phy, CPI0_LM1_CMD_DATA, data);
}
/**
* ice_cpi_phy_lock - get per-PHY lock for CPI transaction serialization
* @hw: pointer to the HW struct
* @phy: PHY index
*
* Return: pointer to PHY mutex, or %NULL when context is unavailable.
*/
static struct mutex *ice_cpi_phy_lock(struct ice_hw *hw, u8 phy)
{
struct ice_pf *pf = hw->back;
if (!pf || !pf->adapter || phy >= ICE_E825_MAX_PHYS)
return NULL;
return &pf->adapter->cpi_phy_lock[phy];
}
/**
* ice_cpi_exec - executes CPI command
* @hw: pointer to the HW struct
* @phy: phy index of port the CPI action is taken on
* @cmd: pointer to the command struct to execute
* @resp: pointer to user allocated CPI response struct
*
* This function executes CPI request with respect to CPI handshake
* mechanism.
*
* Return: 0 on success, otherwise negative on error
*/
int ice_cpi_exec(struct ice_hw *hw, u8 phy,
const struct ice_cpi_cmd *cmd,
struct ice_cpi_resp *resp)
{
struct mutex *cpi_lock; /* serializes CPI transactions per PHY */
u32 phy_cmd, lm_cmd = 0;
int err, err1 = 0;
if (!cmd || !resp)
return -EINVAL;
cpi_lock = ice_cpi_phy_lock(hw, phy);
if (!cpi_lock)
Annotation
- Immediate include surface: `ice_type.h`, `ice_common.h`, `ice_ptp_hw.h`, `ice.h`, `ice_cpi.h`.
- Detected declarations: `function ice_cpi_get_dest_dev`, `function ice_cpi_write_phy`, `function ice_cpi_read_phy`, `function ice_cpi_wait_req0_ack0`, `function ice_cpi_wait_ack`, `function ice_cpi_req0`, `function ice_cpi_exec_cmd`, `function ice_cpi_exec`, `function ice_cpi_set_cmd`, `function ice_cpi_ena_dis_clk_ref`.
- 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.