From patchwork Mon Feb 13 12:50:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bogdan Pricope X-Patchwork-Id: 93876 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1078916qgi; Mon, 13 Feb 2017 04:50:24 -0800 (PST) X-Received: by 10.237.37.209 with SMTP id y17mr20970167qtc.136.1486990223638; Mon, 13 Feb 2017 04:50:23 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id h61si7142134qtd.163.2017.02.13.04.50.23; Mon, 13 Feb 2017 04:50:23 -0800 (PST) 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 514C462FA6; Mon, 13 Feb 2017 12:50:23 +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_MSPIKE_H2, 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 AD89460B10; Mon, 13 Feb 2017 12:50:19 +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 BA01B60B10; Mon, 13 Feb 2017 12:50:17 +0000 (UTC) Received: from mail-wr0-f175.google.com (mail-wr0-f175.google.com [209.85.128.175]) by lists.linaro.org (Postfix) with ESMTPS id 08A0162F7A for ; Mon, 13 Feb 2017 12:50:05 +0000 (UTC) Received: by mail-wr0-f175.google.com with SMTP id 89so149781983wrr.2 for ; Mon, 13 Feb 2017 04:50:04 -0800 (PST) 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=hKqqN+GcZipCTCXqEkESJNq9kUqvu1fGYBNKqc6Q2O4=; b=DhZaN9YaXe9ocPWoWUkuNbOTn4IYTrzjA5CaabPvaXdtM0dl9rAURT162Kwbrm59pE wti1QsHGmqCcwpkTxyb7WaP2daftFwXM6fvZdiH9vNpxJvaecP+xoQPL1XeybeeFdOmX GQobpeJKqiHgpwNRzX6OLP7UM09ReRmHQrtSHCex6z1k3Fp4u6xAMAwNcMZ5V3UPM+YK JuDLuh4730lZ6Guov93dg1wF+Mp8wazjcIwanELv63NiQxeAA54hd5iXu092Itmwi8qq dTGXo6rt91/N9/uHJbML4BtCFLYJiJJLzTr2Cg++zyX58yRMpen0xLUIlRbO9AfVyYLJ dD6A== X-Gm-Message-State: AMke39lTlnwhi0/n2EVEowcc3K/z8rabrphrtkhf0PfJLIwuFT94rKVhEKVgSllUtu+kMHy0Ly8= X-Received: by 10.223.134.218 with SMTP id 26mr19311100wry.104.1486990203874; Mon, 13 Feb 2017 04:50:03 -0800 (PST) Received: from localhost.localdomain ([193.202.22.66]) by smtp.gmail.com with ESMTPSA id k70sm5272339wmc.3.2017.02.13.04.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 13 Feb 2017 04:50:03 -0800 (PST) From: Bogdan Pricope To: lng-odp@lists.linaro.org Date: Mon, 13 Feb 2017 14:50:15 +0200 Message-Id: <1486990215-20580-1-git-send-email-bogdan.pricope@linaro.org> X-Mailer: git-send-email 1.9.1 Subject: [lng-odp] [PATCH 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 158bddf..fbd3ec0 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 */ @@ -635,8 +636,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; @@ -659,18 +661,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;