From patchwork Tue Mar 14 11:14:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bogdan Pricope X-Patchwork-Id: 95283 Delivered-To: patch@linaro.org Received: by 10.140.89.134 with SMTP id v6csp208889qgd; Tue, 14 Mar 2017 04:15:37 -0700 (PDT) X-Received: by 10.107.157.146 with SMTP id g140mr30306023ioe.63.1489490137317; Tue, 14 Mar 2017 04:15:37 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id x99si13784825ioi.70.2017.03.14.04.15.36; Tue, 14 Mar 2017 04:15:37 -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; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id C992763533; Tue, 14 Mar 2017 11:15:36 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 033026352A; Tue, 14 Mar 2017 11:14:59 +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 11F5663526; Tue, 14 Mar 2017 11:14:55 +0000 (UTC) Received: from mail-wm0-f46.google.com (mail-wm0-f46.google.com [74.125.82.46]) by lists.linaro.org (Postfix) with ESMTPS id 5511760F2A for ; Tue, 14 Mar 2017 11:14:22 +0000 (UTC) Received: by mail-wm0-f46.google.com with SMTP id t189so60995346wmt.1 for ; Tue, 14 Mar 2017 04:14:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=DV9350ORQa+M3+ak9H4bszhj1QHs5GICj7NMyaWF/Io=; b=aOYuz06wsFZXL34JQZHWa6EpfRPTyfH6Dt46vpPqJ0Y44bG3M5RGJmiofA1Zc4DXQi JweXmisvhRDirtD8HjR5e5zTrDyet7vZelWEQPpQdYC97PTiceb6I6jA0JEaOiU8+c26 yUBfr/Ulqhdn3TitgmbvKn5LHbqxnZUZ3HYi9YsXNZp2/h2LHkFbXyiGKqZKy6bSm/6A ULcCdk8oJ1BGKnbqouJmCw9AvIFgj1mwCbDCfscZXwdDsX3Jr1Q3qFIWuwDZsvauo1JK lBYq+92KMPrdKq0L+1E7/Gff1ImLcbQCngCXL2i6xzBE3iuQX3k1hBjAKUobwdktAo/s gvHQ== X-Gm-Message-State: AFeK/H2kWVyktbyryOn3AEdNLTFNwPPrTB+K7GxtZXgOdKDGXGMb7kjf7FiziQHJfb0/cXUttUY= X-Received: by 10.28.137.211 with SMTP id l202mr13847722wmd.118.1489490061432; Tue, 14 Mar 2017 04:14:21 -0700 (PDT) Received: from netbricks-team.enea.se ([193.202.22.66]) by smtp.gmail.com with ESMTPSA id y49sm28662657wry.18.2017.03.14.04.14.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Mar 2017 04:14:20 -0700 (PDT) From: Bogdan Pricope To: lng-odp@lists.linaro.org Date: Tue, 14 Mar 2017 13:14:18 +0200 Message-Id: <1489490058-24397-1-git-send-email-bogdan.pricope@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [PATCHv2 3/5] test: generator: receive packets in bursts X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Bogdan Pricope --- example/generator/odp_generator.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) -- 1.9.1 diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 2d95ba8..e14c62f 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -27,6 +27,7 @@ #define POOL_PKT_LEN 1856 /* Max packet length */ #define DEFAULT_PKT_INTERVAL 1000 /* Interval between each packet */ #define MAX_UDP_TX_BURST 32 +#define MAX_RX_BURST 32 #define APPL_MODE_UDP 0 /**< UDP mode */ #define APPL_MODE_PING 1 /**< ping mode */ @@ -638,8 +639,9 @@ static int gen_recv_thread(void *arg) int thr; odp_pktio_t pktio; thread_args_t *thr_args; - odp_packet_t pkt; - odp_event_t ev; + odp_packet_t pkts[MAX_RX_BURST], pkt; + odp_event_t events[MAX_RX_BURST]; + int pkt_cnt, ev_cnt, i; thr = odp_thread_id(); thr_args = arg; @@ -662,18 +664,25 @@ static int gen_recv_thread(void *arg) } /* Use schedule to get buf from any input queue */ - ev = odp_schedule(NULL, ODP_SCHED_WAIT); - - pkt = odp_packet_from_event(ev); - /* Drop packets with errors */ - if (odp_unlikely(odp_packet_has_error(pkt))) { - odp_packet_free(pkt); + ev_cnt = odp_schedule_multi(NULL, ODP_SCHED_WAIT, + events, MAX_RX_BURST); + if (ev_cnt == 0) continue; + for (i = 0, pkt_cnt = 0; i < ev_cnt; i++) { + pkt = odp_packet_from_event(events[i]); + + /* Drop packets with errors */ + if (odp_unlikely(odp_packet_has_error(pkt))) { + odp_packet_free(pkt); + continue; + } + pkts[pkt_cnt++] = pkt; } - print_pkts(thr, &pkt, 1); + print_pkts(thr, pkts, pkt_cnt); - odp_packet_free(pkt); + for (i = 0; i < pkt_cnt; i++) + odp_packet_free(pkts[i]); } return 0;