| 192 | #endif |
| 193 | |
| 194 | uint64_t |
| 195 | get_tsc_freq(void) |
| 196 | { |
| 197 | #ifdef CLOCK_MONOTONIC_RAW |
| 198 | #define NS_PER_SEC 1E9 |
| 199 | #define CYC_PER_10MHZ 1E7 |
| 200 | |
| 201 | struct timespec sleeptime = {.tv_nsec = NS_PER_SEC / 10 }; /* 1/10 second */ |
| 202 | |
| 203 | struct timespec t_start, t_end; |
| 204 | uint64_t tsc_hz; |
| 205 | |
| 206 | if (clock_gettime(CLOCK_MONOTONIC_RAW, &t_start) == 0) { |
| 207 | uint64_t ns, end, start = rte_rdtsc(); |
| 208 | nanosleep(&sleeptime,NULL); |
| 209 | clock_gettime(CLOCK_MONOTONIC_RAW, &t_end); |
| 210 | end = rte_rdtsc(); |
| 211 | ns = ((t_end.tv_sec - t_start.tv_sec) * NS_PER_SEC); |
| 212 | ns += (t_end.tv_nsec - t_start.tv_nsec); |
| 213 | |
| 214 | double secs = (double)ns/NS_PER_SEC; |
| 215 | tsc_hz = (uint64_t)((end - start)/secs); |
| 216 | /* Round up to 10Mhz. 1E7 ~ 10Mhz */ |
| 217 | return RTE_ALIGN_MUL_NEAR(tsc_hz, CYC_PER_10MHZ); |
| 218 | } |
| 219 | #endif |
| 220 | return 0; |
| 221 | } |
| 222 | |
| 223 | int |
| 224 | rte_eal_timer_init(void) |
no test coverage detected