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 9140C46092; Wed, 15 Jan 2025 14:00:12 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 40C6940654; Wed, 15 Jan 2025 13:59:59 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id BA1E14060F for ; Wed, 15 Jan 2025 13:59:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736945995; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+DEHdpU4xQyFg3MvH6vPfk6RZ4x2gk0E7vPoxrzLT9g=; b=W3xqqa6v8aBB97UoRjYyDJypHHemZjreOCf8aaJwWqRk1l1IAyGIXChhUnJUPLd+t4R0ew CR7Bqz85O/Kz1vxYGSu/3dmxKa2/eXaQxXrm8kZ7V/UqYeLRBe3HG30a7bO7y8r5w8OxDK ZsfmunWn4dEFSRW5x3em78GcAP1quVg= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-663-CQa_HeBVOru3qctEGS1LOQ-1; Wed, 15 Jan 2025 07:59:54 -0500 X-MC-Unique: CQa_HeBVOru3qctEGS1LOQ-1 X-Mimecast-MFC-AGG-ID: CQa_HeBVOru3qctEGS1LOQ Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 4F78A1955D88; Wed, 15 Jan 2025 12:59:53 +0000 (UTC) Received: from max-p1.redhat.com (unknown [10.39.208.25]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id DDF7519560AA; Wed, 15 Jan 2025 12:59:51 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, david.marchand@redhat.com, chenbox@nvidia.com Cc: Maxime Coquelin Subject: [PATCH v2 4/4] vhost: improve RARP handling in dequeue paths Date: Wed, 15 Jan 2025 13:59:38 +0100 Message-ID: <20250115125938.2699577-5-maxime.coquelin@redhat.com> In-Reply-To: <20250115125938.2699577-1-maxime.coquelin@redhat.com> References: <20250115125938.2699577-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: K8HbiTPtdBbj6hN24plcO_IKfAmYvSAT_og6JeDkyGo_1736945993 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true 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 With previous refactoring, we can now simplify the RARP packet injection handling in both the sync and async dequeue paths. Signed-off-by: Maxime Coquelin --- lib/vhost/virtio_net.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/lib/vhost/virtio_net.c b/lib/vhost/virtio_net.c index 59ea2d16a5..fab45ebd54 100644 --- a/lib/vhost/virtio_net.c +++ b/lib/vhost/virtio_net.c @@ -3662,21 +3662,23 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, * learning table will get updated first. */ pkts[0] = rarp_mbuf; - vhost_queue_stats_update(dev, vq, pkts, 1); - pkts++; - count -= 1; + nb_rx += 1; } if (vq_is_packed(dev)) { if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) - nb_rx = virtio_dev_tx_packed_legacy(dev, vq, mbuf_pool, pkts, count); + nb_rx += virtio_dev_tx_packed_legacy(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx); else - nb_rx = virtio_dev_tx_packed_compliant(dev, vq, mbuf_pool, pkts, count); + nb_rx += virtio_dev_tx_packed_compliant(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx); } else { if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) - nb_rx = virtio_dev_tx_split_legacy(dev, vq, mbuf_pool, pkts, count); + nb_rx += virtio_dev_tx_split_legacy(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx); else - nb_rx = virtio_dev_tx_split_compliant(dev, vq, mbuf_pool, pkts, count); + nb_rx += virtio_dev_tx_split_compliant(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx); } vhost_queue_stats_update(dev, vq, pkts, nb_rx); @@ -3687,9 +3689,6 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id, out_access_unlock: rte_rwlock_read_unlock(&vq->access_lock); - if (unlikely(rarp_mbuf != NULL)) - nb_rx += 1; - out_no_unlock: return nb_rx; } @@ -4285,25 +4284,23 @@ rte_vhost_async_try_dequeue_burst(int vid, uint16_t queue_id, * learning table will get updated first. */ pkts[0] = rarp_mbuf; - vhost_queue_stats_update(dev, vq, pkts, 1); - pkts++; - count -= 1; + nb_rx += 1; } if (vq_is_packed(dev)) { if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) - nb_rx = virtio_dev_tx_async_packed_legacy(dev, vq, mbuf_pool, - pkts, count, dma_id, vchan_id); + nb_rx += virtio_dev_tx_async_packed_legacy(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx, dma_id, vchan_id); else - nb_rx = virtio_dev_tx_async_packed_compliant(dev, vq, mbuf_pool, - pkts, count, dma_id, vchan_id); + nb_rx += virtio_dev_tx_async_packed_compliant(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx, dma_id, vchan_id); } else { if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) - nb_rx = virtio_dev_tx_async_split_legacy(dev, vq, mbuf_pool, - pkts, count, dma_id, vchan_id); + nb_rx += virtio_dev_tx_async_split_legacy(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx, dma_id, vchan_id); else - nb_rx = virtio_dev_tx_async_split_compliant(dev, vq, mbuf_pool, - pkts, count, dma_id, vchan_id); + nb_rx += virtio_dev_tx_async_split_compliant(dev, vq, mbuf_pool, + pkts + nb_rx, count - nb_rx, dma_id, vchan_id); } *nr_inflight = vq->async->pkts_inflight_n; @@ -4315,9 +4312,6 @@ rte_vhost_async_try_dequeue_burst(int vid, uint16_t queue_id, out_access_unlock: rte_rwlock_read_unlock(&vq->access_lock); - if (unlikely(rarp_mbuf != NULL)) - nb_rx += 1; - out_no_unlock: return nb_rx; } -- 2.47.1