From patchwork Mon Aug 31 13:05:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 52890 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by patches.linaro.org (Postfix) with ESMTPS id 4FEB92127E for ; Mon, 31 Aug 2015 13:07:16 +0000 (UTC) Received: by laboe4 with SMTP id oe4sf25827933lab.3 for ; Mon, 31 Aug 2015 06:07:15 -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=nRJ/cBaxt2S/70iuFKy4ad4O85CPjA8mHgRkUwNt5uA=; b=D9NSkQyLyfEH4cKlDb/YV7cxWtSNqe4c6BkGH/+8Wg5guEEtdMPH9gkb0ISF7PCZJY HmzoTfDc0mHelMCYmNFBrEXYkzJSjHHln4xT0o70TTZj6470shbT0Mz4gGmd9/vWeNRL lD3On+oMugWLfvyszKRLj37H/lOh7Ks+0cl+/h/7KQ4ZJyID124zgj/3AHjzHpVtQ52i mfPuHAbwEmItAmaI3nDtHzL69T8x4Z86+8Knxo94DEE2djfWxwz9eOd/sP+y7TcWKD9D 4yrjll9HN51dyiG7seKNXxJopL2SWYyREFS9adelIGPSvkKiBmM1YP5DRayQ42+NPR9S nkhQ== X-Gm-Message-State: ALoCoQm/ys99aIsdjMN5RYX5BiXCDaj1yZAwQHlztOItLw4aYRvDAHuDUtbOvWSBpPSzIja0dFVL X-Received: by 10.180.83.101 with SMTP id p5mr4636482wiy.2.1441026435250; Mon, 31 Aug 2015 06:07:15 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.21.163 with SMTP id w3ls482426lae.21.gmail; Mon, 31 Aug 2015 06:07:15 -0700 (PDT) X-Received: by 10.112.129.104 with SMTP id nv8mr10183870lbb.63.1441026435098; Mon, 31 Aug 2015 06:07:15 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id rz7si13109512lbb.129.2015.08.31.06.07.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Aug 2015 06:07:15 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by lanb10 with SMTP id b10so35409824lan.2 for ; Mon, 31 Aug 2015 06:07:15 -0700 (PDT) X-Received: by 10.152.22.133 with SMTP id d5mr10161977laf.112.1441026434929; Mon, 31 Aug 2015 06:07:14 -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.151.194 with SMTP id us2csp1625223lbb; Mon, 31 Aug 2015 06:07:13 -0700 (PDT) X-Received: by 10.140.195.148 with SMTP id q142mr38115790qha.92.1441026433749; Mon, 31 Aug 2015 06:07:13 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 141si16912601qhx.82.2015.08.31.06.07.12; Mon, 31 Aug 2015 06:07:13 -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 9A9CF61833; Mon, 31 Aug 2015 13:07:12 +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 CE45B61C6A; Mon, 31 Aug 2015 13:06:24 +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 682AA619A3; Mon, 31 Aug 2015 13:06:13 +0000 (UTC) Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by lists.linaro.org (Postfix) with ESMTPS id 19CE961839 for ; Mon, 31 Aug 2015 13:06:12 +0000 (UTC) Received: by widfa3 with SMTP id fa3so24486228wid.1 for ; Mon, 31 Aug 2015 06:06:11 -0700 (PDT) X-Received: by 10.194.158.34 with SMTP id wr2mr27280971wjb.23.1441026370501; Mon, 31 Aug 2015 06:06:10 -0700 (PDT) Received: from khorivan.synapse.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id ne7sm17955341wic.12.2015.08.31.06.06.09 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 31 Aug 2015 06:06:09 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Mon, 31 Aug 2015 16:05:48 +0300 Message-Id: <1441026351-5378-2-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441026351-5378-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1441026351-5378-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [odp-lng] [Patch 1/4] 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.50 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, used timers can have different rates. As in this example scheduler is used only for poll purposes, 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 */