diff mbox

[API-NEXT,v2,3/9] packet_io: release unsent packets after odp_pktio_send()

Message ID 1433505231-28843-4-git-send-email-zoltan.kiss@linaro.org
State Superseded
Headers show

Commit Message

Zoltan Kiss June 5, 2015, 11:53 a.m. UTC
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
---
 example/packet/odp_pktio.c   | 10 +++++++++-
 test/performance/odp_l2fwd.c | 12 ++++++++++--
 2 files changed, 19 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c
index f08d9f4..0b4a8f1 100644
--- a/example/packet/odp_pktio.c
+++ b/example/packet/odp_pktio.c
@@ -282,9 +282,17 @@  static void *pktio_ifburst_thread(void *arg)
 			/* Drop packets with errors */
 			pkts_ok = drop_err_pkts(pkt_tbl, pkts);
 			if (pkts_ok > 0) {
+				int sent;
+
 				/* Swap Eth MACs and IP-addrs */
 				swap_pkt_addrs(pkt_tbl, pkts_ok);
-				odp_pktio_send(pktio, pkt_tbl, pkts_ok);
+				sent = odp_pktio_send(pktio, pkt_tbl, pkts_ok);
+				if (odp_unlikely(sent < pkts_ok)) {
+					err_cnt += pkts_ok - sent;
+					do
+						odp_packet_free(pkt_tbl[sent]);
+					while (++sent < pkts_ok);
+				}
 			}
 
 			if (odp_unlikely(pkts_ok != pkts))
diff --git a/test/performance/odp_l2fwd.c b/test/performance/odp_l2fwd.c
index 5d4b833..dd0b4b1 100644
--- a/test/performance/odp_l2fwd.c
+++ b/test/performance/odp_l2fwd.c
@@ -224,8 +224,16 @@  static void *pktio_ifburst_thread(void *arg)
 
 		/* Drop packets with errors */
 		pkts_ok = drop_err_pkts(pkt_tbl, pkts);
-		if (pkts_ok > 0)
-			odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok);
+		if (pkts_ok > 0) {
+			int sent = odp_pktio_send(pktio_dst, pkt_tbl, pkts_ok);
+
+			if (odp_unlikely(sent < pkts_ok)) {
+				stats->drops += pkts_ok - sent;
+				do
+					odp_packet_free(pkt_tbl[sent]);
+				while (++sent < pkts_ok);
+			}
+		}
 
 		if (odp_unlikely(pkts_ok != pkts))
 			stats->drops += pkts - pkts_ok;