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

Function get_timeout_cycles

dpdk/lib/eventdev/rte_event_timer_adapter.c:738–783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

736}
737
738static __rte_always_inline int
739get_timeout_cycles(struct rte_event_timer *evtim,
740 const struct rte_event_timer_adapter *adapter,
741 uint64_t *timeout_cycles)
742{
743 static struct rte_reciprocal_u64 nsecpersec_inverse;
744 static uint64_t timer_hz;
745 uint64_t rem_cycles, secs_cycles = 0;
746 uint64_t secs, timeout_nsecs;
747 uint64_t nsecpersec;
748 struct swtim *sw;
749
750 sw = swtim_pmd_priv(adapter);
751 nsecpersec = (uint64_t)NSECPERSEC;
752
753 timeout_nsecs = evtim->timeout_ticks * sw->timer_tick_ns;
754 if (timeout_nsecs > sw->max_tmo_ns)
755 return -1;
756 if (timeout_nsecs < sw->timer_tick_ns)
757 return -2;
758
759 /* Set these values in the first invocation */
760 if (!timer_hz) {
761 timer_hz = rte_get_timer_hz();
762 nsecpersec_inverse = rte_reciprocal_value_u64(nsecpersec);
763 }
764
765 /* If timeout_nsecs > nsecpersec, decrease timeout_nsecs by the number
766 * of whole seconds it contains and convert that value to a number
767 * of cycles. This keeps timeout_nsecs in the interval [0..nsecpersec)
768 * in order to avoid overflow when we later multiply by timer_hz.
769 */
770 if (timeout_nsecs > nsecpersec) {
771 secs = rte_reciprocal_divide_u64(timeout_nsecs,
772 &nsecpersec_inverse);
773 secs_cycles = secs * timer_hz;
774 timeout_nsecs -= secs * nsecpersec;
775 }
776
777 rem_cycles = rte_reciprocal_divide_u64(timeout_nsecs * timer_hz,
778 &nsecpersec_inverse);
779
780 *timeout_cycles = secs_cycles + rem_cycles;
781
782 return 0;
783}
784
785/* This function returns true if one or more (adapter) ticks have occurred since
786 * the last time it was called.

Callers 1

__swtim_arm_burstFunction · 0.85

Calls 3

swtim_pmd_privFunction · 0.85
rte_reciprocal_value_u64Function · 0.85

Tested by

no test coverage detected