From patchwork Thu Jan 29 10:40:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ola Liljedahl X-Patchwork-Id: 43917 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f199.google.com (mail-lb0-f199.google.com [209.85.217.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DAC4324119 for ; Thu, 29 Jan 2015 10:42:00 +0000 (UTC) Received: by mail-lb0-f199.google.com with SMTP id f15sf17981523lbj.2 for ; Thu, 29 Jan 2015 02:41:59 -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=H6ATMGGs9hgVtuhh5AWHQQJkpREAMNT7CGp8aUYqaKE=; b=c0XpOu1kDoGY2akT1nVuW6gL6BeVQaRFbNmPiakrIYd11h3WMgULu5jgszlSnx7JZr lXi1sGEDiFuFIq3ymQJqofqW8tbyD3ZrKTzbkgTfAxy+UquiDuBY5/rtY7GoPfC4oIoj 3y4wif9BbfIqmLwiWg4BrTOFX0+zdDSzaphV8xbrYmDXNP1OYcVU75HB24A1D5j4d1ES JYQPax4em5N6VaD43XachRDSrxFd2e9v+ngr3enMMIXo1jWWcCjj8+gXkaChe8K/2rBs JAhIo3TJMHOznKnQZAg36J4L50qkYMrzzo/PrSLl6rYl82jC4z5Ega84PXtztpASXZ7I wdwA== X-Gm-Message-State: ALoCoQlkqOwJvjivKlMB3v1MxohqlKKhaNjnQ/RiOqY0ZrenqZAH+KOamLgvpndRn2czWgZMTE8E X-Received: by 10.112.167.166 with SMTP id zp6mr875620lbb.5.1422528119732; Thu, 29 Jan 2015 02:41:59 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.88.70 with SMTP id be6ls285922lab.41.gmail; Thu, 29 Jan 2015 02:41:59 -0800 (PST) X-Received: by 10.152.42.164 with SMTP id p4mr13447338lal.45.1422528119569; Thu, 29 Jan 2015 02:41:59 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id sg5si7036845lbb.19.2015.01.29.02.41.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 29 Jan 2015 02:41:59 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by mail-lb0-f178.google.com with SMTP id u10so26564254lbd.9 for ; Thu, 29 Jan 2015 02:41:59 -0800 (PST) X-Received: by 10.152.3.70 with SMTP id a6mr13430348laa.71.1422528119482; Thu, 29 Jan 2015 02:41:59 -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 h5csp1719719lbj; Thu, 29 Jan 2015 02:41:58 -0800 (PST) X-Received: by 10.229.190.6 with SMTP id dg6mr2110qcb.16.1422528118179; Thu, 29 Jan 2015 02:41:58 -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 c91si9694318qgc.92.2015.01.29.02.41.56 (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 29 Jan 2015 02:41:58 -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 1YGmXq-0007US-5f; Thu, 29 Jan 2015 10:41:54 +0000 Received: from mail-lb0-f172.google.com ([209.85.217.172]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YGmWW-0007Jl-Ea for lng-odp@lists.linaro.org; Thu, 29 Jan 2015 10:40:32 +0000 Received: by mail-lb0-f172.google.com with SMTP id l4so26615163lbv.3 for ; Thu, 29 Jan 2015 02:40:27 -0800 (PST) X-Received: by 10.112.134.74 with SMTP id pi10mr35044lbb.67.1422528026945; Thu, 29 Jan 2015 02:40:26 -0800 (PST) Received: from macmini.lan (78-82-118-111.tn.glocalnet.net. [78.82.118.111]) by mx.google.com with ESMTPSA id y11sm2037670lba.5.2015.01.29.02.40.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jan 2015 02:40:26 -0800 (PST) From: Ola Liljedahl To: lng-odp@lists.linaro.org Date: Thu, 29 Jan 2015 11:40:08 +0100 Message-Id: <1422528008-29845-17-git-send-email-ola.liljedahl@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1422528008-29845-1-git-send-email-ola.liljedahl@linaro.org> References: <1422528008-29845-1-git-send-email-ola.liljedahl@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 16/16] api: odp_queue.h: odp_queue_enq_multi() returns partial success 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: ola.liljedahl@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.178 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 Changed the definition of odp_queue_enq_multi() to support partial success (e.g. enqueued some but not all of the events specified). Returns the number of events enqueued (equivalent to odp_queue_deq_multi()). This change is necessary to support ODP implementations that use fixed size queues (e.g. ODP linux-dpdk). Updated the implementation in odp_queue.c to conform to the new semantics. Updated the necessary test/validation/performance programs. Signed-off-by: Ola Liljedahl --- (This document/code contribution attached is provided under the terms of agreement LES-LTM-21309) platform/linux-generic/include/api/odp_queue.h | 9 +++++---- platform/linux-generic/odp_packet_io.c | 4 ++-- platform/linux-generic/odp_queue.c | 4 ++-- test/performance/odp_scheduling.c | 10 +++++++--- test/validation/odp_pktio.c | 16 ++++++++++------ test/validation/odp_queue.c | 3 ++- 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/platform/linux-generic/include/api/odp_queue.h b/platform/linux-generic/include/api/odp_queue.h index 79c7e80..ab0e05e 100644 --- a/platform/linux-generic/include/api/odp_queue.h +++ b/platform/linux-generic/include/api/odp_queue.h @@ -189,12 +189,13 @@ int odp_queue_enq(odp_queue_t queue, odp_event_t ev); * Enqueue multiple events to a queue * * @param queue Queue handle - * @param ev Event handles - * @param num Number of event handles + * @param[in] events Array of event handles + * @param num Number of event handles to enqueue * - * @return 0 if succesful + * @return Number of events actually enqueued (0 ... num) + * @retval <0 on failure */ -int odp_queue_enq_multi(odp_queue_t queue, odp_event_t ev[], int num); +int odp_queue_enq_multi(odp_queue_t queue, const odp_event_t events[], int num); /** * Queue dequeue diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index 0dcd85b..57862dc 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -410,7 +410,7 @@ static int enq_loopback(pktio_entry_t *pktio_entry, odp_packet_t pkt_tbl[], hdr_tbl[i] = odp_buf_to_hdr(_odp_packet_to_buffer(pkt_tbl[i])); qentry = queue_to_qentry(pktio_entry->s.loopq); - return queue_enq_multi(qentry, hdr_tbl, len) == 0 ? len : 0; + return queue_enq_multi(qentry, hdr_tbl, len); } int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len) @@ -552,7 +552,7 @@ int pktout_enq_multi(queue_entry_t *qentry, odp_buffer_hdr_t *buf_hdr[], pkt_tbl[i] = _odp_packet_from_buffer(buf_hdr[i]->handle.handle); nbr = odp_pktio_send(qentry->s.pktout, pkt_tbl, num); - return (nbr == num ? 0 : -1); + return nbr; } int pktout_deq_multi(queue_entry_t *qentry ODP_UNUSED, diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index 17ff7c1..2f04850 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -369,7 +369,7 @@ int queue_enq_multi(queue_entry_t *queue, odp_buffer_hdr_t *buf_hdr[], int num) if (sched == 1) odp_schedule_queue(queue->s.handle, queue->s.param.sched.prio); - return 0; + return num; /* All events enqueued */ } int queue_enq_dummy(queue_entry_t *queue ODP_UNUSED, @@ -385,7 +385,7 @@ int queue_enq_multi_dummy(queue_entry_t *queue ODP_UNUSED, return -1; } -int odp_queue_enq_multi(odp_queue_t handle, odp_event_t ev[], int num) +int odp_queue_enq_multi(odp_queue_t handle, const odp_event_t ev[], int num) { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; queue_entry_t *queue; diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index fbe22b8..763258b 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -526,7 +526,9 @@ static int test_schedule_multi(const char *str, int thr, ev[j] = odp_buffer_to_event(buf); } - if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX)) { + /* Assume we can enqueue all events */ + if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX) != + MULTI_BUFS_MAX) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); return -1; } @@ -541,7 +543,8 @@ static int test_schedule_multi(const char *str, int thr, tot += num; - if (odp_queue_enq_multi(queue, ev, num)) { + /* Assume we can enqueue all events */ + if (odp_queue_enq_multi(queue, ev, num) != num) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); return -1; } @@ -559,7 +562,8 @@ static int test_schedule_multi(const char *str, int thr, tot += num; - if (odp_queue_enq_multi(queue, ev, num)) { + /* Assume we can enqueue all events */ + if (odp_queue_enq_multi(queue, ev, num) != num) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); return -1; } diff --git a/test/validation/odp_pktio.c b/test/validation/odp_pktio.c index 46155fd..dc39c0e 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -330,14 +330,18 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, } /* send packet(s) out */ - if (num_pkts == 1) + if (num_pkts == 1) { ret = odp_queue_enq(pktio_a->outq, tx_ev[0]); - else + if (ret != 0) { + CU_FAIL("failed to enqueue test packet"); + return; + } + } else { ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts); - - if (ret != 0) { - CU_FAIL("failed to enqueue test packets"); - return; + if (ret != num_pkts) { + CU_FAIL("failed to enqueue test packets"); + return; + } } /* and wait for them to arrive back */ diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c index 198b4e2..91a32dc 100644 --- a/test/validation/odp_queue.c +++ b/test/validation/odp_queue.c @@ -83,9 +83,10 @@ static void test_odp_queue_sunnyday(void) /* * odp_queue_enq_multi may return 0..n buffers due to the resource * constraints in the implementation at that given point of time. + * But here we assume that we succeed in enqueuing all buffers. */ ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE); - CU_ASSERT(0 == ret); + CU_ASSERT(MAX_BUFFER_QUEUE == ret); pev_tmp = deev; do { deq_ret = odp_queue_deq_multi(queue_id, pev_tmp,