From patchwork Thu Sep 17 08:31:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 53776 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by patches.linaro.org (Postfix) with ESMTPS id 4234122E57 for ; Thu, 17 Sep 2015 08:33:49 +0000 (UTC) Received: by lamf6 with SMTP id f6sf4051897lam.1 for ; Thu, 17 Sep 2015 01:33: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:delivered-to: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=okerkeKiobHndYvXTi+j4Q42pNq/bW1PmsL3uvcuSck=; b=JOSC5RK3fcjBUeaVrf3YoWk/yeuKQS2/SDq4A2bILGJsDPQQIvvcAaF2pFYwV4PIJ7 tbgVfd0/coPT7wJ3henRGa7bKDMFuIwJJcaAs76vY+4hvL9D+PMfLsT4kWhg+ngKE0fH G4KcaNoXYOYggER9gzKCy81kuRbmaziskZyplT5nR/rK6FqqzyuSHF+coYh/c3KFytNi 6F5b3EI6boAPkGrtfDQ/FStx+815ra6BHk63TpFr8uXp8tWjnyLu8oLBbBzVDaNo2d0J zMsM1RTojG30vzJy4z43aMSKsMGURQizYQ8r92mrwxOmUyCc0aCmOpFka2Yfw5LStMQk UTxg== X-Gm-Message-State: ALoCoQlONhjXNrwHTaONmgbRXP+5osi/qZi+/G0Td7JOrhJSwTd+KzzgHQzk2qN/0rwSzTVfw179 X-Received: by 10.112.151.9 with SMTP id um9mr3755366lbb.19.1442478828216; Thu, 17 Sep 2015 01:33:48 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.30.97 with SMTP id r1ls48438lah.95.gmail; Thu, 17 Sep 2015 01:33:48 -0700 (PDT) X-Received: by 10.112.171.69 with SMTP id as5mr34110888lbc.111.1442478828060; Thu, 17 Sep 2015 01:33:48 -0700 (PDT) Received: from mail-la0-f48.google.com (mail-la0-f48.google.com. [209.85.215.48]) by mx.google.com with ESMTPS id qv2si1377692lbb.0.2015.09.17.01.33.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2015 01:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.48 as permitted sender) client-ip=209.85.215.48; Received: by lamp12 with SMTP id p12so6541465lam.0 for ; Thu, 17 Sep 2015 01:33:47 -0700 (PDT) X-Received: by 10.152.28.9 with SMTP id x9mr25857854lag.73.1442478827654; Thu, 17 Sep 2015 01:33:47 -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.59.35 with SMTP id w3csp2926197lbq; Thu, 17 Sep 2015 01:33:46 -0700 (PDT) X-Received: by 10.50.1.44 with SMTP id 12mr22227188igj.61.1442478826630; Thu, 17 Sep 2015 01:33:46 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id l4si1545635igx.27.2015.09.17.01.33.21; Thu, 17 Sep 2015 01:33:46 -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 9DE7562D47; Thu, 17 Sep 2015 08:33:21 +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_H3, RCVD_IN_MSPIKE_WL, 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 C3AA862D4B; Thu, 17 Sep 2015 08:32:21 +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 1A75762D48; Thu, 17 Sep 2015 08:32:09 +0000 (UTC) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by lists.linaro.org (Postfix) with ESMTPS id F0A2062C3E for ; Thu, 17 Sep 2015 08:31:40 +0000 (UTC) Received: by wicfx3 with SMTP id fx3so13278048wic.1 for ; Thu, 17 Sep 2015 01:31:40 -0700 (PDT) X-Received: by 10.194.187.144 with SMTP id fs16mr53369927wjc.31.1442478700207; Thu, 17 Sep 2015 01:31:40 -0700 (PDT) Received: from localhost.localdomain ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id s16sm8743445wik.13.2015.09.17.01.31.39 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Sep 2015 01:31:39 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Thu, 17 Sep 2015 11:31:28 +0300 Message-Id: <1442478691-30098-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1442478691-30098-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1442478691-30098-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v3 2/5] example: ipsec: avoid mixing of scheduler wait time and time API 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.48 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 time API time and scheduler wait time, used timers can have different rates. As in this example scheduler is used only for polling till event, using wait time for scheduling can be avoided at all. This patch replaces callback function on function w/o wait time, and doesn't add any functional changes. 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 96effe2..564d65e 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; @@ -1095,7 +1078,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)) { @@ -1246,12 +1229,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 */