public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Jon Maloy <jmaloy@redhat.com>
To: Laurent Vivier <lvivier@redhat.com>, passt-dev@passt.top
Cc: David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH v3 05/10] udp_vu: Pass iov explicitly to helpers instead of using file-scoped array
Date: Mon, 11 May 2026 05:37:45 -0400	[thread overview]
Message-ID: <85665e4f-49e5-431a-8c4e-05baa6fa92ca@redhat.com> (raw)
In-Reply-To: <20260416155721.3807225-6-lvivier@redhat.com>



On 2026-04-16 11:57, Laurent Vivier wrote:
> udp_vu_sock_recv(), udp_vu_prepare(), and udp_vu_csum() all operated on
> the file-scoped iov_vu[] array directly.  Pass iov and count as explicit
> parameters instead, and move iov_vu[] and elem[] to function-local
> statics in udp_vu_sock_to_tap(), the only function that needs them.
> 
> Signed-off-by: Laurent Vivier <lvivier@redhat.com>
> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>

Reviewed-by: Jon Maloy <jmaloy@redhat.com>

See below.

> ---
>   udp_vu.c | 67 +++++++++++++++++++++++++++++---------------------------
>   1 file changed, 35 insertions(+), 32 deletions(-)
> 
[...]

oside, int iov_used)
> +static void udp_vu_csum(const struct flowside *toside, const struct iovec *iov,
> +			size_t cnt)
>   {
>   	const struct in_addr *src4 = inany_v4(&toside->oaddr);
>   	const struct in_addr *dst4 = inany_v4(&toside->eaddr);
> -	char *base = iov_vu[0].iov_base;
> +	char *base = iov[0].iov_base;
>   	struct udp_payload_t *bp;
>   	struct iov_tail data;
>   
>   	if (src4 && dst4) {
>   		bp = vu_payloadv4(base);
> -		data = IOV_TAIL(iov_vu, iov_used, (char *)&bp->data - base);
> +		data = IOV_TAIL(iov, cnt, (char *)&bp->data - base);
>   		csum_udp4(&bp->uh, *src4, *dst4, &data);
>   	} else {
>   		bp = vu_payloadv6(base);
> -		data = IOV_TAIL(iov_vu, iov_used, (char *)&bp->data - base);
> +		data = IOV_TAIL(iov, cnt, (char *)&bp->data - base);
>   		csum_udp6(&bp->uh, &toside->oaddr.a6, &toside->eaddr.a6, &data);
>   	}
>   }
> @@ -179,7 +180,9 @@ static void udp_vu_csum(const struct flowside *toside, int iov_used)
>   void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx)
>   {
>   	const struct flowside *toside = flowside_at_sidx(tosidx);
> +	static struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE];

I think this declaration should move one line down.

/jon

>   	bool v6 = !(inany_v4(&toside->eaddr) && inany_v4(&toside->oaddr));
> +	static struct iovec iov_vu[VIRTQUEUE_MAX_SIZE];
>   	struct vu_dev *vdev = c->vdev;
>   	struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE];
>   	int i;
> @@ -212,9 +215,9 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx)
>   
>   		assert((size_t)elem_cnt == iov_cnt);	/* one iovec per element */
>   
> -		dlen = udp_vu_sock_recv(s, v6, &iov_cnt);
> +		dlen = udp_vu_sock_recv(iov_vu, &iov_cnt, s, v6);
>   		if (dlen < 0) {
> -			vu_queue_rewind(vq, iov_cnt);
> +			vu_queue_rewind(vq, elem_cnt);
>   			break;
>   		}
>   
> @@ -224,12 +227,12 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx)
>   		vu_queue_rewind(vq, elem_cnt - elem_used);
>   
>   		if (iov_cnt > 0) {
> -			udp_vu_prepare(c, toside, dlen);
> +			udp_vu_prepare(c, iov_vu, toside, dlen);
>   			if (*c->pcap) {
> -				udp_vu_csum(toside, iov_cnt);
> +				udp_vu_csum(toside, iov_vu, iov_cnt);
>   				pcap_iov(iov_vu, iov_cnt, VNET_HLEN);
>   			}
> -			vu_flush(vdev, vq, elem, iov_cnt);
> +			vu_flush(vdev, vq, elem, elem_used);
>   			vu_queue_notify(vdev, vq);
>   		}
>   	}


  reply	other threads:[~2026-05-11  9:37 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-16 15:57 [PATCH v3 00/10] vhost-user: Preparatory series for multiple iovec entries per virtqueue element Laurent Vivier
2026-04-16 15:57 ` [PATCH v3 01/10] iov: Introduce iov_memset() Laurent Vivier
2026-04-16 15:57 ` [PATCH v3 02/10] iov: Add iov_memcpy() to copy data between iovec arrays Laurent Vivier
2026-05-11  9:07   ` Jon Maloy
2026-04-16 15:57 ` [PATCH v3 03/10] vu_common: Move vnethdr setup into vu_flush() Laurent Vivier
2026-04-16 15:57 ` [PATCH v3 04/10] udp_vu: Move virtqueue management from udp_vu_sock_recv() to its caller Laurent Vivier
2026-05-11  9:30   ` Jon Maloy
2026-05-11 10:44     ` David Gibson
2026-04-16 15:57 ` [PATCH v3 05/10] udp_vu: Pass iov explicitly to helpers instead of using file-scoped array Laurent Vivier
2026-05-11  9:37   ` Jon Maloy [this message]
2026-04-16 15:57 ` [PATCH v3 06/10] checksum: Pass explicit L4 length to checksum functions Laurent Vivier
2026-05-11  1:33   ` David Gibson
2026-04-16 15:57 ` [PATCH v3 07/10] pcap: Pass explicit L2 length to pcap_iov() Laurent Vivier
2026-05-11  1:42   ` David Gibson
2026-05-11  9:50   ` Jon Maloy
2026-04-16 15:57 ` [PATCH v3 08/10] vu_common: Pass explicit frame length to vu_flush() Laurent Vivier
2026-04-16 15:57 ` [PATCH v3 09/10] tcp: Pass explicit data length to tcp_fill_headers() Laurent Vivier
2026-04-16 15:57 ` [PATCH v3 10/10] vhost-user: Centralise Ethernet frame padding in vu_collect() and vu_pad() Laurent Vivier
2026-05-11  2:01   ` David Gibson
2026-05-11  9:53 ` [PATCH v3 00/10] vhost-user: Preparatory series for multiple iovec entries per virtqueue element Jon Maloy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85665e4f-49e5-431a-8c4e-05baa6fa92ca@redhat.com \
    --to=jmaloy@redhat.com \
    --cc=david@gibson.dropbear.id.au \
    --cc=lvivier@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).