From patchwork Fri Mar 24 14:01:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bogdan Pricope X-Patchwork-Id: 95946 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp63266qgd; Fri, 24 Mar 2017 07:07:57 -0700 (PDT) X-Received: by 10.55.20.100 with SMTP id e97mr8351902qkh.3.1490364477623; Fri, 24 Mar 2017 07:07:57 -0700 (PDT) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m23si770058qke.157.2017.03.24.07.07.57; Fri, 24 Mar 2017 07:07:57 -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 4518B642C5; Fri, 24 Mar 2017 14:07:57 +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 C1F38642D9; Fri, 24 Mar 2017 14:03:45 +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 F2027642C8; Fri, 24 Mar 2017 14:03:37 +0000 (UTC) Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by lists.linaro.org (Postfix) with ESMTPS id 59F01642D1 for ; Fri, 24 Mar 2017 14:02:08 +0000 (UTC) Received: by mail-wm0-f48.google.com with SMTP id t189so3062620wmt.1 for ; Fri, 24 Mar 2017 07:02:08 -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:in-reply-to :references; bh=VcJp3VUBRLgfNHuT7BuPSVYXvRJgLWk41K68bf3ePtA=; b=EGO9gn9ujPjY40CaFBbIaEb7m5whR8a8BDdFQNy2PGLqpnyt47WKxyQ7g4xm7Na2km Sdj2wxx3AainMl1Ol8W3ZCCj6bquygoXK774U66gPutdVgf0ePjg10whoHcbZkgDVE/5 BA31qT7qcdmAVSiVK2C+xrVPQG14noEeh/d26Vx+j7uRi92WxYfkW1I/kNq7lifAOvNj I/iYHV+KuNygu1otG8/zFXOSX45bfKQfIeFSpdEnM5V/HS0mP0LBsrN2ZJfR1icSaFTL g+WYJW7GcMXiGbfnkzVxuo2kVHNEgUvH1EWNQHcnn703j5OnpZ/08HSdek9I91v45Z7r zkfA== X-Gm-Message-State: AFeK/H0Y3RNryL518X1ypULx7Skb5snstYOkOUwYpXkV6VjqFON8Ots/4XTvh7yruEXW0z0KW43YE4L8 X-Received: by 10.28.209.75 with SMTP id i72mr3007177wmg.31.1490364126497; Fri, 24 Mar 2017 07:02:06 -0700 (PDT) Received: from localhost.localdomain ([193.202.22.66]) by smtp.gmail.com with ESMTPSA id c8sm2979045wrd.57.2017.03.24.07.02.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Mar 2017 07:02:06 -0700 (PDT) From: Bogdan Pricope To: lng-odp@lists.linaro.org Date: Fri, 24 Mar 2017 16:01:40 +0200 Message-Id: <1490364102-13781-4-git-send-email-bogdan.pricope@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1490364102-13781-1-git-send-email-bogdan.pricope@linaro.org> References: <1490364102-13781-1-git-send-email-bogdan.pricope@linaro.org> Subject: [lng-odp] [PATCHv4 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 | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) -- 1.9.1 diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index a47bd94..34014d8 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,24 @@ 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); + odp_packet_free_multi(pkts, pkt_cnt); } return 0;