DPDK patches and discussions
 help / color / mirror / Atom feed
From: Rafal Kozik <rk@semihalf.com>
To: dev@dpdk.org, keith.wiles@intel.com
Cc: mw@semihalf.com, mk@semihalf.com, gtzalik@amazon.com,
	evgenys@amazon.com, matua@amazon.com, igorch@amazon.com,
	Rafal Kozik <rk@semihalf.com>
Subject: [dpdk-dev] [PATCH 5/5] [pktgen] fix cleanup of not sent packets
Date: Thu, 10 Jan 2019 17:14:06 +0100	[thread overview]
Message-ID: <1547136846-23319-6-git-send-email-rk@semihalf.com> (raw)
In-Reply-To: <1547136846-23319-1-git-send-email-rk@semihalf.com>

Not sent packets are copied to the beginning of array to be reused in next
iteration. But as in some cases more than half of mbuf could not be sent,
source and destination locations would overlap. In such case rte_memcpy
cannot be used.
One of side effects is double sending the same mbuf and as a consequence
double returning it to the mempool.

Fixes: 2bf1eecea240 ("fixup code for 18.05 and cleanup")

Signed-off-by: Rafal Kozik <rk@semihalf.com>
---
 app/pktgen.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/app/pktgen.c b/app/pktgen.c
index f7eee07..c1039a6 100644
--- a/app/pktgen.c
+++ b/app/pktgen.c
@@ -272,11 +272,10 @@ _send_burst_fast(port_info_t *info, uint16_t qid)
 {
 	struct mbuf_table   *mtab = &info->q[qid].tx_mbufs;
 	struct rte_mbuf **pkts;
-	uint32_t ret, cnt, sav, retry;
+	uint32_t ret, cnt, retry, i;
 
 	cnt = mtab->len;
 	mtab->len = 0;
-	sav = cnt;
 
 	pkts = mtab->m_table;
 
@@ -299,8 +298,8 @@ _send_burst_fast(port_info_t *info, uint16_t qid)
 		}
 	}
 	if (cnt) {
-		rte_memcpy(&mtab->m_table[0], &mtab->m_table[sav - cnt],
-		           sizeof(char *) * cnt);
+		for (i = 0; i < cnt; i++)
+			mtab->m_table[i] = pkts[i];
 		mtab->len = cnt;
 	}
 }
-- 
2.7.4

      parent reply	other threads:[~2019-01-10 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-10 16:14 [dpdk-dev] [PATCH 0/5][pktgen] fixes and minor features Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 1/5] [pktgen] fix race condition in start Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 2/5] [pktgen] different PCAP per each queue Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 3/5] [pktgen] use constants for PCAP creation Rafal Kozik
2019-01-10 16:14 ` [dpdk-dev] [PATCH 4/5] [pktgen] expose number of missed Rx packets Rafal Kozik
2019-01-10 16:14 ` Rafal Kozik [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1547136846-23319-6-git-send-email-rk@semihalf.com \
    --to=rk@semihalf.com \
    --cc=dev@dpdk.org \
    --cc=evgenys@amazon.com \
    --cc=gtzalik@amazon.com \
    --cc=igorch@amazon.com \
    --cc=keith.wiles@intel.com \
    --cc=matua@amazon.com \
    --cc=mk@semihalf.com \
    --cc=mw@semihalf.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).