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 18AD9A0524; Tue, 13 Apr 2021 15:20:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F037B160F82; Tue, 13 Apr 2021 15:20:44 +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 54CFF160F78 for ; Tue, 13 Apr 2021 15:20:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618320042; 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=AeQ4uwBIcavs+YESMxkaEFVI1TuWFsAnzijRcOQzAy0=; b=EWlXhnWCzs5WiJeUiqUVAo+HLYRDDOS31AGxdYRFiuQTBrS2oNF0pi4PHvVXQk9sbRAGbz MVVIan1jXmeOEX1l6JoX7G7KMKTqsZYXEqhUmr3pf+9a0U4eeUNqlkzNu3zz4vKW/idn7/ Xz+4BzfeliRpt/7uPmVagMfmyWEQRhU= 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-338-nFngYLtNPn6YckpWDQjhRg-1; Tue, 13 Apr 2021 09:20:41 -0400 X-MC-Unique: nFngYLtNPn6YckpWDQjhRg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 83049107ACC7 for ; Tue, 13 Apr 2021 13:20:40 +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 776845C224; Tue, 13 Apr 2021 13:20:39 +0000 (UTC) From: Balazs Nemeth To: bnemeth@redhat.com, dev@dpdk.org, maxime.coquelin@redhat.com Date: Tue, 13 Apr 2021 15:20:22 +0200 Message-Id: <94518e576d77c6c0a4ae2f8cfa0b543213be77db.1618319906.git.bnemeth@redhat.com> In-Reply-To: <5ef3d4c29927ed241c7128819fe35ac1d95d8f24.1617892982.git.bnemeth@redhat.com> References: <5ef3d4c29927ed241c7128819fe35ac1d95d8f24.1617892982.git.bnemeth@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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 v2] 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. --- 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