From patchwork Fri Sep 11 10:04:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 53434 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f69.google.com (mail-la0-f69.google.com [209.85.215.69]) by patches.linaro.org (Postfix) with ESMTPS id 1ADFF215BF for ; Fri, 11 Sep 2015 10:09:50 +0000 (UTC) Received: by ladx5 with SMTP id x5sf7666866lad.1 for ; Fri, 11 Sep 2015 03:09:49 -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=c7uQDvhBfvHbPLz+goe7UoQaSuf3KxyF98M1KJWpoH7nvynlHeHGx3tKuNiSXSv+lL pAk1Q4MVAgQvInarLxpuQrU9+LqI8Ywx70aErtMOJDFy6Qy7z+KK/veeYqE5C7mpe57V xFI3FPmlCTLmeGgFzd3JWa1mMp7hnZXMuX+yC9UUvoJytvD/2o5bwzt/YTBOZa2ldxPR Qclu8fT5KoSiPYQf/VPatMp6ayWdnUWMT3eVVC8FYqVvydRCJcQNebz0scVFgcau9H/p XPsJOmtcdEG9dOc5ndirrE7XXq+bzyOXZgGs0cHobTVtFaGZU9DiXyiYI82+pUQv0Wxz 5w8w== X-Gm-Message-State: ALoCoQm3maQKR7AEzIIWCgNDpwr9eOl21MkUH9ge0jqqfPS+zBk1oVSViMliIRF2o3MXI0lpBH3o X-Received: by 10.112.139.65 with SMTP id qw1mr11010357lbb.24.1441966189062; Fri, 11 Sep 2015 03:09:49 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.3.194 with SMTP id e2ls330360lae.49.gmail; Fri, 11 Sep 2015 03:09:48 -0700 (PDT) X-Received: by 10.112.210.6 with SMTP id mq6mr40699169lbc.83.1441966188910; Fri, 11 Sep 2015 03:09:48 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id e7si529359lbc.62.2015.09.11.03.09.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2015 03:09:48 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagj9 with SMTP id j9so45492461lag.2 for ; Fri, 11 Sep 2015 03:09:48 -0700 (PDT) X-Received: by 10.152.5.133 with SMTP id s5mr18851643las.19.1441966188782; Fri, 11 Sep 2015 03:09:48 -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 w3csp1486017lbq; Fri, 11 Sep 2015 03:09:47 -0700 (PDT) X-Received: by 10.55.21.40 with SMTP id f40mr60892935qkh.57.1441966187770; Fri, 11 Sep 2015 03:09:47 -0700 (PDT) Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id f73si541412qkh.55.2015.09.11.03.09.46; Fri, 11 Sep 2015 03:09:47 -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 D234461995; Fri, 11 Sep 2015 10:09:46 +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 9B4BF61BC3; Fri, 11 Sep 2015 10:08:20 +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 0A09061BBE; Fri, 11 Sep 2015 10:08:11 +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 ECF4D61985 for ; Fri, 11 Sep 2015 10:05:37 +0000 (UTC) Received: by wicgb1 with SMTP id gb1so56192820wic.1 for ; Fri, 11 Sep 2015 03:05:37 -0700 (PDT) X-Received: by 10.194.95.136 with SMTP id dk8mr920980wjb.60.1441965937187; Fri, 11 Sep 2015 03:05:37 -0700 (PDT) Received: from khorivan.synapse.com ([195.238.92.128]) by smtp.gmail.com with ESMTPSA id ww8sm987313wjb.4.2015.09.11.03.05.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Sep 2015 03:05:36 -0700 (PDT) From: Ivan Khoronzhuk To: lng-odp@lists.linaro.org Date: Fri, 11 Sep 2015 13:04:46 +0300 Message-Id: <1441965889-15727-3-git-send-email-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1441965889-15727-1-git-send-email-ivan.khoronzhuk@linaro.org> References: <1441965889-15727-1-git-send-email-ivan.khoronzhuk@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v2 2/5] 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.49 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 */