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.

Dependency Surface

Detected Declarations

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

Implementation Notes