From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: passt.top; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=PLtNAUkj; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by passt.top (Postfix) with ESMTPS id 6E9365A026E for ; Wed, 12 Aug 2026 20:45:15 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4994c49f588so1854695e9.0 for ; Wed, 12 Aug 2026 11:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786560315; x=1787165115; darn=passt.top; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=geI5f25gqOKWKeNBujSXkIPmjrAy8Te4iZPR3YdRLes=; b=PLtNAUkjNgELkq3yJAwItmefVMNZhfp6gP5OdBizkWRw6sIFVfcMc42o30YziHDQSk j6j/2cS8E7mC9PHbC8WEBhHYBbqC6RbbvfVdH8qrGnWXWon91nrB9rdHxPz5zsrPHHor WtVHs6kzY8xx5eFKVF/Xb5HL9yx+GHDwWDHUthVuQhsPIgDFmUxK7xLbdvmBJp9BUYrA yxevH/59tATIwZB8gyeHzTNFOKx4G90/oJKLs+2rCTtZH/7P41Gfx3THXeaMaoyWB2Ah mtF94NZ9U6SwTKrNHa9jTaS2IfbaM1WeZCvpqAYRcPW0MvN2Jq2L8cso+vNzjOScT0tk 5goQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786560315; x=1787165115; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :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r/1FlfjTACA== X-Received: by 2002:a05:600c:4f8b:b0:499:596b:2e91 with SMTP id 5b1f17b1804b1-499819bd4cfmr15576915e9.3.1786560314805; Wed, 12 Aug 2026 11:45:14 -0700 (PDT) Received: from localhost ([196.157.64.51]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49981b34b5csm7943855e9.8.2026.08.12.11.45.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2026 11:45:14 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 12 Aug 2026 21:45:12 +0300 Message-Id: Subject: Re: [RFC v3 8/8] tap: Implement pasta vhost TX From: "Ammar Yasser" To: "David Gibson" , "Ammar Yasser" X-Mailer: aerc 0.21.0 References: <20260802132155.870796-1-aerosound161@gmail.com> <20260802132155.870796-9-aerosound161@gmail.com> In-Reply-To: Message-ID-Hash: X7EDZXYIXSCIUXX7QRD4DQ5XK5MKDIOI X-Message-ID-Hash: X7EDZXYIXSCIUXX7QRD4DQ5XK5MKDIOI X-MailFrom: aerosound161@gmail.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, eperezma@redhat.com 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 Mon Aug 10, 2026 at 12:18 PM EEST, David Gibson wrote: > On Sun, Aug 02, 2026 at 01:21:55PM +0000, Ammar Yasser wrote: >> Callers will specify whether vhost should be used or no by passing the >> vhost argument to tap_send_frames_pasta. If specified, sending will go >> through a function called tap_send_frames_vhost, which pops a descriptor >> from the queue shared with the kernel and sets the address of that >> descriptor to be the base address of a single iov from the group of >> buffers_per_frame * nframes iovs we pass to the function >>=20 >> Signed-off-by: Ammar Yasser > > Sorry, didn't spot this earlier in the series: if these are based on > Eugenio's earlier patches, they should have his Signed-off-by in > addition to your own. They have significantly diverged in both order and structure so there's no clear mapping between mine and his anymore. if there doesn't need to be a mapping i'm happy to add his Signed-off-by. Otherwise, i did mention his original series in the cover letter > >> --- >> tap.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 file changed, 107 insertions(+), 1 deletion(-) >>=20 >> diff --git a/tap.c b/tap.c >> index e177eef..66bb71d 100644 >> --- a/tap.c >> +++ b/tap.c >> @@ -361,7 +361,32 @@ void tap_icmp6_send(const struct ctx *c, >> } >> =20 >> /** >> - * tap_send_frames_pasta() - Send multiple frames to the pasta tap >> + * tx_reap() - Reclaim the descriptors the kernel has already processed >> + */ >> +static void tx_reap(void) { >> + struct vring_used *used =3D &vring_used_all[1].used; >> + uint16_t used_idx =3D le16toh(used->idx); >> + >> + smp_rmb(); >> + >> + /* increment last_used_idx until it reaches the kernel's used index */ >> + while (vqs[1].last_used_idx !=3D used_idx) { >> + uint16_t desc_id =3D le32toh(used->ring[vqs[1].last_used_idx % VHOST_= NDESCS].id); >> + =09 >> + for (;;) { >> + /* keep going until we find a descriptor without the next flag */ >> + vqs[1].num_free++; >> + if (!(le16toh(vring_desc[1][desc_id].flags) & VRING_DESC_F_NEXT)) >> + break; >> + /* this descriptor wasn't the last, set desc_id to the next one and = keep going */ >> + desc_id =3D le16toh(vring_desc[1][desc_id].next); >> + } >> + vqs[1].last_used_idx++; >> + } >> +} >> + >> +/** >> + * tap_send_frames_vhost() - Send multiple frames to the pasta tap >> * @c: Execution context >> * @iov: Array of buffers >> * @bufs_per_frame: Number of buffers (iovec entries) per frame >> @@ -371,6 +396,84 @@ void tap_icmp6_send(const struct ctx *c, >> * @bufs_per_frame contiguous buffers representing a single frame. >> * >> * Return: number of frames successfully sent >> + */ >> +static size_t tap_send_frames_vhost(const struct ctx *c, >> + const struct iovec *iov, >> + size_t bufs_per_frame, size_t nframes) >> +{ >> + size_t i; >> + size_t processed_frames =3D 0; > > Reverse christmas tree. Noted > >> + >> + /* update our local counters first */ >> + tx_reap(); >> + >> + #define AVAIL_Q(i)(vring_avail_all[i].avail) > > # for preprocessor directives should always go in column 0. Ok > >> + >> + for (i =3D 0; i < nframes; i++) { >> + size_t j; >> + >> + if (vqs[1].num_free < bufs_per_frame) >> + break; > > IIRC, we were discussing during the last call that at least for the > first version it's fine if we synchronously wait for buffers to be > available. Since then it occurred to me that another acceptable > option would be to simply drop frames if there are no available > buffers (this is kind of how IP is designed to work - congestion is > reported implicitly as packet loss). Do whichever is easier for now > and it can be refined later. Will do > >> + >> + /* set the index of the avail ring in the tx queue to be our last_use= d_idx */ >> + uint16_t head =3D vqs[1].next_free % VHOST_NDESCS; > > No inline decls. Ok