* Update the internal nanosecond count in the structure. */
| 53 | * Update the internal nanosecond count in the structure. |
| 54 | */ |
| 55 | static inline uint64_t |
| 56 | rte_timecounter_update(struct rte_timecounter *tc, uint64_t cycle_now) |
| 57 | { |
| 58 | uint64_t cycle_delta, ns_offset; |
| 59 | |
| 60 | /* Calculate the delta since the last call. */ |
| 61 | if (tc->cycle_last <= cycle_now) |
| 62 | cycle_delta = (cycle_now - tc->cycle_last) & tc->cc_mask; |
| 63 | else |
| 64 | /* Handle cycle counts that have wrapped around . */ |
| 65 | cycle_delta = (~(tc->cycle_last - cycle_now) & tc->cc_mask) + 1; |
| 66 | |
| 67 | /* Convert to nanoseconds. */ |
| 68 | ns_offset = rte_cyclecounter_cycles_to_ns(tc, cycle_delta); |
| 69 | |
| 70 | /* Store current cycle counter for next call. */ |
| 71 | tc->cycle_last = cycle_now; |
| 72 | |
| 73 | /* Update the nanosecond count. */ |
| 74 | tc->nsec += ns_offset; |
| 75 | |
| 76 | return tc->nsec; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Convert from timespec structure into nanosecond units. |
no test coverage detected