MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_timecounter_update

Function rte_timecounter_update

dpdk/lib/eal/include/rte_time.h:55–77  ·  view source on GitHub ↗

* Update the internal nanosecond count in the structure. */

Source from the content-addressed store, hash-verified

53 * Update the internal nanosecond count in the structure.
54 */
55static inline uint64_t
56rte_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.

Calls 1

Tested by

no test coverage detected