+ if (hw_timestamping && ticks_per_cycle_mult == 0) {
+ uint64_t cycles_base = rte_rdtsc();
+ uint64_t ticks_base;
+ retval = rte_eth_read_clock(port, &ticks_base);
+ if (retval != 0)
+ return retval;
+ rte_delay_ms(100);
+ uint64_t cycles = rte_rdtsc();
+ uint64_t ticks;
+ rte_eth_read_clock(port, &ticks);
+ uint64_t c_freq = cycles - cycles_base;
+ uint64_t t_freq = ticks - ticks_base;
+ double freq_mult = (double)c_freq / t_freq;
+ printf("TSC Freq ~= %" PRIu64
+ "\nHW Freq ~= %" PRIu64
+ "\nRatio : %f\n",
+ c_freq * 10, t_freq * 10, freq_mult);
+ /* TSC will be faster than internal ticks so freq_mult is > 0
+ * We convert the multiplication to an integer shift & mult
+ */
+ ticks_per_cycle_mult = (1 << TICKS_PER_CYCLE_SHIFT) / freq_mult;
+ }
+
+ struct rte_ether_addr addr;