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=D+a17hda; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 511A15A0625 for ; Thu, 11 Dec 2025 13:16:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765455384; 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=/QwtATG5U1OfqaRU+iQNGf0OinVx3RvGNWmrBZ6WvAE=; b=D+a17hdaecRtrgT5o+tzO2CmHD8PF6KyHd6zRWcQtl0BDFAwJrqCHzzVWOXpoCAb3BB0IV t3eCsuy0A40dX01tihKY+zHneGJiX0LGqkQFo4m+x5YKoH3eLfam3JEx8dQVLpnRCBpx2e Zlw1lFqsy6NPMzyyp7uWQg8yBEvTlBo= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-80-GnEnhablOHeR7iwVi9FJjg-1; Thu, 11 Dec 2025 07:16:23 -0500 X-MC-Unique: GnEnhablOHeR7iwVi9FJjg-1 X-Mimecast-MFC-AGG-ID: GnEnhablOHeR7iwVi9FJjg_1765455382 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-477964c22e0so292205e9.0 for ; Thu, 11 Dec 2025 04:16:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765455381; x=1766060181; 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=/QwtATG5U1OfqaRU+iQNGf0OinVx3RvGNWmrBZ6WvAE=; b=Qs870BZCBDFBV94IN6hNv4fMipsNBjndThzdcLoj8kREJVdFWuE8bMRN3oyon5wesg ouwsogj53AHg+ii4ZLzGqCGdmzPJb71vuTkVFHbIF8BJ9xLNQbNoGmw2kWxMLeIhGOoh A+Q7+gWMKBVd0aySeo6BYb/yBiVHa0g/7FNSmt9KT2CejEj9uJWnBFFvbK5kx6Zeu24Q eGAb59j+jYwxxq/xAxR3TN2C6FRlq2pycLvqiolYSZ45mKL+suD8HJr2xFIMwEmWw7/e kqFUY7G+XOLJbY3qI2uvOpehUcHIAne2yyFy51u37wi9+wTNxrWMRmCO6j6hL4jMny73 M3mg== X-Gm-Message-State: AOJu0YwBKVLpAOk5stiEQ9s38msjgDiA60nfF5+J95yksufEtWzjd2KD Af7FaO0OthnO+LdXhgpgf3WTJT0qiiyZ44pzlYy+MdPEgPvECa2gDAShsJfhblSDx7rrEAYegwD 6vCI6YKFeepHDB+5SJ3UU0+gR4guok9u2E7qljvnxH/fpRJoFrQI41eouOPJnLZO+UhyCPVxFMo lswMaq49zhMkC+LLVUDtvcO4bSbbTjV6FvaHZh X-Gm-Gg: AY/fxX6uP/mEk2y4GcCNUJuI595lRpJTSHFBSwP5rPKGENfvPbaM3hE//8vLKRSZPol IBasD8VRqrpxGdmM6ith54jzWo8InZYMS0rDHXF53vi3+UKyHx5b3B1vs74kgoTU0d2VqJX5GCu 1RBAt/KN4/Jf7OQSjoVvuD9pR2zFSqPWRosUekXXMmd1uFmJoEfEk4rvQMaZnjJKxg1BJ82kCGc aOdsxL0UqfBe7ICUehiGNsiNkWMfqYBn8UlN28Oj1psvdTKU4Z9ySTiONovGezCiXteZZzX8wfA AqiB0bls+XI8+7IylpxPrGvpEWXTkF75ukBCVEPyajhHAUCLKAgAjg78PI5qluB5COhamSdIdrE 0tSZHodNTOgk2Qvzlzyq4 X-Received: by 2002:a05:600c:2218:b0:471:793:e795 with SMTP id 5b1f17b1804b1-47a89d2c84bmr12600845e9.0.1765455380900; Thu, 11 Dec 2025 04:16:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IExTzv50G0/5bBkWeBDOSxzhFe/ZTp3KlNEM2Y09mVnfhk702coZGM1u54iTIbFBwTTxWqJbw== X-Received: by 2002:a05:600c:2218:b0:471:793:e795 with SMTP id 5b1f17b1804b1-47a89d2c84bmr12600515e9.0.1765455380266; Thu, 11 Dec 2025 04:16:20 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42fa8b9b259sm5158485f8f.41.2025.12.11.04.16.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 04:16:19 -0800 (PST) Date: Thu, 11 Dec 2025 13:16:18 +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: <20251211131618.1b5dac57@elisabeth> In-Reply-To: <85c1c222-dbd6-410d-96e3-9b000795919f@redhat.com> References: <20251203185435.582096-1-lvivier@redhat.com> <20251203185435.582096-5-lvivier@redhat.com> <20251211080144.72d9577f@elisabeth> <85c1c222-dbd6-410d-96e3-9b000795919f@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: tPOgfJb-JKg-V6jLYh2AXpQN5vY-Ex55oUcydzIpckk_1765455382 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: PWBE73SRSFNQK3QGJHS74PQWBPUTN57S X-Message-ID-Hash: PWBE73SRSFNQK3QGJHS74PQWBPUTN57S 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 Thu, 11 Dec 2025 09:48:42 +0100 Laurent Vivier wrote: > On 12/11/25 08:01, Stefano Brivio wrote: > > 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) > > I will. David had the same comment. Uh, wait, I must have missed it. Do you have a Message-ID? I'm afraid I must have missed some emails here but I don't see them in archives either... > TX and RX are from the point of view of guest, it's > not obvious when we read passt code. Right, yes, for me neither, I always get confused. That's why I thought we could make the RX vhost-user queue become "SEND" in passt's code, but: > I would prefer as David proposed to use, i.e. FROMGUEST and TOGUEST: > > #define VHOST_FROM_GUEST(qpair) ((qpair) * 2 + 1) > #define VHOST_TO_GUEST(qpair) ((qpair) * 2) ...this is even clearer. It misses the QUEUE though. Does VHOST_QUEUE_{FROM,TO}_GUEST fit where you use it? Otherwise I guess VQ together with FROM / TO should be clear enough. > > and: > > > > #define VHOST_QUEUE_PAIR(q) ((q) % 2) ? (q) : (q) / 2) > > I don't undestand the purpose of this one. To get the pair number from a queue number. You're doing something like that (I guess?) in 5/6, vu_handle_tx(): + tap_flush_pools(index / 2); + tap_add_packet(vdev->context, index / 2, &data, now); + tap_handler(vdev->context, index / 2, now); but now that I see your definition for VHOST_FROM_GUEST() above, and that the purpose wasn't clear to you, I guess it should be: #define VHOST_PAIR_FROM_QUEUE(q) (((q) % 2) ? ((q) - 1 / 2) : ((q) / 2)) ...or maybe it's not needed? I'm not sure. > > > > ...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 > > It's not really NO_QUEUE, it's default queue pair, the queue pair 0 Hmm but for non-vhost-user usages then it's not a queue, right? Well, whatever, as long as we have a definition for it... or maybe we could have VHOST_QUEUE_DEFAULT and NO_VHOST_QUEUE or VHOST_NO_QUEUE all being 0? -- Stefano