From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fh3W5FNc; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 5ED275A0652 for ; Thu, 11 Dec 2025 08:01:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765436511; 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=MpmOHWXqJ5jY8s2Z3rCBxjf7i3FxpLOz8z9MtKVvUnk=; b=fh3W5FNcgcy/aT5noVu9XuCHu0A0lsL2+oL3aRmsR0JpznXz1EF8Ucy3C4P8M6etdTAlnE w2abGatD4EnNavEqcS6W23/UHkbL5du6snkcj1xejjENTrGx/5XoiH2Q+ZduZ33LOn5kwy Tej89EUJ7DHexHCh9005nC2zxiu2amY= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-617-tNQxytm9Pv-Yl4OBcWJtVA-1; Thu, 11 Dec 2025 02:01:49 -0500 X-MC-Unique: tNQxytm9Pv-Yl4OBcWJtVA-1 X-Mimecast-MFC-AGG-ID: tNQxytm9Pv-Yl4OBcWJtVA_1765436508 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-42e2e447e86so232381f8f.3 for ; Wed, 10 Dec 2025 23:01:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765436508; x=1766041308; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=MpmOHWXqJ5jY8s2Z3rCBxjf7i3FxpLOz8z9MtKVvUnk=; b=fQFOwoUQryq5z5eviDdzPh5emR7HumSZhR1QMh2d9gDywm6bxmSqWvLIXZW1Y6y1Jp azYA7qVsKhAWoWY2psH7QLtBGjqdjvi5xsXyncVCMQR+pK81HlZCbmI94ja4FFyreb1q V+DPlREr3KIfkG2WIyDtKi/a39Nj6pO0n+galOdbM8lB3AJ+WKqcRzfgCITywcRXeYYJ nyWonLkG83HllwhjQnubhTlqmaltPwmPocK4t0CkI2ofCMsLYVW/VEYvhCdGkAw0A+h1 A9hmRucdxHecVUKXE1hI4n0Ry0yhsrOK0IIJn9lez/RRSeMhhlN8ycJsAhwxVEsJbc2W zcNA== X-Gm-Message-State: AOJu0Yxb5VNC4gP91n7iv9AdLfCskckm1JfEk5elL1V2j0v+r/39n0tK /1QU7zZ2DEho5q7lWCJ+T2VI5V1hCPx8mM8zHJB4x0PvgMJWYN6CrNHwP4jzFhYe+myeUE4B9F5 0B7u0ygAL4PzWtZ+ohKLMY8S8szIBgzVDgUk7IVLFEVTgwRxR7CUPBWJO3SIJKMdCCyMIFNMwzk HlZqGkDBj2a33/lmmTyn2VXTocLlmnStkC8QsW X-Gm-Gg: AY/fxX4kJiOzhoVcS8PsBY5Oxtm9C5kl6S0MarMGi/chAsQtrfDjDi1EYKpODdGRABT xRWav4f8uremSPqAjorlHI4SG5j/N2mK01FqsZjwmsoNEVfZZWE/rpPgoIS2BqyAWZDIgeGywk6 Tvu3fEnvIC4ujXsm2luSTgzHl+u3t8vR/bLr8W3YY6L6HS1QpbW43gIqi5pZqAuJk0ecG5JInRR E3JaOlltj4TjEbNOnk+zv5ODaEv/GrRSUNEfRSaIfyTlD55Dm++HAJnzCOvw/P9/HeT41Yc4AWB OCTBvFSPfKuqS0mAKFuTEshqgRoeE/yekbgwDTG8nLu45PEAb3xdEveLVwNaTCAtHKZ9QS5mJh0 ixcIvu5Ecx04MPDnVJGSGRW4vmPzMLyBLNZ0svg== X-Received: by 2002:a05:6000:26ca:b0:42b:3023:66a9 with SMTP id ffacd0b85a97d-42fa39d2ed4mr5023913f8f.22.1765436507533; Wed, 10 Dec 2025 23:01:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHIrUmU8WAq4T0vUx4UjHGicD4+qi9M99RshOi+rQ6ab6GEiRUMb3ivjHK1+a3GEzKELShtVg== X-Received: by 2002:a05:6000:26ca:b0:42b:3023:66a9 with SMTP id ffacd0b85a97d-42fa39d2ed4mr5023846f8f.22.1765436506738; Wed, 10 Dec 2025 23:01:46 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8b85dd1sm3833515f8f.20.2025.12.10.23.01.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Dec 2025 23:01:46 -0800 (PST) Date: Thu, 11 Dec 2025 08:01:44 +0100 From: Stefano Brivio To: Laurent Vivier Subject: Re: [PATCH v3 4/6] vhost-user: Add queue pair parameter throughout the network stack Message-ID: <20251211080144.72d9577f@elisabeth> In-Reply-To: <20251203185435.582096-5-lvivier@redhat.com> References: <20251203185435.582096-1-lvivier@redhat.com> <20251203185435.582096-5-lvivier@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tysG4B4fvONj3fGIUtA7Zs0M3hQ1J5fOSiYoCavkWEg_1765436508 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: LAZPUZ45DDA27GSLY572NBN2IJWKEJCV X-Message-ID-Hash: LAZPUZ45DDA27GSLY572NBN2IJWKEJCV X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Wed, 3 Dec 2025 19:54:32 +0100 Laurent Vivier wrote: > diff --git a/vu_common.c b/vu_common.c > index b13b7c308fd8..80d9a30f6f71 100644 > --- a/vu_common.c > +++ b/vu_common.c > @@ -196,11 +196,11 @@ static void vu_handle_tx(struct vu_dev *vdev, int index, > > data = IOV_TAIL(elem[count].out_sg, elem[count].out_num, 0); > if (IOV_DROP_HEADER(&data, struct virtio_net_hdr_mrg_rxbuf)) > - tap_add_packet(vdev->context, &data, now); > + tap_add_packet(vdev->context, 0, &data, now); > > count++; > } > - tap_handler(vdev->context, now); > + tap_handler(vdev->context, 0, now); > > if (count) { > int i; > @@ -235,23 +235,26 @@ void vu_kick_cb(struct vu_dev *vdev, union epoll_ref ref, > } > > /** > - * vu_send_single() - Send a buffer to the front-end using the RX virtqueue > + * vu_send_single() - Send a buffer to the front-end using a specified virtqueue > * @c: execution context > + * @qpair: Queue pair on which to send the buffer > * @buf: address of the buffer > * @size: size of the buffer > * > * Return: number of bytes sent, -1 if there is an error > */ > -int vu_send_single(const struct ctx *c, const void *buf, size_t size) > +int vu_send_single(const struct ctx *c, unsigned int qpair, const void *buf, size_t size) > { > struct vu_dev *vdev = c->vdev; > - struct vu_virtq *vq = &vdev->vq[VHOST_USER_RX_QUEUE]; > struct vu_virtq_element elem[VIRTQUEUE_MAX_SIZE]; > struct iovec in_sg[VIRTQUEUE_MAX_SIZE]; > + struct vu_virtq *vq; > size_t total; > int elem_cnt; > int i; > > + vq = &vdev->vq[qpair << 1]; << 1 instead of * 2 is a bit surprising here, for a few seconds I thought you swapped qpair and 1. Then I started thinking that somebody is likely to mix up (probably not you) indices of RX and TX queues at some point. So... what about some macros, say (let's see if I got it right this time): #define VHOST_SEND_QUEUE(pair) ((pair) * 2) #define VHOST_RECV_QUEUE(pair) (pair) and: #define VHOST_QUEUE_PAIR(q) ((q) % 2) ? (q) : (q) / 2) ...are they correct? A short description or "Theory of operation" section somewhere with a recap of how queue indices are used would be nice to have. And maybe also something explaining that 0 that's now appearing in argument lists: #define VHOST_NO_QUEUE 0 ? > + > trace("vu_send_single size %zu", size); > > if (!vu_queue_enabled(vq) || !vu_queue_started(vq)) { > diff --git a/vu_common.h b/vu_common.h > index f538f237790b..9ceb8034a9a5 100644 > --- a/vu_common.h > +++ b/vu_common.h > @@ -56,6 +56,7 @@ void vu_flush(const struct vu_dev *vdev, struct vu_virtq *vq, > struct vu_virtq_element *elem, int elem_cnt); > void vu_kick_cb(struct vu_dev *vdev, union epoll_ref ref, > const struct timespec *now); > -int vu_send_single(const struct ctx *c, const void *buf, size_t size); > +int vu_send_single(const struct ctx *c, unsigned int qpair, const void *buf, > + size_t size); > > #endif /* VU_COMMON_H */ I'm still reviewing the rest, currently at 5/6. -- Stefano