From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 3FFEEA0524;
	Tue, 13 Apr 2021 15:31:19 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id C0483160F9E;
	Tue, 13 Apr 2021 15:31:18 +0200 (CEST)
Received: from us-smtp-delivery-124.mimecast.com
 (us-smtp-delivery-124.mimecast.com [170.10.133.124])
 by mails.dpdk.org (Postfix) with ESMTP id 1A4DF160F97
 for <dev@dpdk.org>; Tue, 13 Apr 2021 15:31:16 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;
 s=mimecast20190719; t=1618320676;
 h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
 to:to:cc:mime-version:mime-version:content-type:content-type:
 content-transfer-encoding:content-transfer-encoding:
 in-reply-to:in-reply-to:references:references;
 bh=URdZrESdKIoueJ7DtZjavwEUGhEf6OIDuODCU7kKO9M=;
 b=M0aTmNTenu9wzsy3PWHrSi+pUp2eoD6kSASl10QVxn4NDgf7s5nCaV8qpC6Ehl2UUU+Jc6
 tputaHD99Mus6Y32K30LYK9n8iig/Ca1fIUKMXjoqpN4nlSg3gCEy9piMhFEIK+94K4oXc
 gT91t3yTtuRBo5AQQi0o6bqvSyCpK0g=
Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com
 [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id
 us-mta-320-93d5MubTOTWmNJEGnynJxQ-1; Tue, 13 Apr 2021 09:31:14 -0400
X-MC-Unique: 93d5MubTOTWmNJEGnynJxQ-1
Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com
 [10.5.11.13])
 (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))
 (No client certificate requested)
 by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A5445192AB6F
 for <dev@dpdk.org>; Tue, 13 Apr 2021 13:31:13 +0000 (UTC)
Received: from bnemeth.users.ipa.redhat.com (ovpn-113-107.ams2.redhat.com
 [10.36.113.107])
 by smtp.corp.redhat.com (Postfix) with ESMTP id 38C38226E2;
 Tue, 13 Apr 2021 13:31:08 +0000 (UTC)
From: Balazs Nemeth <bnemeth@redhat.com>
To: bnemeth@redhat.com,
	dev@dpdk.org,
	maxime.coquelin@redhat.com
Date: Tue, 13 Apr 2021 15:31:03 +0200
Message-Id: <e427b1f691770d4c7706d9b7d469e549eadb1f8e.1618320615.git.bnemeth@redhat.com>
In-Reply-To: <94518e576d77c6c0a4ae2f8cfa0b543213be77db.1618319906.git.bnemeth@redhat.com>
References: <94518e576d77c6c0a4ae2f8cfa0b543213be77db.1618319906.git.bnemeth@redhat.com>
MIME-Version: 1.0
X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13
Authentication-Results: relay.mimecast.com;
 auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=bnemeth@redhat.com
X-Mimecast-Spam-Score: 0
X-Mimecast-Originator: redhat.com
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="US-ASCII"
Subject: [dpdk-dev] [PATCH v3] vhost: don't track remaining packets
 separately
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

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