From nobody Sat Sep 09 10:53:01 2023 X-Original-To: freebsd-virtualization@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RjVFP5lvpz4sxNV; Sat, 9 Sep 2023 10:53:13 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RjVFP5JrNz3bgZ; Sat, 9 Sep 2023 10:53:13 +0000 (UTC) (envelope-from vmaffione@freebsd.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694256793; 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: in-reply-to:in-reply-to:references:references; bh=pExO+lt8UHmK0kjUOnu0vVtEyLRQxvtCu3q+Tjnt/CU=; b=FIv2Paie/wYW9ptwp7jy0HuJa6IzyE4wUNSu8P0TmpT23FO88DQutR2OuBcLD+r+BrL/kd KC4aZ4EfvomYljt/XiC7Gn5+jTOxNBYzb1UAt5KgCv4zKQVhFYRzNMfWp6m1TFa4ycfZe1 3Y3sTn6r+sex5yEsvloLmc8l+5LMTwm4JIYmyznC9XET8RAORIgLcgHQ27xWEIVKhyjrr/ L5KK147q/pp62XvETlR1ZVucE4I4eVUNgrnVdKnjBs7nmeClnk89g7n88ISHtrXNSbEzIO yRkiGynQVK+fD5OQppQhYiRshNV0NDBwDtBswOi+CNKtOOTpfZDqfzjIKfGs9w== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1694256793; a=rsa-sha256; cv=none; b=pIkn/SOImdB7IyCUFa1M3ChfOWtXTEfU5462mZ1QNfJoZ6hFEvI59aNVlKGay646CC42CJ h9v5rvP+LYK8EDRHV/JXyCV9klmf0nK2oWEoWKn6fYdCuxQdbODigWqKmKBKusP6zINaHc GQLTE8BuAAszAzZqegc4fObCD5nDxmTDpzsJRLyBsOSjYTOQ4sV9j8b9d9suoecClx2Vkc H1EP/7cPFi+ZZqMdLYzuDuI/r8gDuY6Db3K9kaUgX+6JDmal1ciBVtw6iSxQ2p8g/UAJ3z bGt6OCmGdy4Q3Jzw3GcqIHMwC49x+PTY6fYSBNLm70V7OFFJauKuHgutkMT8tw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1694256793; 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: in-reply-to:in-reply-to:references:references; bh=pExO+lt8UHmK0kjUOnu0vVtEyLRQxvtCu3q+Tjnt/CU=; b=A8vroCiEW2k9xY6tFRqrPazTZJLYsWeScbohnfn/bKBD3R09bDOxF8KLt5rfYn3+mLRQX9 ndRxwkEE5dFX0Zv0G62BDnlsqIT0w8YQ/28pUsL3C9cocSRO7bu1vq2fSPxFAty/zsxky/ h8609RWxIUhC9qzjHFIVo2kgUJUxWs8X1aBP+v2V7MVQGYAdy2t5T+2hvx2P+1BGs3NKho 4adtQ9AsZ1nGSMqzuzz4uRsnHHNmXhRMuTxU4gA33snNrvV21o2/PTs/lLMnxyLspvX/sz VbJmaz7D7fDT2S6zDcKg1ZsuiO45VqCj9CQNgUQLDOf8xw6CmLhAy3InmGvhLQ== Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1D4" (verified OK)) (Authenticated sender: vmaffione) by smtp.freebsd.org (Postfix) with ESMTPSA id 4RjVFP4FSCz13ZX; Sat, 9 Sep 2023 10:53:13 +0000 (UTC) (envelope-from vmaffione@freebsd.org) Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-26d0d376ec7so2232334a91.2; Sat, 09 Sep 2023 03:53:13 -0700 (PDT) X-Gm-Message-State: AOJu0YxcGvqP/pzEUxDbThuSFlq1CLRBHykRSpJ1ZNXMxb1AgBpNKPLB OVFWnLpvuxLe0AwZqZAuitO5cFW87GqdjS0ll28= X-Google-Smtp-Source: AGHT+IHWQ3ufNTrDziqMyUjhpaZg9HYDJRQX1akkIzQFQxGTbCm8AJTyOayShiYr7/MZdFQKMLgzHEF4bi+s89OlVfQ= X-Received: by 2002:a17:90a:660f:b0:267:909f:3719 with SMTP id l15-20020a17090a660f00b00267909f3719mr4884793pjj.19.1694256792512; Sat, 09 Sep 2023 03:53:12 -0700 (PDT) List-Id: Discussion List-Archive: https://lists.freebsd.org/archives/freebsd-virtualization List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-virtualization@freebsd.org X-BeenThere: freebsd-virtualization@freebsd.org MIME-Version: 1.0 References: In-Reply-To: From: Vincenzo Maffione Date: Sat, 9 Sep 2023 12:53:01 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Question about virtio_alloc_virtqueues To: =?UTF-8?Q?Mina_Gali=C4=87?= Cc: freebsd-hackers , "freebsd-virtualization@FreeBSD.org" Content-Type: multipart/alternative; boundary="00000000000046b0630604eae632" --00000000000046b0630604eae632 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Looking at the code, it looks like that comment was written at a time where per-virtqueue MSIX interrupts were not available, and virtio_alloc_virtqueues() API was already designed to receive a flag to indicate that per-virtqueue MSIX interrupts were requested. The code you quoted would likely have been a simple placeholder, to be replaced with something like "flags |=3D VIRTIO_PERVQ_INTR" once the support had come. It= 's a very common pattern to start with setting flags =3D 0, and then bitwise o= r |=3D flags depending on the situation. However: - per-virtqueue MSIX interrupts are now available (e.g. look at vtpci_setup_interrupts()), and - virtiqueues interrupt setup happens in a separate API, i.e. virtio_setup_intr(), which takes care all the possible cases So as far as I can tell that comment is not relevant anymore and can be removed together with the flags. Unless I'm wrong, ofc. Cheers, Vincenzo Il giorno ven 8 set 2023 alle ore 21:05 Mina Gali=C4=87 = ha scritto: > Hi folks, > > for the past two or so weeks, I've been trying to document the > virtio functions: You can see some of my progress here: > > https://codeberg.org/meena/freebsd-src/commits/branch/improve/virtio > > I'm currently trying to document virtio_alloc_virtqueues. > The second argument, flags, is only ever called with 0, and > never passed on to anything. So I thought I'd remove it. > However, there *is* this comment in if_vtnet.c: > > /* > * TODO: Enable interrupt binding if this is multiqueue. This wil= l > * only matter when per-virtqueue MSIX is available. > */ > if (sc->vtnet_flags & VTNET_FLAG_MQ) > flags |=3D 0; > > > after which flags are still set to 0. for now?? > What does this mean? > > Kind regards, > > Mina Gali=C4=87 > > --00000000000046b0630604eae632 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,
=C2=A0 Looking at the code, it looks li= ke that comment was written at a time where per-virtqueue MSIX interrupts w= ere not available, and virtio_alloc_virtqueues() API was already designed t= o receive a flag to indicate that per-virtqueue MSIX interrupts were reques= ted. The code you quoted would likely have been a simple placeholder, to be= replaced with something like "flags |=3D VIRTIO_PERVQ_INTR" once= the support had come. It's a very common pattern to start with setting= flags =3D 0, and then bitwise or |=3D flags depending on the situation.

However:
  • per-virtqueue MSIX in= terrupts are now available (e.g. look at vtpci_setup_interrupts()), and
  • virtiqueues interrupt setup happens in a separate API, i.e. virtio_set= up_intr(), which takes care all the possible cases
So as = far as I can tell that comment is not relevant anymore and can be removed t= ogether with the flags.
Unless I'm wrong, ofc.
=
Cheers,
=C2=A0 Vincenzo

<= div class=3D"gmail_quote">
Il giorno v= en 8 set 2023 alle ore 21:05 Mina Gali=C4=87 <freebsd@igalic.co> ha scritto:
Hi folks,

for the past two or so weeks, I've been trying to document the
virtio functions: You can see some of my progress here:

https://codeberg.org/meena/freeb= sd-src/commits/branch/improve/virtio

I'm currently trying to document virtio_alloc_virtqueues.
The second argument, flags, is only ever called with 0, and
never passed on to anything. So I thought I'd remove it.
However, there *is* this comment in if_vtnet.c:

=C2=A0 =C2=A0 =C2=A0 =C2=A0 /*
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* TODO: Enable interrupt binding if this = is multiqueue. This will
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* only matter when per-virtqueue MSIX is = available.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/
=C2=A0 =C2=A0 =C2=A0 =C2=A0 if (sc->vtnet_flags & VTNET_FLAG_MQ)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 flags |=3D 0;


after which flags are still set to 0. for now??
What does this mean?

Kind regards,

Mina Gali=C4=87

--00000000000046b0630604eae632--