From patchwork Tue Jan 20 11:18:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43353 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C7F662034D for ; Tue, 20 Jan 2015 11:19:54 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id pn19sf7361180lab.2 for ; Tue, 20 Jan 2015 03:19:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=t9swhQoEx24//3KLhSqzKhyq7am6cJVhTCsK1bIOa6Y=; b=i717wfAforiPoAOHilj0zXryxYQHfXslOlcdhjQib74cy+BcToB73eLdOkKLl3b7n3 sQ6S4FRo/PBLgPRIK1ufscpPmgPIF/3SyB5uWgPDGhGAq3gfPPgmqtLmFglBHLn1he/l DLwllHfAExfAPOL11VKsJL3sr0NcXcJG/9YwVCfKLSH7xC5hNlj+Ozgqn1DrzXGJsh11 VhrKqNuA9CV2AlLQNuzxpJ/YStP0OhOHQbbMAagFeI8EwWcWSpyfNSxA5u4o3ts9Ju8e t9d2vIhgMU0fXE2tCXWevPaQzSchCC6kITLbkcpI3a/qiMaLCThBdVgZh8loBsHpAqWK hqTg== X-Gm-Message-State: ALoCoQmHToq76c+mWqDcPxzLDQNAxuVqKxqr70sx+qH+k/wYkHmMePIbJs/gQSdtEWJLkb70yZMF X-Received: by 10.152.36.168 with SMTP id r8mr38250laj.2.1421752793719; Tue, 20 Jan 2015 03:19:53 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.202 with SMTP id m10ls635426lah.76.gmail; Tue, 20 Jan 2015 03:19:53 -0800 (PST) X-Received: by 10.152.5.38 with SMTP id p6mr37341009lap.91.1421752793564; Tue, 20 Jan 2015 03:19:53 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id t1si4607972laz.36.2015.01.20.03.19.53 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 03:19:53 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ge10so12544843lab.10 for ; Tue, 20 Jan 2015 03:19:53 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr8202293laa.80.1421752793455; Tue, 20 Jan 2015 03:19:53 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp1380874lbb; Tue, 20 Jan 2015 03:19:52 -0800 (PST) X-Received: by 10.140.108.9 with SMTP id i9mr53031401qgf.73.1421752791661; Tue, 20 Jan 2015 03:19:51 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id k8si21686283qat.73.2015.01.20.03.19.50 (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 20 Jan 2015 03:19:51 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDWqa-0006KS-3u; Tue, 20 Jan 2015 11:19:48 +0000 Received: from mail-qa0-f43.google.com ([209.85.216.43]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YDWqB-0006Eh-Vj for lng-odp@lists.linaro.org; Tue, 20 Jan 2015 11:19:24 +0000 Received: by mail-qa0-f43.google.com with SMTP id v10so27771026qac.2 for ; Tue, 20 Jan 2015 03:19:18 -0800 (PST) X-Received: by 10.140.46.37 with SMTP id j34mr53524889qga.12.1421752758310; Tue, 20 Jan 2015 03:19:18 -0800 (PST) Received: from mcpro03.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id t2sm14975907qae.6.2015.01.20.03.19.16 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 20 Jan 2015 03:19:17 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Tue, 20 Jan 2015 13:18:05 +0200 Message-Id: <1421752692-24439-10-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1421752692-24439-1-git-send-email-petri.savolainen@linaro.org> References: <1421752692-24439-1-git-send-email-petri.savolainen@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCH v2 09/16] api: timer: Use odp_event_t instead of odp_buffer_t X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: petri.savolainen@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Changed timer API to use odp_event_t instead of odp_buffer_t. Signed-off-by: Petri Savolainen --- example/timer/odp_timer_test.c | 28 ++++++------ platform/linux-generic/include/api/odp_timer.h | 63 ++++++++++---------------- platform/linux-generic/odp_timer.c | 28 ++++-------- test/validation/odp_timer.c | 55 +++++++++++----------- 4 files changed, 77 insertions(+), 97 deletions(-) diff --git a/example/timer/odp_timer_test.c b/example/timer/odp_timer_test.c index 69cde3e..f4fa9a2 100644 --- a/example/timer/odp_timer_test.c +++ b/example/timer/odp_timer_test.c @@ -62,8 +62,8 @@ static const char *timerset2str(odp_timer_set_t val) return "too early"; case ODP_TIMER_TOOLATE: return "too late"; - case ODP_TIMER_NOBUF: - return "no buffer"; + case ODP_TIMER_NOEVENT: + return "no event"; default: return "?"; } @@ -72,7 +72,7 @@ static const char *timerset2str(odp_timer_set_t val) /** @private Helper struct for timers */ struct test_timer { odp_timer_t tim; - odp_buffer_t buf; + odp_event_t ev; }; /** @private Array of all timer helper structs */ @@ -86,6 +86,7 @@ static void test_abs_timeouts(int thr, test_args_t *args) odp_queue_t queue; uint64_t tick; struct test_timer *ttp; + odp_buffer_t buf; EXAMPLE_DBG(" [%i] test_timeouts\n", thr); @@ -106,11 +107,12 @@ static void test_abs_timeouts(int thr, test_args_t *args) EXAMPLE_ERR("Failed to allocate timer\n"); return; } - ttp->buf = odp_buffer_alloc(pool); - if (ttp->buf == ODP_BUFFER_INVALID) { + buf = odp_buffer_alloc(pool); + if (buf == ODP_BUFFER_INVALID) { EXAMPLE_ERR("Failed to allocate buffer\n"); return; } + ttp->ev = odp_buffer_to_event(buf); tick = odp_timer_current_tick(tp); while ((int)odp_atomic_load_u32(&remain) > 0) { @@ -118,7 +120,7 @@ static void test_abs_timeouts(int thr, test_args_t *args) odp_timer_set_t rc; tick += period; - rc = odp_timer_set_abs(ttp->tim, tick, &ttp->buf); + rc = odp_timer_set_abs(ttp->tim, tick, &ttp->ev); if (odp_unlikely(rc != ODP_TIMER_SUCCESS)) { /* Too early or too late timeout requested */ EXAMPLE_ABORT("odp_timer_set_abs() failed: %s\n", @@ -134,14 +136,14 @@ static void test_abs_timeouts(int thr, test_args_t *args) if (ev == ODP_EVENT_INVALID) continue; /* Re-check the remain counter */ if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) { - /* Not a default timeout buffer */ + /* Not a default timeout event */ EXAMPLE_ABORT("Unexpected event type (%u) received\n", odp_event_type(ev)); } odp_timeout_t tmo = odp_timeout_from_event(ev); tick = odp_timeout_tick(tmo); ttp = odp_timeout_user_ptr(tmo); - ttp->buf = odp_buffer_from_event(ev); + ttp->ev = ev; if (!odp_timeout_fresh(tmo)) { /* Not the expected expiration tick, timer has * been reset or cancelled or freed */ @@ -154,12 +156,12 @@ static void test_abs_timeouts(int thr, test_args_t *args) } /* Cancel and free last timer used */ - (void)odp_timer_cancel(ttp->tim, &ttp->buf); - if (ttp->buf != ODP_BUFFER_INVALID) - odp_buffer_free(ttp->buf); + (void)odp_timer_cancel(ttp->tim, &ttp->ev); + if (ttp->ev != ODP_EVENT_INVALID) + odp_buffer_free(odp_buffer_from_event(ttp->ev)); else - EXAMPLE_ERR("Lost timeout buffer at timer cancel\n"); - /* Since we have cancelled the timer, there is no timeout buffer to + EXAMPLE_ERR("Lost timeout event at timer cancel\n"); + /* Since we have cancelled the timer, there is no timeout event to * return from odp_timer_free() */ (void)odp_timer_free(ttp->tim); } diff --git a/platform/linux-generic/include/api/odp_timer.h b/platform/linux-generic/include/api/odp_timer.h index cb17b7b..075263a 100644 --- a/platform/linux-generic/include/api/odp_timer.h +++ b/platform/linux-generic/include/api/odp_timer.h @@ -20,7 +20,6 @@ extern "C" { #include #include -#include #include #include @@ -86,10 +85,10 @@ typedef enum { * timer pool. */ ODP_TIMER_TOOLATE = -2, /** - * Timer set operation failed because no timeout buffer specified and no - * timeout buffer present in the timer (timer inactive/expired). + * Timer set operation failed because no timeout event specified and no + * timeout event present in the timer (timer inactive/expired). */ - ODP_TIMER_NOBUF = -3 + ODP_TIMER_NOEVENT = -3 } odp_timer_set_t; /** Maximum timer pool name length in chars (including null char) */ @@ -214,29 +213,29 @@ odp_timer_t odp_timer_alloc(odp_timer_pool_t tpid, * Free a timer * * Free (destroy) a timer, reclaiming associated resources. - * The timeout buffer for an active timer will be returned. - * The timeout buffer for an expired timer will not be returned. It is the + * The timeout event for an active timer will be returned. + * The timeout event for an expired timer will not be returned. It is the * responsibility of the application to handle this timeout when it is received. * * @param tim Timer handle - * @return Buffer handle of timeout buffer or ODP_BUFFER_INVALID + * @return Event handle of timeout event or ODP_EVENT_INVALID */ -odp_buffer_t odp_timer_free(odp_timer_t tim); +odp_event_t odp_timer_free(odp_timer_t tim); /** - * Set a timer (absolute time) with a user-provided timeout buffer + * Set a timer (absolute time) with a user-provided timeout event * * Set (arm) the timer to expire at specific time. The timeout - * buffer will be enqueued when the timer expires. + * event will be enqueued when the timer expires. * * Note: any invalid parameters will be treated as programming errors and will * cause the application to abort. * * @param tim Timer * @param abs_tck Expiration time in absolute timer ticks - * @param[in,out] tmo_buf Reference to a buffer variable that points to - * timeout buffer or NULL to reuse the existing timeout buffer. Any existing - * timeout buffer that is replaced by a successful set operation will be + * @param[in,out] tmo_ev Reference to an event variable that points to + * timeout event or NULL to reuse the existing timeout event. Any existing + * timeout event that is replaced by a successful set operation will be * returned here. * * @retval ODP_TIMER_SUCCESS Operation succeeded @@ -244,15 +243,15 @@ odp_buffer_t odp_timer_free(odp_timer_t tim); * early * @retval ODP_TIMER_TOOLATE Operation failed because expiration tick too * late - * @retval ODP_TIMER_NOBUF Operation failed because timeout buffer not + * @retval ODP_TIMER_NOEVENT Operation failed because timeout event not * specified in odp_timer_set call and not present in timer */ int odp_timer_set_abs(odp_timer_t tim, uint64_t abs_tck, - odp_buffer_t *tmo_buf); + odp_event_t *tmo_ev); /** - * Set a timer with a relative expiration time and user-provided buffer. + * Set a timer with a relative expiration time and user-provided event. * * Set (arm) the timer to expire at a relative future time. * @@ -262,9 +261,9 @@ int odp_timer_set_abs(odp_timer_t tim, * @param tim Timer * @param rel_tck Expiration time in timer ticks relative to current time of * the timer pool the timer belongs to - * @param[in,out] tmo_buf Reference to a buffer variable that points to - * timeout buffer or NULL to reuse the existing timeout buffer. Any existing - * timeout buffer that is replaced by a successful set operation will be + * @param[in,out] tmo_ev Reference to an event variable that points to + * timeout event or NULL to reuse the existing timeout event. Any existing + * timeout event that is replaced by a successful set operation will be * returned here. * * @retval ODP_TIMER_SUCCESS Operation succeeded @@ -272,18 +271,18 @@ int odp_timer_set_abs(odp_timer_t tim, * early * @retval ODP_TIMER_TOOLATE Operation failed because expiration tick too * late - * @retval ODP_TIMER_NOBUF Operation failed because timeout buffer not + * @retval ODP_TIMER_NOEVENT Operation failed because timeout event not * specified in call and not present in timer */ int odp_timer_set_rel(odp_timer_t tim, uint64_t rel_tck, - odp_buffer_t *tmo_buf); + odp_event_t *tmo_ev); /** * Cancel a timer * * Cancel a timer, preventing future expiration and delivery. Return any - * present timeout buffer. + * present timeout event. * * A timer that has already expired may be impossible to cancel and the timeout * will instead be delivered to the destination queue. @@ -292,23 +291,11 @@ int odp_timer_set_rel(odp_timer_t tim, * cause the application to abort. * * @param tim Timer - * @param[out] tmo_buf Pointer to a buffer variable - * @retval 0 Success, active timer cancelled, timeout returned in '*tmo_buf' + * @param[out] tmo_ev Pointer to an event variable + * @retval 0 Success, active timer cancelled, timeout returned in '*tmo_ev' * @retval -1 Failure, timer already expired (or inactive) */ -int odp_timer_cancel(odp_timer_t tim, odp_buffer_t *tmo_buf); - -/** - * Return timeout handle that is associated with timeout buffer - * - * Note: any invalid parameters will cause undefined behavior and may cause - * the application to abort or crash. - * - * @param buf A buffer of type ODP_BUFFER_TYPE_TIMEOUT - * - * @return timeout handle - */ -odp_timeout_t odp_timeout_from_buf(odp_buffer_t buf); +int odp_timer_cancel(odp_timer_t tim, odp_event_t *tmo_ev); /** * Return timeout handle that is associated with timeout event @@ -316,7 +303,7 @@ odp_timeout_t odp_timeout_from_buf(odp_buffer_t buf); * Note: any invalid parameters will cause undefined behavior and may cause * the application to abort or crash. * - * @param buf An event of type ODP_EVENT_TIMEOUT + * @param ev An event of type ODP_EVENT_TIMEOUT * * @return timeout handle */ diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index 5d462ba..a32e240 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -739,17 +739,17 @@ odp_timer_t odp_timer_alloc(odp_timer_pool_t tpid, return ODP_TIMER_INVALID; } -odp_buffer_t odp_timer_free(odp_timer_t hdl) +odp_event_t odp_timer_free(odp_timer_t hdl) { odp_timer_pool *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); odp_buffer_t old_buf = timer_free(tp, idx); - return old_buf; + return odp_buffer_to_event(old_buf); } int odp_timer_set_abs(odp_timer_t hdl, uint64_t abs_tck, - odp_buffer_t *tmo_buf) + odp_event_t *tmo_ev) { odp_timer_pool *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); @@ -758,15 +758,15 @@ int odp_timer_set_abs(odp_timer_t hdl, return ODP_TIMER_TOOEARLY; if (odp_unlikely(abs_tck > cur_tick + tp->max_rel_tck)) return ODP_TIMER_TOOLATE; - if (timer_reset(idx, abs_tck, tmo_buf, tp)) + if (timer_reset(idx, abs_tck, (odp_buffer_t *)tmo_ev, tp)) return ODP_TIMER_SUCCESS; else - return ODP_TIMER_NOBUF; + return ODP_TIMER_NOEVENT; } int odp_timer_set_rel(odp_timer_t hdl, uint64_t rel_tck, - odp_buffer_t *tmo_buf) + odp_event_t *tmo_ev) { odp_timer_pool *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); @@ -775,34 +775,26 @@ int odp_timer_set_rel(odp_timer_t hdl, return ODP_TIMER_TOOEARLY; if (odp_unlikely(rel_tck > tp->max_rel_tck)) return ODP_TIMER_TOOLATE; - if (timer_reset(idx, abs_tck, tmo_buf, tp)) + if (timer_reset(idx, abs_tck, (odp_buffer_t *)tmo_ev, tp)) return ODP_TIMER_SUCCESS; else - return ODP_TIMER_NOBUF; + return ODP_TIMER_NOEVENT; } -int odp_timer_cancel(odp_timer_t hdl, odp_buffer_t *tmo_buf) +int odp_timer_cancel(odp_timer_t hdl, odp_event_t *tmo_ev) { odp_timer_pool *tp = handle_to_tp(hdl); uint32_t idx = handle_to_idx(hdl, tp); /* Set the expiration tick of the timer to TMO_INACTIVE */ odp_buffer_t old_buf = timer_cancel(tp, idx, TMO_INACTIVE); if (old_buf != ODP_BUFFER_INVALID) { - *tmo_buf = old_buf; + *tmo_ev = odp_buffer_to_event(old_buf); return 0; /* Active timer cancelled, timeout returned */ } else { return -1; /* Timer already expired, no timeout returned */ } } -odp_timeout_t odp_timeout_from_buf(odp_buffer_t buf) -{ - /* This check not mandated by the API specification */ - if (_odp_buffer_type(buf) != ODP_BUFFER_TYPE_TIMEOUT) - ODP_ABORT("Buffer not a timeout"); - return (odp_timeout_t)timeout_hdr_from_buf(buf); -} - odp_timeout_t odp_timeout_from_event(odp_event_t ev) { /* This check not mandated by the API specification */ diff --git a/test/validation/odp_timer.c b/test/validation/odp_timer.c index adc1554..4e4cc5b 100644 --- a/test/validation/odp_timer.c +++ b/test/validation/odp_timer.c @@ -37,25 +37,25 @@ static int min(int a, int b) /* @private Timer helper structure */ struct test_timer { odp_timer_t tim; /* Timer handle */ - odp_buffer_t buf; /* Timeout buffer */ - odp_buffer_t buf2; /* Copy of buffer handle */ + odp_event_t ev; /* Timeout event */ + odp_event_t ev2; /* Copy of event handle */ uint64_t tick; /* Expiration tick or TICK_INVALID */ }; #define TICK_INVALID (~(uint64_t)0) -/* @private Handle a received (timeout) buffer */ -static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) +/* @private Handle a received (timeout) event */ +static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) { /* Use assert() for internal correctness checks of test program */ - assert(buf != ODP_BUFFER_INVALID); - if (odp_event_type(odp_buffer_to_event(buf)) != ODP_EVENT_TIMEOUT) { - /* Not a timeout buffer */ - CU_FAIL("Unexpected buffer type received"); + assert(ev != ODP_EVENT_INVALID); + if (odp_event_type(ev) != ODP_EVENT_TIMEOUT) { + /* Not a timeout event */ + CU_FAIL("Unexpected event type received"); return; } /* Read the metadata from the timeout */ - odp_timeout_t tmo = odp_timeout_from_buf(buf); + odp_timeout_t tmo = odp_timeout_from_event(ev); odp_timer_t tim = odp_timeout_timer(tmo); uint64_t tick = odp_timeout_tick(tmo); struct test_timer *ttp = odp_timeout_user_ptr(tmo); @@ -65,7 +65,7 @@ static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) if (ttp == NULL) CU_FAIL("odp_timeout_user_ptr() null user ptr"); - if (ttp->buf2 != buf) + if (ttp->ev2 != ev) CU_FAIL("odp_timeout_user_ptr() wrong user ptr"); if (ttp->tim != tim) CU_FAIL("odp_timeout_timer() wrong timer"); @@ -95,8 +95,8 @@ static void handle_tmo(odp_buffer_t buf, bool stale, uint64_t prev_tick) } /* Use assert() for correctness check of test program itself */ - assert(ttp->buf == ODP_BUFFER_INVALID); - ttp->buf = buf; + assert(ttp->ev == ODP_EVENT_INVALID); + ttp->ev = ev; } /* @private Worker thread entrypoint which performs timer alloc/set/cancel/free @@ -123,10 +123,12 @@ static void *worker_entrypoint(void *arg) tt[i].tim = odp_timer_alloc(tp, queue, &tt[i]); if (tt[i].tim == ODP_TIMER_INVALID) CU_FAIL_FATAL("Failed to allocate timer"); - tt[i].buf = odp_buffer_alloc(tbp); - if (tt[i].buf == ODP_BUFFER_INVALID) + /* Timeout alloc is needed. + * With this alloc call pool/event type should be buffer. */ + tt[i].ev = odp_buffer_to_event(odp_buffer_alloc(tbp)); + if (tt[i].ev == ODP_EVENT_INVALID) CU_FAIL_FATAL("Failed to allocate timeout buffer"); - tt[i].buf2 = tt[i].buf; + tt[i].ev2 = tt[i].ev; tt[i].tick = TICK_INVALID; } @@ -140,7 +142,7 @@ static void *worker_entrypoint(void *arg) (rand_r(&seed) % RANGE_MS) * 1000000ULL); odp_timer_set_t rc; - rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].buf); + rc = odp_timer_set_abs(tt[i].tim, tck, &tt[i].ev); if (rc != ODP_TIMER_SUCCESS) { CU_FAIL("Failed to set timer"); } else { @@ -159,26 +161,24 @@ static void *worker_entrypoint(void *arg) for (ms = 0; ms < 7 * RANGE_MS / 10; ms++) { odp_event_t ev; while ((ev = odp_queue_deq(queue)) != ODP_EVENT_INVALID) { - odp_buffer_t buf; - buf = odp_buffer_from_event(ev); /* Subtract one from prev_tick to allow for timeouts * to be delivered a tick late */ - handle_tmo(buf, false, prev_tick - 1); + handle_tmo(ev, false, prev_tick - 1); nrcv++; } prev_tick = odp_timer_current_tick(tp); i = rand_r(&seed) % NTIMERS; - if (tt[i].buf == ODP_BUFFER_INVALID && + if (tt[i].ev == ODP_EVENT_INVALID && (rand_r(&seed) % 2 == 0)) { /* Timer active, cancel it */ - int rc = odp_timer_cancel(tt[i].tim, &tt[i].buf); + int rc = odp_timer_cancel(tt[i].tim, &tt[i].ev); if (rc != 0) /* Cancel failed, timer already expired */ ntoolate++; tt[i].tick = TICK_INVALID; ncancel++; } else { - if (tt[i].buf != ODP_BUFFER_INVALID) + if (tt[i].ev != ODP_EVENT_INVALID) /* Timer inactive => set */ nset++; else @@ -193,7 +193,7 @@ static void *worker_entrypoint(void *arg) do { cur_tick = odp_timer_current_tick(tp); rc = odp_timer_set_rel(tt[i].tim, - tck, &tt[i].buf); + tck, &tt[i].ev); } while (cur_tick != odp_timer_current_tick(tp)); if (rc == ODP_TIMER_TOOEARLY || rc == ODP_TIMER_TOOLATE) { @@ -212,13 +212,13 @@ static void *worker_entrypoint(void *arg) /* Cancel and free all timers */ uint32_t nstale = 0; for (i = 0; i < NTIMERS; i++) { - (void)odp_timer_cancel(tt[i].tim, &tt[i].buf); + (void)odp_timer_cancel(tt[i].tim, &tt[i].ev); tt[i].tick = TICK_INVALID; - if (tt[i].buf == ODP_BUFFER_INVALID) + if (tt[i].ev == ODP_EVENT_INVALID) /* Cancel too late, timer already expired and * timoeut buffer enqueued */ nstale++; - if (odp_timer_free(tt[i].tim) != ODP_BUFFER_INVALID) + if (odp_timer_free(tt[i].tim) != ODP_EVENT_INVALID) CU_FAIL("odp_timer_free"); } @@ -237,8 +237,7 @@ static void *worker_entrypoint(void *arg) while (nstale != 0) { odp_event_t ev = odp_queue_deq(queue); if (ev != ODP_EVENT_INVALID) { - odp_buffer_t buf = odp_buffer_from_event(ev); - handle_tmo(buf, true, 0/*Dont' care for stale tmo's*/); + handle_tmo(ev, true, 0/*Dont' care for stale tmo's*/); nstale--; } else { CU_FAIL("Failed to receive stale timeout");