drivers/net/ethernet/intel/ice/ice_ptp.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/intel/ice/ice_ptp.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/intel/ice/ice_ptp.c
Extension
.c
Size
93436 bytes
Lines
3437
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

struct ice_crosststamp_cfg {
	/* HW semaphore lock register */
	u32 lock_reg;
	u32 lock_busy;

	/* Capture control register */
	u32 ctl_reg;
	u32 ctl_active;

	/* Time storage */
	u32 art_time_l;
	u32 art_time_h;
	u32 dev_time_l[2];
	u32 dev_time_h[2];
};

static const struct ice_crosststamp_cfg ice_crosststamp_cfg_e82x = {
	.lock_reg = PFHH_SEM,
	.lock_busy = PFHH_SEM_BUSY_M,
	.ctl_reg = GLHH_ART_CTL,
	.ctl_active = GLHH_ART_CTL_ACTIVE_M,
	.art_time_l = GLHH_ART_TIME_L,
	.art_time_h = GLHH_ART_TIME_H,
	.dev_time_l[0] = GLTSYN_HHTIME_L(0),
	.dev_time_h[0] = GLTSYN_HHTIME_H(0),
	.dev_time_l[1] = GLTSYN_HHTIME_L(1),
	.dev_time_h[1] = GLTSYN_HHTIME_H(1),
};

#ifdef CONFIG_ICE_HWTS
static const struct ice_crosststamp_cfg ice_crosststamp_cfg_e830 = {
	.lock_reg = E830_PFPTM_SEM,
	.lock_busy = E830_PFPTM_SEM_BUSY_M,
	.ctl_reg = E830_GLPTM_ART_CTL,
	.ctl_active = E830_GLPTM_ART_CTL_ACTIVE_M,
	.art_time_l = E830_GLPTM_ART_TIME_L,
	.art_time_h = E830_GLPTM_ART_TIME_H,
	.dev_time_l[0] = E830_GLTSYN_PTMTIME_L(0),
	.dev_time_h[0] = E830_GLTSYN_PTMTIME_H(0),
	.dev_time_l[1] = E830_GLTSYN_PTMTIME_L(1),
	.dev_time_h[1] = E830_GLTSYN_PTMTIME_H(1),
};

#endif /* CONFIG_ICE_HWTS */
/**
 * struct ice_crosststamp_ctx - Device cross timestamp context
 * @snapshot: snapshot of system clocks for historic interpolation
 * @snapshot_clock_id: System clock ID for @snapshot
 * @pf: pointer to the PF private structure
 * @cfg: pointer to hardware configuration for cross timestamp
 */
struct ice_crosststamp_ctx {
	struct system_time_snapshot snapshot;
	clockid_t snapshot_clock_id;
	struct ice_pf *pf;
	const struct ice_crosststamp_cfg *cfg;
};

/**
 * ice_capture_crosststamp - Capture a device/system cross timestamp
 * @device: Current device time
 * @system: System counter value read synchronously with device time
 * @__ctx: Context passed from ice_ptp_getcrosststamp
 *
 * Read device and system (ART) clock simultaneously and return the corrected
 * clock values in ns.
 *
 * Return: zero on success, or a negative error code on failure.
 */
static int ice_capture_crosststamp(ktime_t *device,
				   struct system_counterval_t *system,
				   void *__ctx)
{
	struct ice_crosststamp_ctx *ctx = __ctx;
	const struct ice_crosststamp_cfg *cfg;
	u32 lock, ctl, ts_lo, ts_hi, tmr_idx;
	struct ice_pf *pf;
	struct ice_hw *hw;
	int err;
	u64 ts;

	cfg = ctx->cfg;
	pf = ctx->pf;
	hw = &pf->hw;

	tmr_idx = hw->func_caps.ts_func_info.tmr_index_assoc;
	if (tmr_idx > 1)
		return -EINVAL;

	/* Poll until we obtain the cross-timestamp hardware semaphore */

Annotation

Implementation Notes