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 A823B46093; Wed, 15 Jan 2025 17:47:05 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 46E2B402B5; Wed, 15 Jan 2025 17:47:05 +0100 (CET) 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 03B0240298 for ; Wed, 15 Jan 2025 17:47:03 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736959623; 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=9Ypdz3Bo/06Cu+vxLN5D5oHpXCM1b5NrJk4vZflT90E=; b=D79/m2nweBi8VXW0aaR2KEr1CMpRwFzELHZnciPDd3SvbOSK3JhKo2XFFs5HbACp3NP+V+ /UMHX2YWeeEw/doSK1d+AWfLEvU/zJBMzKIJ00hYfKfg7daWk1as9FHBtSjXpS/j/aRReY 3vjlT23lbj9NiqzU7GLuj+WnQypAdKM= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-426-yEoF4P9hM-aEg2ESRnTkng-1; Wed, 15 Jan 2025 11:47:02 -0500 X-MC-Unique: yEoF4P9hM-aEg2ESRnTkng-1 X-Mimecast-MFC-AGG-ID: yEoF4P9hM-aEg2ESRnTkng Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-30226a472caso37196371fa.0 for ; Wed, 15 Jan 2025 08:47:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736959620; x=1737564420; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9Ypdz3Bo/06Cu+vxLN5D5oHpXCM1b5NrJk4vZflT90E=; b=qbkid+KV0XP9ouWI3eRTZS+r1zynvXxNK8Y2GgKwDzk7R+8ZqNiGaVkTcY8Oqae1Ak 41uQJn0Y+r25gMs9pL0+9jvaGZC5W0CNFtP0NJ3RN6bKZGAdU2YkRtFtIfy9NxOCVY+O nfgJ43jnnxQfLv6eAxk2wK0YQBezFJkehtvr3vSthNGL8ConHJ9MGRm29kjqazydEXdo MZ6kAArPvLaDbrcSqwcoJTCJrqY6Zf3q9k7OIgHSCWGtzMaxsem+mznkifkx2ycbzaHN L68LDpeoAEhrrHVPS665GQuUjdiMihlNhvPiinKH1qI/cme9hFOglOXsQXT3zAUMOI69 1SdQ== X-Gm-Message-State: AOJu0YxYx6OHKocSTgi7+fYt9F4cmj3/t5OYZ+PkIHSiHkeJTA6IhNtn Kjgs/wugGvQKS9gZC9E2Sd/06aUJ+IqpIwKUW7NKIdrlG3KdUS5ff2cHUBdKNRwbQxPjI2Wz6vK 0My41aV7FxOJBFqfoixL5VKaCVBFpgqOY90FqFl6x9thN0CigQbJjT+k7oi52z8xyOD0PTP+L3u DrMsit+6kH0XGHmXA= X-Gm-Gg: ASbGncu3JioYL0mEAP6yuXYclq9vLMSOccbdKf8z7EmP0hKL/8ljRw91weiKj11Kyop yrRczMSXorRYj3Il7wEgdbLkXQ08wmLUT7UPq/L32 X-Received: by 2002:a05:6512:3d22:b0:540:25a6:c390 with SMTP id 2adb3069b0e04-542845b6f79mr9862585e87.23.1736959620348; Wed, 15 Jan 2025 08:47:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IGss27tJd0I9xoY9TXPOwpY1M8Ovpar40RwtFQYb2Cny6s2+bL56Q7H5MyeF23iCYom4ZFzwjlSZuJEQucmlQA= X-Received: by 2002:a05:6512:3d22:b0:540:25a6:c390 with SMTP id 2adb3069b0e04-542845b6f79mr9862579e87.23.1736959619914; Wed, 15 Jan 2025 08:46:59 -0800 (PST) MIME-Version: 1.0 References: <20250115125938.2699577-1-maxime.coquelin@redhat.com> <20250115125938.2699577-5-maxime.coquelin@redhat.com> In-Reply-To: <20250115125938.2699577-5-maxime.coquelin@redhat.com> From: David Marchand Date: Wed, 15 Jan 2025 17:46:48 +0100 X-Gm-Features: AbW1kvZelzBMIpYKeqzbXJ3w7YfYfpudk_scezlLCiPtuVuvnvw5fgltFZDXODg Message-ID: Subject: Re: [PATCH v2 4/4] vhost: improve RARP handling in dequeue paths To: Maxime Coquelin Cc: dev@dpdk.org, chenbox@nvidia.com X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: LVvfgkHF7euzJiTJ5wRmvL92nW0LVKXKLjz8g7-q4hc_1736959620 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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 On Wed, Jan 15, 2025 at 1:59=E2=80=AFPM Maxime Coquelin wrote: > > 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_i= d, > * learning table will get updated first. > */ > pkts[0] =3D rarp_mbuf; Well, ideally it would be pkts[nb_rx], but see comment below. > - vhost_queue_stats_update(dev, vq, pkts, 1); > - pkts++; > - count -=3D 1; > + nb_rx +=3D 1; > } With this change, the rarp_mbuf variable is unneeded. You can store to pkts[nb_rx] when calling rte_net_make_rarp_packet() (and at the same time, move the comment about injecting the packet to the head of the array). > > if (vq_is_packed(dev)) { > if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) > - nb_rx =3D virtio_dev_tx_packed_legacy(dev, vq, mb= uf_pool, pkts, count); > + nb_rx +=3D virtio_dev_tx_packed_legacy(dev, vq, m= buf_pool, > + pkts + nb_rx, count - nb_rx); > else > - nb_rx =3D virtio_dev_tx_packed_compliant(dev, vq,= mbuf_pool, pkts, count); > + nb_rx +=3D 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 =3D virtio_dev_tx_split_legacy(dev, vq, mbu= f_pool, pkts, count); > + nb_rx +=3D virtio_dev_tx_split_legacy(dev, vq, mb= uf_pool, > + pkts + nb_rx, count - nb_rx); > else > - nb_rx =3D virtio_dev_tx_split_compliant(dev, vq, = mbuf_pool, pkts, count); > + nb_rx +=3D 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 !=3D NULL)) > - nb_rx +=3D 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] =3D rarp_mbuf; > - vhost_queue_stats_update(dev, vq, pkts, 1); > - pkts++; > - count -=3D 1; > + nb_rx +=3D 1; > } Idem. > > if (vq_is_packed(dev)) { > if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) > - nb_rx =3D virtio_dev_tx_async_packed_legacy(dev, = vq, mbuf_pool, > - pkts, count, dma_id, vchan_id); > + nb_rx +=3D virtio_dev_tx_async_packed_legacy(dev,= vq, mbuf_pool, > + pkts + nb_rx, count - nb_rx, dma_= id, vchan_id); > else > - nb_rx =3D virtio_dev_tx_async_packed_compliant(de= v, vq, mbuf_pool, > - pkts, count, dma_id, vchan_id); > + nb_rx +=3D virtio_dev_tx_async_packed_compliant(d= ev, vq, mbuf_pool, > + pkts + nb_rx, count - nb_rx, dma_= id, vchan_id); > } else { > if (dev->flags & VIRTIO_DEV_LEGACY_OL_FLAGS) > - nb_rx =3D virtio_dev_tx_async_split_legacy(dev, v= q, mbuf_pool, > - pkts, count, dma_id, vchan_id); > + nb_rx +=3D virtio_dev_tx_async_split_legacy(dev, = vq, mbuf_pool, > + pkts + nb_rx, count - nb_rx, dma_= id, vchan_id); > else > - nb_rx =3D virtio_dev_tx_async_split_compliant(dev= , vq, mbuf_pool, > - pkts, count, dma_id, vchan_id); > + nb_rx +=3D virtio_dev_tx_async_split_compliant(de= v, vq, mbuf_pool, > + pkts + nb_rx, count - nb_rx, dma_= id, vchan_id); > } > > *nr_inflight =3D 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 !=3D NULL)) > - nb_rx +=3D 1; > - > out_no_unlock: > return nb_rx; > } > -- > 2.47.1 > --=20 David Marchand