From patchwork Mon Jan 26 13:05:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43756 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f200.google.com (mail-lb0-f200.google.com [209.85.217.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 92F8323FFF for ; Mon, 26 Jan 2015 13:08:17 +0000 (UTC) Received: by mail-lb0-f200.google.com with SMTP id u10sf4200169lbd.3 for ; Mon, 26 Jan 2015 05:08:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state: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=PwLJvoiYhC9OWGlw0oXm1bjW6awWX6snq/vKzsLN3fA=; b=DAbZA2ShCGmMfVity0GHyYoiLgP5x4z0nTJdHovT2Gvg87XHiu6LsolYzLgP/vDdb4 fYI2s4LDs67UfEs021z7uYspIsKWhDaPAJL8XPCID8Szz8eq0Un7XFvMJX7ON5eLeCnb MHPr/cJJUJWWm6ABronqx1ZRLQgnfADelPf0mMHCpHB1KTFMr3w4DKno7hZAP40ImsoJ SK6Sq9dxqg7VdwZVyNhB0U157CpbLgNVBnhwYxd/QTaElcD8k8UW+f0RPE1oREducV/C 9S7dqLKQesHUJMYgOKevqvLXClOkABW+Cdl0M7aWKOgLSWV00tKfsVKs1eBOEGYbxGup zegQ== X-Gm-Message-State: ALoCoQkXNasOztPwhYt7ogM6e7JPFfIhRN7JCfmG5ynrLJta34jWm3o6hhOB7iCasSJZm6khcqML X-Received: by 10.112.137.70 with SMTP id qg6mr1246653lbb.14.1422277696521; Mon, 26 Jan 2015 05:08:16 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.7.42 with SMTP id g10ls108127laa.51.gmail; Mon, 26 Jan 2015 05:08:16 -0800 (PST) X-Received: by 10.152.234.35 with SMTP id ub3mr21199534lac.70.1422277696301; Mon, 26 Jan 2015 05:08:16 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id y4si8960732lbn.81.2015.01.26.05.08.16 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 05:08:16 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id l4so7444453lbv.3 for ; Mon, 26 Jan 2015 05:08:16 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr21066761lal.29.1422277696162; Mon, 26 Jan 2015 05:08:16 -0800 (PST) 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.35.133 with SMTP id h5csp774606lbj; Mon, 26 Jan 2015 05:08:15 -0800 (PST) X-Received: by 10.229.249.137 with SMTP id mk9mr41087867qcb.4.1422277694847; Mon, 26 Jan 2015 05:08:14 -0800 (PST) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id j13si13065875qaa.61.2015.01.26.05.08.13 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 26 Jan 2015 05:08:14 -0800 (PST) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YFjOl-0005DZ-L8; Mon, 26 Jan 2015 13:08:11 +0000 Received: from mail-qa0-f52.google.com ([209.85.216.52]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YFjNX-0004pw-1S for lng-odp@lists.linaro.org; Mon, 26 Jan 2015 13:06:55 +0000 Received: by mail-qa0-f52.google.com with SMTP id x12so6500959qac.11 for ; Mon, 26 Jan 2015 05:06:49 -0800 (PST) X-Received: by 10.224.120.130 with SMTP id d2mr35409349qar.81.1422277609896; Mon, 26 Jan 2015 05:06:49 -0800 (PST) Received: from mcpro03.emea.nsn-net.net (ec2-23-23-178-99.compute-1.amazonaws.com. [23.23.178.99]) by mx.google.com with ESMTPSA id a1sm4972929qab.28.2015.01.26.05.06.47 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 26 Jan 2015 05:06:49 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Mon, 26 Jan 2015 15:05:51 +0200 Message-Id: <1422277551-16417-18-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422277551-16417-1-git-send-email-petri.savolainen@linaro.org> References: <1422277551-16417-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v5 17/17] linux-generic: scheduler: Use events instead of buffers X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 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-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: petri.savolainen@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.217.172 as permitted sender) smtp.mail=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 Signed-off-by: Petri Savolainen --- platform/linux-generic/odp_schedule.c | 49 ++++++++++++++++------------------- 1 file changed, 23 insertions(+), 26 deletions(-) diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index 4cb82b3..58561a9 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -55,10 +55,10 @@ typedef struct { } queue_desc_t; typedef struct { - odp_queue_t pri_queue; - odp_buffer_t desc_buf; + odp_queue_t pri_queue; + odp_event_t desc_ev; - odp_buffer_t buf[MAX_DEQ]; + odp_event_t ev[MAX_DEQ]; int num; int index; odp_queue_t queue; @@ -150,10 +150,10 @@ int odp_schedule_init_local(void) int i; sched_local.pri_queue = ODP_QUEUE_INVALID; - sched_local.desc_buf = ODP_BUFFER_INVALID; + sched_local.desc_ev = ODP_EVENT_INVALID; for (i = 0; i < MAX_DEQ; i++) - sched_local.buf[i] = ODP_BUFFER_INVALID; + sched_local.ev[i] = ODP_EVENT_INVALID; sched_local.num = 0; sched_local.index = 0; @@ -207,19 +207,18 @@ void odp_schedule_release_atomic(void) if (sched_local.pri_queue != ODP_QUEUE_INVALID && sched_local.num == 0) { /* Release current atomic queue */ - odp_queue_enq(sched_local.pri_queue, - odp_buffer_to_event(sched_local.desc_buf)); + odp_queue_enq(sched_local.pri_queue, sched_local.desc_ev); sched_local.pri_queue = ODP_QUEUE_INVALID; } } -static inline int copy_bufs(odp_buffer_t out_buf[], unsigned int max) +static inline int copy_events(odp_event_t out_ev[], unsigned int max) { int i = 0; while (sched_local.num && max) { - out_buf[i] = sched_local.buf[sched_local.index]; + out_ev[i] = sched_local.ev[sched_local.index]; sched_local.index++; sched_local.num--; max--; @@ -235,7 +234,7 @@ static inline int copy_bufs(odp_buffer_t out_buf[], unsigned int max) * * TODO: SYNC_ORDERED not implemented yet */ -static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], +static int schedule(odp_queue_t *out_queue, odp_event_t out_ev[], unsigned int max_num, unsigned int max_deq) { int i, j; @@ -243,7 +242,7 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], int ret; if (sched_local.num) { - ret = copy_bufs(out_buf, max_num); + ret = copy_events(out_ev, max_num); if (out_queue) *out_queue = sched_local.queue; @@ -294,8 +293,7 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], !queue_is_sched(queue)) continue; - num = odp_queue_deq_multi(queue, - (odp_event_t *)sched_local.buf, + num = odp_queue_deq_multi(queue, sched_local.ev, max_deq); if (num == 0) { @@ -305,24 +303,24 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], if (odp_queue_type(queue) == ODP_QUEUE_TYPE_PKTIN && !queue_is_destroyed(queue)) - odp_queue_enq(pri_q, odp_buffer_to_event(desc_buf)); + odp_queue_enq(pri_q, ev); continue; } sched_local.num = num; sched_local.index = 0; - ret = copy_bufs(out_buf, max_num); + ret = copy_events(out_ev, max_num); sched_local.queue = queue; if (queue_sched_atomic(queue)) { /* Hold queue during atomic access */ sched_local.pri_queue = pri_q; - sched_local.desc_buf = desc_buf; + sched_local.desc_ev = ev; } else { /* Continue scheduling the queue */ - odp_queue_enq(pri_q, odp_buffer_to_event(desc_buf)); + odp_queue_enq(pri_q, ev); } /* Output the source queue handle */ @@ -339,8 +337,8 @@ static int schedule(odp_queue_t *out_queue, odp_buffer_t out_buf[], static int schedule_loop(odp_queue_t *out_queue, uint64_t wait, - odp_buffer_t out_buf[], - unsigned int max_num, unsigned int max_deq) + odp_event_t out_ev[], + unsigned int max_num, unsigned int max_deq) { uint64_t start_cycle, cycle, diff; int ret; @@ -348,7 +346,7 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t wait, start_cycle = 0; while (1) { - ret = schedule(out_queue, out_buf, max_num, max_deq); + ret = schedule(out_queue, out_ev, max_num, max_deq); if (ret) break; @@ -377,21 +375,20 @@ static int schedule_loop(odp_queue_t *out_queue, uint64_t wait, odp_event_t odp_schedule(odp_queue_t *out_queue, uint64_t wait) { - odp_buffer_t buf; + odp_event_t ev; - buf = ODP_BUFFER_INVALID; + ev = ODP_EVENT_INVALID; - schedule_loop(out_queue, wait, &buf, 1, MAX_DEQ); + schedule_loop(out_queue, wait, &ev, 1, MAX_DEQ); - return odp_buffer_to_event(buf); + return ev; } int odp_schedule_multi(odp_queue_t *out_queue, uint64_t wait, odp_event_t events[], unsigned int num) { - return schedule_loop(out_queue, wait, - (odp_buffer_t *)events, num, MAX_DEQ); + return schedule_loop(out_queue, wait, events, num, MAX_DEQ); }