02/05/2019 21:11, Tom Barbette: > + 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 ~= %lu\nHW Freq ~= %lu\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; > + }
I see two issues in this code: 1/ statements are mixed with variable declarations 2/ %lu is used for 64-bit variables, which does not work on 32-bit system. I am fixing item 2 when merging. I hope item 1 won't be an issue for some old compilers.