From patchwork Fri Jan 23 11:42:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petri Savolainen X-Patchwork-Id: 43613 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f72.google.com (mail-ee0-f72.google.com [74.125.83.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 91C5D240D9 for ; Fri, 23 Jan 2015 11:43:22 +0000 (UTC) Received: by mail-ee0-f72.google.com with SMTP id e49sf4525807eek.3 for ; Fri, 23 Jan 2015 03:43:21 -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=L8eb+w0jYjqDy/hMzU+sVWjsNezpu5yf+ZRAVYD0sX4=; b=mgKmKHCM6qrwkTwlIhus4WAcHkKl3DJglwGLpB2AJgJgigiOurbGjr6lSia9qHYMuu +wPFG/oemToh203lrZ24JgKbLfHS0uVQWVr1vds4b7I6rvpU6AwrPI8I3CkdzKR+91Vw 3UKGxe3RLQuWgnRRUY5ZQ7UbzYKfcE7ez+fmhyDtHoHtJoY5BkckQf5JlKksdS7uw0RB +qLKS2rt7QVUYJ5UQncy/m8LouXS8PsZ6HsWYj/URIpqDUjS9bCrRbnGe34B6RFwUlQw tow0yM9GmSiTpUOFR89mpkC7GpBK5hgs6Xa+/Pv4K3x6FM1x3IAlVsHTgYdemR9A3a1g Xwqw== X-Gm-Message-State: ALoCoQmMbGUCfaG7LxVGQ81fzNlp0jxe0xvKOsMp3t0PfkqkHvpenyQkrvGv22L1jSRzFQm8/zUy X-Received: by 10.194.204.201 with SMTP id la9mr25423wjc.6.1422013401837; Fri, 23 Jan 2015 03:43:21 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.182.172 with SMTP id ef12ls253670lac.104.gmail; Fri, 23 Jan 2015 03:43:21 -0800 (PST) X-Received: by 10.152.7.180 with SMTP id k20mr7020678laa.4.1422013401602; Fri, 23 Jan 2015 03:43:21 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id t9si1108238laj.101.2015.01.23.03.43.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 03:43:21 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so6571361lbv.8 for ; Fri, 23 Jan 2015 03:43:21 -0800 (PST) X-Received: by 10.152.7.229 with SMTP id m5mr6879155laa.80.1422013401482; Fri, 23 Jan 2015 03:43:21 -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.9.200 with SMTP id c8csp220828lbb; Fri, 23 Jan 2015 03:43:20 -0800 (PST) X-Received: by 10.140.91.74 with SMTP id y68mr12260364qgd.90.1422013399749; Fri, 23 Jan 2015 03:43:19 -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 1si1605378qam.65.2015.01.23.03.43.18 (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 03:43:19 -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 1YEcdw-0003Nj-CH; Fri, 23 Jan 2015 11:43:16 +0000 Received: from mail-qa0-f47.google.com ([209.85.216.47]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1YEcdi-0003LV-Ca for lng-odp@lists.linaro.org; Fri, 23 Jan 2015 11:43:02 +0000 Received: by mail-qa0-f47.google.com with SMTP id n8so5385699qaq.6 for ; Fri, 23 Jan 2015 03:42:57 -0800 (PST) X-Received: by 10.140.90.112 with SMTP id w103mr12099796qgd.65.1422013377194; Fri, 23 Jan 2015 03:42:57 -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 f7sm1182892qaq.42.2015.01.23.03.42.55 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 03:42:56 -0800 (PST) From: Petri Savolainen To: lng-odp@lists.linaro.org Date: Fri, 23 Jan 2015 13:42:11 +0200 Message-Id: <1422013344-6655-4-git-send-email-petri.savolainen@linaro.org> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422013344-6655-1-git-send-email-petri.savolainen@linaro.org> References: <1422013344-6655-1-git-send-email-petri.savolainen@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH v4 03/16] api: event: schedule_multi and queue_enq_multi 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.177 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 odp_schedule_multi() and odp_queue_enq_multi() to use events instead of buffers. Signed-off-by: Petri Savolainen --- platform/linux-generic/include/api/odp_queue.h | 8 ++++---- platform/linux-generic/include/api/odp_schedule.h | 16 ++++++++-------- platform/linux-generic/odp_queue.c | 4 ++-- platform/linux-generic/odp_schedule.c | 5 +++-- test/performance/odp_scheduling.c | 22 +++++++++++++--------- test/validation/odp_pktio.c | 9 ++++----- test/validation/odp_queue.c | 16 ++++++++++------ test/validation/odp_schedule.c | 12 +++++++----- 8 files changed, 51 insertions(+), 41 deletions(-) diff --git a/platform/linux-generic/include/api/odp_queue.h b/platform/linux-generic/include/api/odp_queue.h index 3caa7c1..61afd36 100644 --- a/platform/linux-generic/include/api/odp_queue.h +++ b/platform/linux-generic/include/api/odp_queue.h @@ -181,15 +181,15 @@ void *odp_queue_get_context(odp_queue_t queue); int odp_queue_enq(odp_queue_t queue, odp_event_t ev); /** - * Enqueue multiple buffers to a queue + * Enqueue multiple events to a queue * * @param queue Queue handle - * @param buf Buffer handles - * @param num Number of buffer handles + * @param ev Event handles + * @param num Number of event handles * * @return 0 if succesful */ -int odp_queue_enq_multi(odp_queue_t queue, odp_buffer_t buf[], int num); +int odp_queue_enq_multi(odp_queue_t queue, odp_event_t ev[], int num); /** * Queue dequeue diff --git a/platform/linux-generic/include/api/odp_schedule.h b/platform/linux-generic/include/api/odp_schedule.h index 45fa48c..688a6db 100644 --- a/platform/linux-generic/include/api/odp_schedule.h +++ b/platform/linux-generic/include/api/odp_schedule.h @@ -64,22 +64,22 @@ uint64_t odp_schedule_wait_time(uint64_t ns); odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait); /** - * Schedule multiple buffers + * Schedule multiple events * - * Like odp_schedule(), but returns multiple buffers from a queue. + * Like odp_schedule(), but returns multiple events from a queue. * - * @param from Output parameter for the source queue (where the buffer was + * @param from Output parameter for the source queue (where the event was * dequeued from). Ignored if NULL. - * @param wait Minimum time to wait for a buffer. Waits infinitely, if set to + * @param wait Minimum time to wait for an event. Waits infinitely, if set to * ODP_SCHED_WAIT. Does not wait, if set to ODP_SCHED_NO_WAIT. * Use odp_schedule_wait_time() to convert time to other wait * values. - * @param out_buf Buffer array for output - * @param num Maximum number of buffers to output + * @param events Event array for output + * @param num Maximum number of events to output * - * @return Number of buffers outputed (0 ... num) + * @return Number of events outputed (0 ... num) */ -int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_buffer_t out_buf[], +int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[], unsigned int num); /** diff --git a/platform/linux-generic/odp_queue.c b/platform/linux-generic/odp_queue.c index c027f23..f3046e2 100644 --- a/platform/linux-generic/odp_queue.c +++ b/platform/linux-generic/odp_queue.c @@ -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_buffer_t buf[], int num) +int odp_queue_enq_multi(odp_queue_t handle, odp_event_t ev[], int num) { odp_buffer_hdr_t *buf_hdr[QUEUE_MULTI_MAX]; queue_entry_t *queue; @@ -397,7 +397,7 @@ int odp_queue_enq_multi(odp_queue_t handle, odp_buffer_t buf[], int num) queue = queue_to_qentry(handle); for (i = 0; i < num; i++) - buf_hdr[i] = odp_buf_to_hdr(buf[i]); + buf_hdr[i] = odp_buf_to_hdr(odp_buffer_from_event(ev[i])); return queue->s.enqueue_multi(queue, buf_hdr, num); } diff --git a/platform/linux-generic/odp_schedule.c b/platform/linux-generic/odp_schedule.c index ff68b07..1654364 100644 --- a/platform/linux-generic/odp_schedule.c +++ b/platform/linux-generic/odp_schedule.c @@ -381,9 +381,10 @@ odp_event_t odp_schedule(odp_queue_t *out_queue, uint64_t wait) int odp_schedule_multi(odp_queue_t *out_queue, uint64_t wait, - odp_buffer_t out_buf[], unsigned int num) + odp_event_t events[], unsigned int num) { - return schedule_loop(out_queue, wait, out_buf, num, MAX_DEQ); + return schedule_loop(out_queue, wait, + (odp_buffer_t *)events, num, MAX_DEQ); } diff --git a/test/performance/odp_scheduling.c b/test/performance/odp_scheduling.c index 09f5db1..7a48eed 100644 --- a/test/performance/odp_scheduling.c +++ b/test/performance/odp_scheduling.c @@ -481,7 +481,7 @@ static int test_schedule_multi(const char *str, int thr, odp_buffer_pool_t msg_pool, int prio, odp_barrier_t *barrier) { - odp_buffer_t buf[MULTI_BUFS_MAX]; + odp_event_t ev[MULTI_BUFS_MAX]; odp_queue_t queue; uint64_t t1 = 0; uint64_t t2 = 0; @@ -508,16 +508,20 @@ static int test_schedule_multi(const char *str, int thr, } for (j = 0; j < MULTI_BUFS_MAX; j++) { - buf[j] = odp_buffer_alloc(msg_pool); + odp_buffer_t buf; - if (!odp_buffer_is_valid(buf[j])) { + buf = odp_buffer_alloc(msg_pool); + + if (!odp_buffer_is_valid(buf)) { LOG_ERR(" [%i] msg_pool alloc failed\n", thr); return -1; } + + ev[j] = odp_buffer_to_event(buf); } - if (odp_queue_enq_multi(queue, buf, MULTI_BUFS_MAX)) { + if (odp_queue_enq_multi(queue, ev, MULTI_BUFS_MAX)) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); return -1; } @@ -527,22 +531,22 @@ static int test_schedule_multi(const char *str, int thr, t1 = odp_time_cycles(); for (i = 0; i < QUEUE_ROUNDS; i++) { - num = odp_schedule_multi(&queue, ODP_SCHED_WAIT, buf, + num = odp_schedule_multi(&queue, ODP_SCHED_WAIT, ev, MULTI_BUFS_MAX); tot += num; - if (odp_queue_enq_multi(queue, buf, num)) { + if (odp_queue_enq_multi(queue, ev, num)) { LOG_ERR(" [%i] Queue enqueue failed.\n", thr); return -1; } } - /* Clear possible locally stored buffers */ + /* Clear possible locally stored events */ odp_schedule_pause(); while (1) { - num = odp_schedule_multi(&queue, ODP_SCHED_NO_WAIT, buf, + num = odp_schedule_multi(&queue, ODP_SCHED_NO_WAIT, ev, MULTI_BUFS_MAX); if (num == 0) @@ -550,7 +554,7 @@ static int test_schedule_multi(const char *str, int thr, tot += num; - if (odp_queue_enq_multi(queue, buf, num)) { + if (odp_queue_enq_multi(queue, ev, 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 9c5ca2a..16e85fa 100644 --- a/test/validation/odp_pktio.c +++ b/test/validation/odp_pktio.c @@ -300,7 +300,7 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, int num_pkts) { odp_packet_t tx_pkt[num_pkts]; - odp_buffer_t tx_buf[num_pkts]; + odp_event_t tx_ev[num_pkts]; odp_packet_t rx_pkt; uint32_t tx_seq[num_pkts]; int i, ret; @@ -319,7 +319,7 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, if (pktio_fixup_checksums(tx_pkt[i]) != 0) break; - tx_buf[i] = odp_packet_to_buffer(tx_pkt[i]); + tx_ev[i] = odp_packet_to_event(tx_pkt[i]); } if (i != num_pkts) { @@ -329,10 +329,9 @@ static void pktio_txrx_multi(pktio_info_t *pktio_a, pktio_info_t *pktio_b, /* send packet(s) out */ if (num_pkts == 1) - ret = odp_queue_enq(pktio_a->outq, - odp_buffer_to_event(tx_buf[0])); + ret = odp_queue_enq(pktio_a->outq, tx_ev[0]); else - ret = odp_queue_enq_multi(pktio_a->outq, tx_buf, num_pkts); + ret = odp_queue_enq_multi(pktio_a->outq, tx_ev, num_pkts); if (ret != 0) { CU_FAIL("failed to enqueue test packets"); diff --git a/test/validation/odp_queue.c b/test/validation/odp_queue.c index a083c26..7c5e8dd 100644 --- a/test/validation/odp_queue.c +++ b/test/validation/odp_queue.c @@ -35,7 +35,8 @@ static int init_queue_suite(void) static void test_odp_queue_sunnyday(void) { odp_queue_t queue_creat_id, queue_id; - odp_buffer_t enbuf[MAX_BUFFER_QUEUE], debuf[MAX_BUFFER_QUEUE]; + odp_event_t enev[MAX_BUFFER_QUEUE]; + odp_buffer_t debuf[MAX_BUFFER_QUEUE]; odp_buffer_t buf; odp_buffer_pool_t msg_pool; odp_queue_param_t param; @@ -72,14 +73,16 @@ static void test_odp_queue_sunnyday(void) CU_ASSERT_EQUAL(buf, odp_queue_deq(queue_id)); odp_buffer_free(buf); - for (i = 0; i < MAX_BUFFER_QUEUE; i++) - enbuf[i] = odp_buffer_alloc(msg_pool); + for (i = 0; i < MAX_BUFFER_QUEUE; i++) { + odp_buffer_t buf = odp_buffer_alloc(msg_pool); + enev[i] = odp_buffer_to_event(buf); + } /* * odp_queue_enq_multi may return 0..n buffers due to the resource * constraints in the implementation at that given point of time. */ - ret = odp_queue_enq_multi(queue_id, enbuf, MAX_BUFFER_QUEUE); + ret = odp_queue_enq_multi(queue_id, enev, MAX_BUFFER_QUEUE); CU_ASSERT(0 == ret); pbuf_tmp = debuf; do { @@ -92,8 +95,9 @@ static void test_odp_queue_sunnyday(void) } while (nr_deq_entries < MAX_BUFFER_QUEUE); for (i = 0; i < MAX_BUFFER_QUEUE; i++) { - CU_ASSERT_EQUAL(enbuf[i], debuf[i]); - odp_buffer_free(enbuf[i]); + odp_buffer_t enbuf = odp_buffer_from_event(enev[i]); + CU_ASSERT_EQUAL(enbuf, debuf[i]); + odp_buffer_free(enbuf); } return; diff --git a/test/validation/odp_schedule.c b/test/validation/odp_schedule.c index 7a9fd1f..7ea0863 100644 --- a/test/validation/odp_schedule.c +++ b/test/validation/odp_schedule.c @@ -119,16 +119,18 @@ static void *schedule_common_(void *arg) odp_ticketlock_unlock(&globals->count_lock); if (args->enable_schd_multi) { - odp_buffer_t bufs[BURST_BUF_SIZE]; + odp_event_t events[BURST_BUF_SIZE]; int j; - num = odp_schedule_multi(&from, ODP_SCHED_NO_WAIT, bufs, - BURST_BUF_SIZE); + num = odp_schedule_multi(&from, ODP_SCHED_NO_WAIT, + events, BURST_BUF_SIZE); CU_ASSERT(num >= 0); CU_ASSERT(num <= BURST_BUF_SIZE); if (num == 0) continue; - for (j = 0; j < num; j++) - odp_buffer_free(bufs[j]); + for (j = 0; j < num; j++) { + buf = odp_buffer_from_event(events[j]); + odp_buffer_free(buf); + } } else { ev = odp_schedule(&from, ODP_SCHED_NO_WAIT); buf = odp_buffer_from_event(ev);