diff mbox series

[PATCHv3,3/5] test: generator: receive packets in bursts

Message ID 1489994897-6836-4-git-send-email-bogdan.pricope@linaro.org
State Superseded
Headers show
Series test: generator: improve performance | expand

Commit Message

Bogdan Pricope March 20, 2017, 7:28 a.m. UTC
Signed-off-by: Bogdan Pricope <bogdan.pricope@linaro.org>

---
 example/generator/odp_generator.c | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

-- 
1.9.1
diff mbox series

Patch

diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c
index 2d95ba8..1932852 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;