From patchwork Thu May 12 17:21:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 67689 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp869911qge; Thu, 12 May 2016 10:22:11 -0700 (PDT) X-Received: by 10.55.209.134 with SMTP id o6mr11320441qkl.153.1463073731829; Thu, 12 May 2016 10:22:11 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h60si9189838qgh.92.2016.05.12.10.22.11; Thu, 12 May 2016 10:22:11 -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 595FB6164A; Thu, 12 May 2016 17:22:11 +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=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, URIBL_BLOCKED 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 E49EC6164B; Thu, 12 May 2016 17:21:34 +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 BD2A66162C; Thu, 12 May 2016 17:21:30 +0000 (UTC) Received: from mail-oi0-f48.google.com (mail-oi0-f48.google.com [209.85.218.48]) by lists.linaro.org (Postfix) with ESMTPS id 822CF61605 for ; Thu, 12 May 2016 17:21:28 +0000 (UTC) Received: by mail-oi0-f48.google.com with SMTP id k142so130809590oib.1 for ; Thu, 12 May 2016 10:21:28 -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=PG+3zY36vmFP/1GNsBK+3q8zMF3AVFQzZPr8o1liI90=; b=nHPOxoKDee9wVPp9DkW967KHAf8dBQmGgFWOz6M+dBnAUlB7PV+5sAMgfb78f1w4vu zldi87ArXQ0VrGXkrYdVRr3Yalmd18xnpPY7TbYLZXMmfSmhTTUnQor0mqqDMdMOCvH6 m1Pz2yONo/F8u3O14dWb+vo2Dq08VlpGz9ii64mJVGS41lQ8WCOvMB0d6po4lSTItjlk 2HEu8/leNF3+X3W90lMNFZ7NT9SLPV9b1Q6S++hlYBFI50qFAsYlrp9xPHpV9KOO8jP9 LXnujpZDWxwE+UqypCVofB8gHJwlfiSVfJg4djCrZYpdaFlaCulFEH2opSmKAquiELjw Tk4Q== X-Gm-Message-State: AOPr4FUQYxeX7AWro3v0qiAUF7YVFJ/huFO64/PKh9856/l0tjmJzMPpOAVFdu+E9nzQKCLtAMY= X-Received: by 10.202.82.71 with SMTP id g68mr6269897oib.36.1463073688029; Thu, 12 May 2016 10:21:28 -0700 (PDT) Received: from localhost.localdomain (cpe-66-68-129-43.austin.res.rr.com. [66.68.129.43]) by smtp.gmail.com with ESMTPSA id fo3sm2222001obb.1.2016.05.12.10.21.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 May 2016 10:21:27 -0700 (PDT) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 12 May 2016 12:21:24 -0500 Message-Id: <1463073684-12848-2-git-send-email-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1463073684-12848-1-git-send-email-bill.fischofer@linaro.org> References: <1463073684-12848-1-git-send-email-bill.fischofer@linaro.org> X-Topics: timers patch Subject: [lng-odp] [PATCHv5 2/2] doc: userguide: add timer and timeout event section to user guide 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: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Ivan Khoronzhuk Signed-off-by: Bill Fischofer Signed-off-by: Christophe Milard --- doc/users-guide/Makefile.am | 1 + doc/users-guide/users-guide-timer.adoc | 107 +++++++++++++++++++++++++++++++++ doc/users-guide/users-guide.adoc | 2 + 3 files changed, 110 insertions(+) create mode 100644 doc/users-guide/users-guide-timer.adoc diff --git a/doc/users-guide/Makefile.am b/doc/users-guide/Makefile.am index 2e1195e..5903392 100644 --- a/doc/users-guide/Makefile.am +++ b/doc/users-guide/Makefile.am @@ -4,6 +4,7 @@ SRC = $(top_srcdir)/doc/users-guide/users-guide.adoc \ $(top_srcdir)/doc/users-guide/users-guide-cls.adoc \ $(top_srcdir)/doc/users-guide/users-guide-packet.adoc \ $(top_srcdir)/doc/users-guide/users-guide-pktio.adoc \ + $(top_srcdir)/doc/users-guide/users-guide-timer.adoc \ $(top_srcdir)/doc/users-guide/users-guide-tm.adoc TARGET = users-guide.html IMAGES = $(top_srcdir)/doc/images/overview.svg \ diff --git a/doc/users-guide/users-guide-timer.adoc b/doc/users-guide/users-guide-timer.adoc new file mode 100644 index 0000000..08de04e --- /dev/null +++ b/doc/users-guide/users-guide-timer.adoc @@ -0,0 +1,107 @@ +== Timers and Timeout Events +The ODP Timer APIs offer a set of functions that permit applications to react +to the passage of time, and are designed to reflect the underlying hardware +timing features found in various platforms that support ODP implementations. + +Timers are drawn from specialized pools called _timer pools_ that have their +own abstract type (`odp_timer_pool_t`). Each timer pool is a logically +independent time source with its own _resolution_ measured in nanoseconds (ns) +and a maximum number of timers that it can support. Applications can have many +timers active at the same time and can set them to use either relative or +absolute time. Associated with each timer is a queue that is to receive events +when this timer expires. This queue is created by a separate +`odp_queue_create()` call that is passed as a parameter to `odp_timer_alloc()`. + +Timeouts are specialized events of type `odp_timeout_t` that are used to +represent the expiration of timers. Timeouts are drawn from pools of type +`ODP_POOL_TIMEOUT` that are created by the standard `odp_pool_create()` API. +Timeout events are associated with timers when those timers are _set_ and are +enqueued to their timer's associated queue whenever a set timer expires. So the +effect of timer expiration is a timeout event being added to a queue and +delivered via normal ODP event scheduling. + +The following diagrams show the life cycle of the timers and the time-out +objects. Transitions in these finite state machines are marked by the event +triggering them. Events marked in green are common to both state machines, +i.e. trigger both state machines. + +.ODP Timers lifecycle State Diagram +image::timer_fsm.svg[align="center"] + +.ODP Time-out event lifecyle State Diagram +image::timeout_fsm.svg[align="center"] + +Reminder: +On `timer expire` event, the related timeout event is enqueued to the timer +related queue. + +Timers measure time in _ticks_ rather than nanoseconds because each timer pool +may have its own time source and associated conversion ratios. It is thus more +efficient to manipulate time in these native tick values. As a result time +measured in nanoseconds must be converted between timer-pool specific tick +values via the conversion functions `odp_timer_ns_to_tick()` and +`odp_timer_tick_to_ns()` as needed. Both of these functions take a timer pool +as an input parameter to enable the pool-specific conversion ratios to be +used. + +Associated with each timer pool is a free running tick counter that can be +sampled at any time via the `odp_timer_current_tick()` API. Timers can be +set to an absolute future tick value via `odp_timer_set_abs()` or to a +future tick value relative to the current tick via `odp_timer_set_rel()`. + +Before a set timer expires, it can be canceled via the `odp_timer_cancel()` +API. A successful cancel has the same effect as if the timer were never set. +An attempted cancel will fail if the timer is not set or if it has already +expired. + +=== Timer Pool Management +To facilitate implementation of the ODP timer APIs, an additional timer API is +provided. During initialization, applications are expected to create the timer +pools they need and then call `odp_timer_pool_start()`. ODP implementations +may or may not fail further attempts to create timer pools after this API is +called. For best portability, applications should not attempt to create +further timer pools after calling `odp_timer_pool_start()`. Note that no such +restrictions exist on timeout pools, as these are just ordinary ODP pools. + +Following start, applications may allocate, set, cancel, and free timers +from their associated timer pools. During termination processing, after all +timers allocated from a timer pool have been freed, the pool itself should be +released via a call to `odp_timer_pool_destroy()`. + +=== Timeout Event Management +The purpose of ODP timers is to schedule their associated timeout events, which +are how applications actually react to the passage of time. To help with this, +several additional APIs and conventions are provided. + +Timer allocation is performed via the `odp_timer_alloc()` API: +[source,c] +----- +/** + * Allocate a timer + * + * Create a timer (allocating all necessary resources e.g. timeout event) from + * the timer pool. The user_ptr is copied to timeouts and can be retrieved + * using the odp_timeout_user_ptr() call. + * + * @param tpid Timer pool identifier + * @param queue Destination queue for timeout notifications + * @param user_ptr User defined pointer or NULL to be copied to timeouts + * + * @return Timer handle on success + * @retval ODP_TIMER_INVALID on failure and errno set. + */ +odp_timer_t odp_timer_alloc(odp_timer_pool_t tpid, + odp_queue_t queue, + void *user_ptr); +----- +Note that in addition to the timer pool id and queue, a user pointer is +provided. This is to allow context associated with the timeout to be +communicated. Upon receiving a timeout event, the application can use +the `odp_timeout_user_ptr()` API to retrieve the user pointer associated +with the timer that triggered this event. + +As mentioned, if a timer is canceled after it has already expired, the +request fails and the associated timeout event will still be +delivered. However, upon receiving a timeout event the application can use the +`odp_timeout_fresh()` API to inquire whether the timeout event is fresh or +stale. diff --git a/doc/users-guide/users-guide.adoc b/doc/users-guide/users-guide.adoc index 0221634..3f16608 100644 --- a/doc/users-guide/users-guide.adoc +++ b/doc/users-guide/users-guide.adoc @@ -907,6 +907,8 @@ include::users-guide-packet.adoc[] include::users-guide-pktio.adoc[] +include::users-guide-timer.adoc[] + == Cryptographic services ODP provides support for cryptographic operations required by various security