From patchwork Thu Aug 27 13:56:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 52767 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id B783622DC4 for ; Thu, 27 Aug 2015 13:56:24 +0000 (UTC) Received: by wicne3 with SMTP id ne3sf8829412wic.1 for ; Thu, 27 Aug 2015 06:56:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:delivered-to:from:to:date :message-id: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=93PI05OJkvaKX/3IfcsD4rpWCFue1uwDEsbSef9/WE0=; b=Ht44WK/sYeAIq7rLOHPzrT6s+pdxLjw+T7a9rh7ntVq0Ew6VInrflT9iHHfc6B2Ctm hFAcQeEs3qoULFvt3veOND1Ne3f3wOnc5FJitL8D6pdKOxhtf50Cqohz1d9+/l2H393q BF2Zy2E3jVocGtxjp30EyDm/Lg/5MeNmeK5sAaR0DeYhIdVXJiI/mUPUlpB/2EFg0NwC ST9zJEAvR2lklOgspg7LtIlR/yZXOZvDeAQQr73R2Had+gg9oWuDJ8lhqZbJhbS+DUmk vDHp7qnVShzrdtUHP/E+ZFOIsMibTiBUoDapiqBCZMZGASW5U3vGuS9E6r6Zwoi897XB gOfA== X-Gm-Message-State: ALoCoQlavRkHKOMhg4KCjsQRm6tVPTd8TwcHVcoyLzX+3fl4uy0/c/RcTe47xR3GAIaEBkq90sAO X-Received: by 10.112.90.225 with SMTP id bz1mr1192622lbb.12.1440683783947; Thu, 27 Aug 2015 06:56:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.170 with SMTP id l10ls84256lah.82.gmail; Thu, 27 Aug 2015 06:56:23 -0700 (PDT) X-Received: by 10.152.184.72 with SMTP id es8mr2610914lac.48.1440683783814; Thu, 27 Aug 2015 06:56:23 -0700 (PDT) Received: from mail-la0-f52.google.com (mail-la0-f52.google.com. [209.85.215.52]) by mx.google.com with ESMTPS id bw10si2255604lbc.114.2015.08.27.06.56.23 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Aug 2015 06:56:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.52 as permitted sender) client-ip=209.85.215.52; Received: by laba3 with SMTP id a3so13019358lab.1 for ; Thu, 27 Aug 2015 06:56:23 -0700 (PDT) X-Received: by 10.152.44.196 with SMTP id g4mr2346790lam.56.1440683783705; Thu, 27 Aug 2015 06:56:23 -0700 (PDT) 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.162.200 with SMTP id yc8csp4662690lbb; Thu, 27 Aug 2015 06:56:22 -0700 (PDT) X-Received: by 10.50.225.35 with SMTP id rh3mr16525109igc.29.1440683781668; Thu, 27 Aug 2015 06:56:21 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l20si1982440iol.170.2015.08.27.06.56.20; Thu, 27 Aug 2015 06:56:21 -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; Received: by lists.linaro.org (Postfix, from userid 109) id 56D2F6217A; Thu, 27 Aug 2015 13:56:20 +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 ED95761FB3; Thu, 27 Aug 2015 13:56:15 +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 652A361FC0; Thu, 27 Aug 2015 13:56:13 +0000 (UTC) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com [209.85.217.172]) by lists.linaro.org (Postfix) with ESMTPS id 64C7561F90 for ; Thu, 27 Aug 2015 13:56:12 +0000 (UTC) Received: by lbbsx3 with SMTP id sx3so11912040lbb.0 for ; Thu, 27 Aug 2015 06:56:11 -0700 (PDT) X-Received: by 10.112.142.105 with SMTP id rv9mr2279376lbb.11.1440683770952; Thu, 27 Aug 2015 06:56:10 -0700 (PDT) Received: from khorivan.synapse.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id w8sm607398laj.21.2015.08.27.06.56.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Aug 2015 06:56:09 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 27 Aug 2015 16:56:01 +0300 Message-Id: <1440683761-30283-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 X-Topics: patch Subject: [lng-odp] [Patch] example: ipsec: avoid mixing scheduler wait time and wall time X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 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" X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ivan.khoronzhuk@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.52 as permitted sender) smtp.mailfrom=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 It's not correct to mix wall time and scheduler wait time, they can have different resolution. As in this function scheduler is used as poll function, so using wait time for scheduling can be avoided at all. This patch replaces callback function in order to eliminate usage of wait time. Signed-off-by: Ivan Khoronzhuk --- example/ipsec/odp_ipsec.c | 57 +++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index 104d29a..2628dfa 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -221,8 +221,7 @@ void free_pkt_ctx(pkt_ctx_t *ctx) */ typedef odp_queue_t (*queue_create_func_t) (const char *, odp_queue_type_t, odp_queue_param_t *); -typedef odp_event_t (*schedule_func_t) - (odp_queue_t *, uint64_t); +typedef odp_event_t (*schedule_func_t) (odp_queue_t *); static queue_create_func_t queue_create; static schedule_func_t schedule; @@ -259,49 +258,33 @@ odp_queue_t polled_odp_queue_create(const char *name, return my_queue; } +static inline +odp_event_t odp_schedule_cb(odp_queue_t *from) +{ + return odp_schedule(from, ODP_SCHED_WAIT); +} + /** * odp_schedule replacement to poll queues versus using ODP scheduler */ static -odp_event_t polled_odp_schedule(odp_queue_t *from, uint64_t wait) +odp_event_t polled_odp_schedule_cb(odp_queue_t *from) { - uint64_t start_cycle; - uint64_t cycle; - uint64_t diff; - - start_cycle = 0; + int idx = 0; while (1) { - int idx; + if (idx >= num_polled_queues) + idx = 0; - for (idx = 0; idx < num_polled_queues; idx++) { - odp_queue_t queue = poll_queues[idx]; - odp_event_t buf; + odp_queue_t queue = poll_queues[idx++]; + odp_event_t buf; - buf = odp_queue_deq(queue); + buf = odp_queue_deq(queue); - if (ODP_EVENT_INVALID != buf) { - *from = queue; - return buf; - } + if (ODP_EVENT_INVALID != buf) { + *from = queue; + return buf; } - - if (ODP_SCHED_WAIT == wait) - continue; - - if (ODP_SCHED_NO_WAIT == wait) - break; - - if (0 == start_cycle) { - start_cycle = odp_time_cycles(); - continue; - } - - cycle = odp_time_cycles(); - diff = odp_time_diff_cycles(start_cycle, cycle); - - if (wait < diff) - break; } *from = ODP_QUEUE_INVALID; @@ -1077,7 +1060,7 @@ void *pktio_thread(void *arg EXAMPLE_UNUSED) odp_crypto_op_result_t result; /* Use schedule to get event from any input queue */ - ev = schedule(&dispatchq, ODP_SCHED_WAIT); + ev = schedule(&dispatchq); /* Determine new work versus completion or sequence number */ if (ODP_EVENT_PACKET == odp_event_type(ev)) { @@ -1228,12 +1211,12 @@ main(int argc, char *argv[]) /* create by default scheduled queues */ queue_create = odp_queue_create; - schedule = odp_schedule; + schedule = odp_schedule_cb; /* check for using poll queues */ if (getenv("ODP_IPSEC_USE_POLL_QUEUES")) { queue_create = polled_odp_queue_create; - schedule = polled_odp_schedule; + schedule = polled_odp_schedule_cb; } /* Init ODP before calling anything else */