From patchwork Tue Oct 25 00:27:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Brooks X-Patchwork-Id: 80282 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp333601qge; Mon, 31 Oct 2016 14:51:28 -0700 (PDT) X-Received: by 10.200.54.89 with SMTP id n25mr22725827qtb.82.1477950688459; Mon, 31 Oct 2016 14:51:28 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 47si3549641qtx.123.2016.10.31.14.51.28; Mon, 31 Oct 2016 14:51:28 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 2ACD4617D3; Mon, 31 Oct 2016 21:51:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=BAYES_00, DATE_IN_PAST_96_XX, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 58A91617CD; Mon, 31 Oct 2016 21:50:57 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 1025A617CD; Mon, 31 Oct 2016 21:50:49 +0000 (UTC) Received: from mail-oi0-f51.google.com (mail-oi0-f51.google.com [209.85.218.51]) by lists.linaro.org (Postfix) with ESMTPS id 1C07961787 for ; Mon, 31 Oct 2016 21:50:48 +0000 (UTC) Received: by mail-oi0-f51.google.com with SMTP id 62so133301523oif.1 for ; Mon, 31 Oct 2016 14:50:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9t5hqgEpfyc/0ASqv6pUJfls2gOgYjLGxBErQCp4DoI=; b=HwRmIiYNntx1E9b2Gj1mzDO5HrvaWnL8ntkI8QYOHhwVxE4m6q30BxLP06BkFk8var pTcExMr8XB6JJr7CxrDmHL/vyg9NAvMIccTBpVmwrKWI4c1WJYs3iP2mV+aR428luWEi 1c0h/fotAi+N/kS8AQIoQQYWnE8zjLCo25q248S5vhe9qre7+BIxuvvqAR2mzVnR85ID 3yDPc1be8r78m8AYe9p+tIVPvSPnFfucIaIWKEH/nhdh6GpXn724QO++IhmNYKjvZxMO zxkuBTx6U7eYrAhPrCDyFejSfOFKL2MGpI6a9ZKQfk1Kx7wLVfT3GdV4ukiS86fVvAaL xr2A== X-Gm-Message-State: ABUngvcCnKvYkBGk2R0Ka3MJG6oKYGntTQvo4gWWPOKICJvt85l0CgObDgaloLGGt2jNU6z9TU4= X-Received: by 10.202.185.196 with SMTP id j187mr18215804oif.170.1477950647511; Mon, 31 Oct 2016 14:50:47 -0700 (PDT) Received: from vm-arch-01.localdomain (68-248-140-212.lightspeed.austtx.sbcglobal.net. [68.248.140.212]) by smtp.gmail.com with ESMTPSA id w22sm177107otw.31.2016.10.31.14.50.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Oct 2016 14:50:47 -0700 (PDT) From: Brian Brooks To: lng-odp@lists.linaro.org Date: Mon, 24 Oct 2016 19:27:50 -0500 Message-Id: <20161025002752.11939-2-brian.brooks@linaro.org> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161025002752.11939-1-brian.brooks@linaro.org> References: <20161025002752.11939-1-brian.brooks@linaro.org> X-Topics: timers Subject: [lng-odp] [RFC 2/4] timer: add odp_timer_pool_from_timer() X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Brian Brooks --- include/odp/api/spec/timer.h | 9 +++++++++ platform/linux-generic/odp_timer.c | 5 +++++ test/common_plat/validation/api/timer/timer.c | 2 ++ 3 files changed, 16 insertions(+) -- 2.10.1 diff --git a/include/odp/api/spec/timer.h b/include/odp/api/spec/timer.h index 540da44..0a6eca1 100644 --- a/include/odp/api/spec/timer.h +++ b/include/odp/api/spec/timer.h @@ -200,6 +200,15 @@ int odp_timer_pool_info(odp_timer_pool_t tpid, uint64_t odp_timer_pool_res(odp_timer_pool_t tpid); /** + * Get timer pool from timer + * + * @param tim Timer handle + * + * @return Timer pool handle + */ +odp_timer_pool_t odp_timer_pool_from_timer(odp_timer_t tim); + +/** * Allocate a timer * * Create a timer (allocating all necessary resources e.g. timeout event) from diff --git a/platform/linux-generic/odp_timer.c b/platform/linux-generic/odp_timer.c index d4b30b2..19b1e58 100644 --- a/platform/linux-generic/odp_timer.c +++ b/platform/linux-generic/odp_timer.c @@ -842,6 +842,11 @@ uint64_t odp_timer_pool_res(odp_timer_pool_t tpid) return tpid->param.res_ns; } +odp_timer_pool_t odp_timer_pool_from_timer(odp_timer_t tim) +{ + return handle_to_tp(tim); +} + uint64_t odp_timer_pool_to_u64(odp_timer_pool_t tpid) { return _odp_pri(tpid); diff --git a/test/common_plat/validation/api/timer/timer.c b/test/common_plat/validation/api/timer/timer.c index a8321f3..66a0143 100644 --- a/test/common_plat/validation/api/timer/timer.c +++ b/test/common_plat/validation/api/timer/timer.c @@ -231,6 +231,8 @@ static void handle_tmo(odp_event_t ev, bool stale, uint64_t prev_tick) uint64_t tick = odp_timeout_tick(tmo); struct test_timer *ttp = odp_timeout_user_ptr(tmo); + CU_ASSERT(odp_timer_pool_from_timer(tim) == tp); + if (tim == ODP_TIMER_INVALID) CU_FAIL("odp_timeout_timer() invalid timer"); if (!ttp)