From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 101A7A0579; Thu, 8 Apr 2021 16:45:27 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C31511410C2; Thu, 8 Apr 2021 16:45:26 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id EAE254068B for ; Thu, 8 Apr 2021 16:45:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617893125; 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; bh=dr6UtrUXQEmaxQHy9vr6LLhrtbH/ESzXQnYRlU9QMx0=; b=IL7fO5lkV3r2kkvvulMEHaZirc1IJQCSCZAcuQwYIeJmlDH33m4KGWY5e+sfsy0uKUlsKt eCcEkl7FfzF1bAau4uQK1V4ZXHoqLWjjK/yUUHxS8rVzkjVbM+xfeoeyu4bJpjZ4YQHkn/ c0QiX/aBU5zjao1STzgOrYjbpDkovQg= 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-165-cOnXzZCuNmWRahHBNk5ltw-1; Thu, 08 Apr 2021 10:45:23 -0400 X-MC-Unique: cOnXzZCuNmWRahHBNk5ltw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 955BB108C309 for ; Thu, 8 Apr 2021 14:45:22 +0000 (UTC) Received: from bnemeth.users.ipa.redhat.com (ovpn-114-185.ams2.redhat.com [10.36.114.185]) by smtp.corp.redhat.com (Postfix) with ESMTP id E356160636; Thu, 8 Apr 2021 14:45:21 +0000 (UTC) From: Balazs Nemeth To: bnemeth@redhat.com, dev@dpdk.org Date: Thu, 8 Apr 2021 16:44:55 +0200 Message-Id: <5ef3d4c29927ed241c7128819fe35ac1d95d8f24.1617892982.git.bnemeth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "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 --- 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