DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] vhost: don't track remaining packets separately
@ 2021-04-08 14:44 Balazs Nemeth
  2021-04-13 11:36 ` Maxime Coquelin
  2021-04-13 13:20 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
  0 siblings, 2 replies; 6+ messages in thread
From: Balazs Nemeth @ 2021-04-08 14:44 UTC (permalink / raw)
  To: bnemeth, dev

The remained variable stores the same information as the difference
between count and pkt_idx. Remove the remained variable to simplify.

Signed-off-by: Balazs Nemeth <bnemeth@redhat.com>
---
 lib/librte_vhost/virtio_net.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index e8cc5f659..cfd52360d 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1353,16 +1353,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;
 			}
 		}
@@ -1370,7 +1368,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);
 
@@ -2480,12 +2477,11 @@ virtio_dev_tx_packed(struct virtio_net *dev,
 	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,
 							&pkts[pkt_idx])) {
 				pkt_idx += PACKED_BATCH_SIZE;
-				remained -= PACKED_BATCH_SIZE;
 
 				continue;
 			}
@@ -2496,9 +2492,7 @@ virtio_dev_tx_packed(struct virtio_net *dev,
 			break;
 		}
 		pkt_idx++;
-		remained--;
-
-	} while (remained);
+	} while (pkt_idx < count);
 
 	if (pkt_idx != count) {
 		rte_pktmbuf_free_bulk(&pkts[pkt_idx], count - pkt_idx);
-- 
2.30.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-28  3:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08 14:44 [dpdk-dev] [PATCH] vhost: don't track remaining packets separately Balazs Nemeth
2021-04-13 11:36 ` Maxime Coquelin
2021-04-13 13:20 ` [dpdk-dev] [PATCH v2] " Balazs Nemeth
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

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).