src/dpdk/drivers/net/octeontx2/otx2_ptp.c
int
otx2_nix_raw_clock_tsc_conv(struct otx2_eth_dev *dev)
{
	uint64_t ticks_base = 0, ticks = 0, tsc = 0, t_freq;
	int rc, val;

	/* Calculating the frequency at which PTP HI clock is running */
	rc = nix_read_raw_clock(dev, &ticks_base, &tsc, false);
	if (rc) {
		otx2_err("Failed to read the raw clock value: %d", rc);
		goto fail;
	}

	rte_delay_ms(100);

	rc = nix_read_raw_clock(dev, &ticks, &tsc, false);
	if (rc) {
		otx2_err("Failed to read the raw clock value: %d", rc);
		goto fail;
	}

	t_freq = (ticks - ticks_base) * 10;

	/* Calculating the freq multiplier viz the ratio between the
	 * frequency at which PTP HI clock works and tsc clock runs
	 */
	dev->clk_freq_mult =
		(double)pow(10, floor(log10(t_freq))) / rte_get_timer_hz();

	val = false;
#ifdef RTE_ARM_EAL_RDTSC_USE_PMU
	val = true;
#endif
	rc = nix_read_raw_clock(dev, &ticks, &tsc, val);
	if (rc) {
		otx2_err("Failed to read the raw clock value: %d", rc);
		goto fail;
	}

	/* Calculating delta between PTP HI clock and tsc */
	dev->clk_delta = ((uint64_t)(ticks / dev->clk_freq_mult) - tsc);

fail:
	return rc;
}
/* This function calculates two parameters "clk_freq_mult" and
 * "clk_delta" which is useful in deriving PTP HI clock from
 * timestamp counter (tsc) value.
 */
This function calculates two parameters "clk_freq_mult" and
"clk_delta" which is useful in deriving PTP HI clock from
timestamp counter (tsc) value.
This function calculates two parameters " clk_freq_mult " and " clk_delta " which is useful in deriving PTP HI clock from timestamp counter ( tsc ) value .
int
otx2_nix_raw_clock_tsc_conv(struct otx2_eth_dev *dev)
{
	uint64_t ticks_base = 0, ticks = 0, tsc = 0, t_freq;
	int rc, val;
	rc = nix_read_raw_clock(dev, &ticks_base, &tsc, false);
	if (rc) {
		otx2_err("Failed to read the raw clock value: %d", rc);
		goto fail;
	}
	rte_delay_ms(100);
	rc = nix_read_raw_clock(dev, &ticks, &tsc, false);
	if (rc) {
		otx2_err("Failed to read the raw clock value: %d", rc);
		goto fail;
	}
	t_freq = (ticks - ticks_base) * 10;
	dev->clk_freq_mult =
		(double)pow(10, floor(log10(t_freq))) / rte_get_timer_hz();
	val = false;
#ifdef RTE_ARM_EAL_RDTSC_USE_PMU
	val = true;
#endif
	rc = nix_read_raw_clock(dev, &ticks, &tsc, val);
	if (rc) {
		otx2_err("Failed to read the raw clock value: %d", rc);
		goto fail;
	}
	dev->clk_delta = ((uint64_t)(ticks / dev->clk_freq_mult) - tsc);
fail:
	return rc;
}
int otx2_nix_raw_clock_tsc_conv ( struct otx2_eth_dev * dev ) { uint64_t ticks_base = 0 , ticks = 0 , tsc = 0 , t_freq ; int rc , val ; rc = nix_read_raw_clock ( dev , & ticks_base , & tsc , false ) ; if ( rc ) { otx2_err ( " " , rc ) ; goto fail ; } rte_delay_ms ( 100 ) ; rc = nix_read_raw_clock ( dev , & ticks , & tsc , false ) ; if ( rc ) { otx2_err ( " " , rc ) ; goto fail ; } t_freq = ( ticks - ticks_base ) * 10 ; dev -> clk_freq_mult = ( double ) pow ( 10 , floor ( log10 ( t_freq ) ) ) / rte_get_timer_hz ( ) ; val = false ; #ifdef RTE_ARM_EAL_RDTSC_USE_PMU val = true ; #endif rc = nix_read_raw_clock ( dev , & ticks , & tsc , val ) ; if ( rc ) { otx2_err ( " " , rc ) ; goto fail ; } dev -> clk_delta = ( ( uint64_t ) ( ticks / dev -> clk_freq_mult ) - tsc ) ; fail : return rc ; }
This function calculates two parameters "clk_freq_mult" and
 "clk_delta" which is useful in deriving PTP HI clock from
 timestamp counter (tsc) value.
This function calculates two parameters " clk_freq_mult " and " clk_delta " which is useful in deriving PTP HI clock from timestamp counter ( tsc ) value .
/* Calculating the frequency at which PTP HI clock is running */ /* Calculating the freq multiplier viz the ratio between the
	 * frequency at which PTP HI clock works and tsc clock runs
	 */ /* Calculating delta between PTP HI clock and tsc */