On Fri, Feb 27, 2026 at 03:03:28PM +0100, Laurent Vivier wrote: > Extend vu_init_elem() to accept an iov_per_elem parameter specifying > how many iovec entries to assign to each virtqueue element. The iov > array is now strided by iov_per_elem rather than 1. > > Update all callers to pass 1, preserving existing behavior. > > No functional change. > > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tcp_vu.c | 2 +- > udp_vu.c | 2 +- > vu_common.c | 19 ++++++++++--------- > vu_common.h | 2 +- > 4 files changed, 13 insertions(+), 12 deletions(-) > > diff --git a/tcp_vu.c b/tcp_vu.c > index 77d6e75496a0..51f7834f0307 100644 > --- a/tcp_vu.c > +++ b/tcp_vu.c > @@ -202,7 +202,7 @@ static ssize_t tcp_vu_sock_recv(const struct ctx *c, struct vu_virtq *vq, > > hdrlen = tcp_vu_hdrlen(v6); > > - vu_init_elem(elem, &iov_vu[DISCARD_IOV_NUM], ARRAY_SIZE(elem)); > + vu_init_elem(elem, &iov_vu[DISCARD_IOV_NUM], ARRAY_SIZE(elem), 1); > > elem_cnt = 0; > *head_cnt = 0; > diff --git a/udp_vu.c b/udp_vu.c > index 5ae79b9bb0c5..7e486b74883e 100644 > --- a/udp_vu.c > +++ b/udp_vu.c > @@ -214,7 +214,7 @@ void udp_vu_sock_to_tap(const struct ctx *c, int s, int n, flow_sidx_t tosidx) > int elem_cnt, elem_used; > ssize_t dlen; > > - vu_init_elem(elem, iov_vu, ARRAY_SIZE(elem)); > + vu_init_elem(elem, iov_vu, ARRAY_SIZE(elem), 1); > > elem_cnt = vu_collect(vdev, vq, elem, ARRAY_SIZE(elem), > IP_MAX_MTU + ETH_HLEN + VNET_HLEN, NULL); > diff --git a/vu_common.c b/vu_common.c > index b6753a556049..e32a56d881a3 100644 > --- a/vu_common.c > +++ b/vu_common.c > @@ -54,18 +54,19 @@ int vu_packet_check_range(struct vdev_memory *memory, > } > > /** > - * vu_init_elem() - initialize an array of virtqueue elements with 1 iov in each > - * @elem: Array of virtqueue elements to initialize > - * @iov: Array of iovec to assign to virtqueue element > - * @elem_cnt: Number of virtqueue element > + * vu_init_elem() - Initialize an array of virtqueue elements > + * @elem: Array of virtqueue elements to initialize > + * @iov: Array of iovecs to assign to virtqueue elements > + * @elem_cnt: Number of virtqueue elements > + * @iov_per_elem: Number of iovecs per element > */ > void vu_init_elem(struct vu_virtq_element *elem, struct iovec *iov, > - int elem_cnt) > + int elem_cnt, int iov_per_elem) > { > - int i; > + int i, j; > > - for (i = 0; i < elem_cnt; i++) > - vu_set_element(&elem[i], 0, NULL, 1, &iov[i]); > + for (i = 0, j = 0; i < elem_cnt; i++, j += iov_per_elem) > + vu_set_element(&elem[i], 0, NULL, iov_per_elem, &iov[j]); > } > > /** > @@ -268,7 +269,7 @@ int vu_send_single(const struct ctx *c, const void *buf, size_t size) > return -1; > } > > - vu_init_elem(elem, in_sg, ARRAY_SIZE(elem)); > + vu_init_elem(elem, in_sg, ARRAY_SIZE(elem), 1); > > size += VNET_HLEN; > elem_cnt = vu_collect(vdev, vq, elem, ARRAY_SIZE(elem), size, &total); > diff --git a/vu_common.h b/vu_common.h > index c1d2ce888f12..51639c04df14 100644 > --- a/vu_common.h > +++ b/vu_common.h > @@ -48,7 +48,7 @@ static inline void vu_set_element(struct vu_virtq_element *elem, > } > > void vu_init_elem(struct vu_virtq_element *elem, struct iovec *iov, > - int elem_cnt); > + int elem_cnt, int iov_per_elem); > int vu_collect(const struct vu_dev *vdev, struct vu_virtq *vq, > struct vu_virtq_element *elem, int max_elem, size_t size, > size_t *collected); > -- > 2.53.0 > -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson