DPDK patches and discussions
 help / color / mirror / Atom feed
From: Balazs Nemeth <bnemeth@redhat.com>
To: bnemeth@redhat.com, dev@dpdk.org, maxime.coquelin@redhat.com
Subject: [dpdk-dev] [PATCH v2] vhost: don't track remaining packets separately
Date: Tue, 13 Apr 2021 15:20:22 +0200	[thread overview]
Message-ID: <94518e576d77c6c0a4ae2f8cfa0b543213be77db.1618319906.git.bnemeth@redhat.com> (raw)
In-Reply-To: <5ef3d4c29927ed241c7128819fe35ac1d95d8f24.1617892982.git.bnemeth@redhat.com>

The remained variable stores the same information as the difference
between count and pkt_idx. Remove the remained variable to simplify.
---
 lib/librte_vhost/virtio_net.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index ff39878609..01b849f6cb 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1352,16 +1352,14 @@ virtio_dev_rx_packed(struct virtio_net *dev,
 		     uint32_t count)
 {
 	uint32_t pkt_idx = 0;
-	uint32_t remained = count;
 
 	do {
 		rte_prefetch0(&vq->desc_packed[vq->last_avail_idx]);
 
-		if (remained >= PACKED_BATCH_SIZE) {
+		if (count - pkt_idx >= PACKED_BATCH_SIZE) {
 			if (!virtio_dev_rx_batch_packed(dev, vq,
 							&pkts[pkt_idx])) {
 				pkt_idx += PACKED_BATCH_SIZE;
-				remained -= PACKED_BATCH_SIZE;
 				continue;
 			}
 		}
@@ -1369,7 +1367,6 @@ virtio_dev_rx_packed(struct virtio_net *dev,
 		if (virtio_dev_rx_single_packed(dev, vq, pkts[pkt_idx]))
 			break;
 		pkt_idx++;
-		remained--;
 
 	} while (pkt_idx < count);
 
@@ -2460,16 +2457,14 @@ virtio_dev_tx_packed(struct virtio_net *dev,
 		     uint32_t count)
 {
 	uint32_t pkt_idx = 0;
-	uint32_t remained = count;
 
 	do {
 		rte_prefetch0(&vq->desc_packed[vq->last_avail_idx]);
 
-		if (remained >= PACKED_BATCH_SIZE) {
+		if (count - pkt_idx >= PACKED_BATCH_SIZE) {
 			if (!virtio_dev_tx_batch_packed(dev, vq, mbuf_pool,
 							&pkts[pkt_idx])) {
 				pkt_idx += PACKED_BATCH_SIZE;
-				remained -= PACKED_BATCH_SIZE;
 				continue;
 			}
 		}
@@ -2478,9 +2473,7 @@ virtio_dev_tx_packed(struct virtio_net *dev,
 						&pkts[pkt_idx]))
 			break;
 		pkt_idx++;
-		remained--;
-
-	} while (remained);
+	} while (pkt_idx < count);
 
 	if (vq->shadow_used_idx) {
 		do_data_copy_dequeue(vq);
-- 
2.30.2


  parent reply	other threads:[~2021-04-13 13:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-08 14:44 [dpdk-dev] [PATCH] " Balazs Nemeth
2021-04-13 11:36 ` Maxime Coquelin
2021-04-13 13:20 ` Balazs Nemeth [this message]
2021-04-13 13:31   ` [dpdk-dev] [PATCH v3] " Balazs Nemeth
2021-04-15 16:22     ` Maxime Coquelin
2021-04-28  3:14     ` Xia, Chenbo

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=94518e576d77c6c0a4ae2f8cfa0b543213be77db.1618319906.git.bnemeth@redhat.com \
    --to=bnemeth@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.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).