diff options
author | Petri Savolainen <petri.savolainen@nokia.com> | 2023-11-20 17:12:41 +0200 |
---|---|---|
committer | Petri Savolainen <petri.savolainen@nokia.com> | 2023-12-20 13:05:01 +0200 |
commit | 29f7e5aaba34df55ee92107ead4b7e303c254018 (patch) | |
tree | 1ab52fd0e65e05e752bc424c9f3fd3962bdc55e2 | |
parent | ce3674603fe38d9a229f8faf73a1fe3acb6104b9 (diff) |
linux-gen: use odp_time_add_ns()
Simplify linux-gen implementation by using the new add nsec
function instead of sum time stamps function.
Signed-off-by: Petri Savolainen <petri.savolainen@nokia.com>
Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
-rw-r--r-- | platform/linux-generic/odp_packet_io.c | 12 | ||||
-rw-r--r-- | platform/linux-generic/odp_schedule_basic.c | 11 | ||||
-rw-r--r-- | platform/linux-generic/odp_schedule_scalable.c | 8 | ||||
-rw-r--r-- | platform/linux-generic/odp_schedule_sp.c | 3 | ||||
-rw-r--r-- | platform/linux-generic/test/pktio_ipc/ipc_common.c | 4 |
5 files changed, 12 insertions, 26 deletions
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index cef2158cb..236813e80 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -2566,14 +2566,12 @@ int odp_pktin_recv_tmo(odp_pktin_queue_t queue, odp_packet_t packets[], int num, /* Avoid unnecessary system calls. Record the start time * only when needed and after the first call to recv. */ if (odp_unlikely(!started)) { - odp_time_t t; - /* Avoid overflow issues for large wait times */ if (wait > MAX_WAIT_TIME) wait = MAX_WAIT_TIME; - t = odp_time_local_from_ns(wait * 1000); + started = 1; - t1 = odp_time_sum(odp_time_local(), t); + t1 = odp_time_add_ns(odp_time_local(), wait * 1000); } /* Check every SLEEP_CHECK rounds if total wait time @@ -2650,14 +2648,12 @@ int odp_pktin_recv_mq_tmo(const odp_pktin_queue_t queues[], uint32_t num_q, uint return 0; if (odp_unlikely(!started)) { - odp_time_t t; - /* Avoid overflow issues for large wait times */ if (wait > MAX_WAIT_TIME) wait = MAX_WAIT_TIME; - t = odp_time_local_from_ns(wait * 1000); + started = 1; - t1 = odp_time_sum(odp_time_local(), t); + t1 = odp_time_add_ns(odp_time_local(), wait * 1000); } /* Check every SLEEP_CHECK rounds if total wait time diff --git a/platform/linux-generic/odp_schedule_basic.c b/platform/linux-generic/odp_schedule_basic.c index 05eb6aa9f..7bd8cbfed 100644 --- a/platform/linux-generic/odp_schedule_basic.c +++ b/platform/linux-generic/odp_schedule_basic.c @@ -1628,7 +1628,7 @@ static inline int schedule_run(odp_queue_t *out_queue, odp_event_t out_ev[], uin static inline int schedule_loop(odp_queue_t *out_queue, uint64_t wait, odp_event_t out_ev[], uint32_t max_num) { - odp_time_t next, wtime; + odp_time_t next; int first = 1; int ret; @@ -1647,8 +1647,7 @@ static inline int schedule_loop(odp_queue_t *out_queue, uint64_t wait, break; if (first) { - wtime = odp_time_local_from_ns(wait); - next = odp_time_sum(odp_time_local(), wtime); + next = odp_time_add_ns(odp_time_local(), wait); first = 0; continue; } @@ -1677,11 +1676,9 @@ static inline int schedule_loop_sleep(odp_queue_t *out_queue, uint64_t wait, if (first) { start = odp_time_local(); - start_sleep = - odp_time_sum(start, - odp_time_local_from_ns(sched->powersave.poll_time)); + start_sleep = odp_time_add_ns(start, sched->powersave.poll_time); if (wait != ODP_SCHED_WAIT) - end = odp_time_sum(start, odp_time_local_from_ns(wait)); + end = odp_time_add_ns(start, wait); first = 0; continue; } diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/odp_schedule_scalable.c index bb1549e9b..6d60c048f 100644 --- a/platform/linux-generic/odp_schedule_scalable.c +++ b/platform/linux-generic/odp_schedule_scalable.c @@ -1221,7 +1221,6 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t ev[], sched_scalable_thread_state_t *ts; int n; odp_time_t start; - odp_time_t delta; odp_time_t deadline; ts = _odp_sched_ts; @@ -1262,8 +1261,7 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t ev[], if (odp_likely(n > 0)) return n; - delta = odp_time_local_from_ns(wait); - deadline = odp_time_sum(start, delta); + deadline = odp_time_add_ns(start, wait); while (odp_time_cmp(deadline, odp_time_local()) > 0) { n = _schedule(from, ev, num); @@ -1281,7 +1279,6 @@ static odp_event_t schedule(odp_queue_t *from, uint64_t wait) sched_scalable_thread_state_t *ts; int n; odp_time_t start; - odp_time_t delta; odp_time_t deadline; ts = _odp_sched_ts; @@ -1324,8 +1321,7 @@ static odp_event_t schedule(odp_queue_t *from, uint64_t wait) if (odp_likely(n > 0)) return ev; - delta = odp_time_local_from_ns(wait); - deadline = odp_time_sum(start, delta); + deadline = odp_time_add_ns(start, wait); while (odp_time_cmp(deadline, odp_time_local()) > 0) { n = _schedule(from, &ev, num); diff --git a/platform/linux-generic/odp_schedule_sp.c b/platform/linux-generic/odp_schedule_sp.c index a42955ee9..ada0677cc 100644 --- a/platform/linux-generic/odp_schedule_sp.c +++ b/platform/linux-generic/odp_schedule_sp.c @@ -683,8 +683,7 @@ static int schedule_multi(odp_queue_t *from, uint64_t wait, continue; if (update_t1) { - t1 = odp_time_sum(odp_time_local(), - odp_time_local_from_ns(wait)); + t1 = odp_time_add_ns(odp_time_local(), wait); update_t1 = 0; continue; } diff --git a/platform/linux-generic/test/pktio_ipc/ipc_common.c b/platform/linux-generic/test/pktio_ipc/ipc_common.c index d30aaf473..f693feeb2 100644 --- a/platform/linux-generic/test/pktio_ipc/ipc_common.c +++ b/platform/linux-generic/test/pktio_ipc/ipc_common.c @@ -18,14 +18,12 @@ int ipc_odp_packet_send_or_free(odp_pktio_t pktio, int sent = 0; odp_time_t start_time; odp_time_t end_time; - odp_time_t wait; odp_pktout_queue_t pktout; int i; memset(&pktout, 0, sizeof(pktout)); start_time = odp_time_local(); - wait = odp_time_local_from_ns(ODP_TIME_SEC_IN_NS); - end_time = odp_time_sum(start_time, wait); + end_time = odp_time_add_ns(start_time, ODP_TIME_SEC_IN_NS); if (odp_pktout_queue(pktio, &pktout, 1) != 1) { ODPH_ERR("no output queue\n"); |