Date: Sat, 9 Sep 2023 12:53:01 +0200 From: Vincenzo Maffione <vmaffione@freebsd.org> To: =?UTF-8?Q?Mina_Gali=C4=87?= <freebsd@igalic.co> Cc: freebsd-hackers <freebsd-hackers@freebsd.org>, "freebsd-virtualization@FreeBSD.org" <freebsd-virtualization@freebsd.org> Subject: Re: Question about virtio_alloc_virtqueues Message-ID: <CA%2B_eA9h_AAh95sJ7q1p3J4xCZcd73WWzHkA=BfR6dFYA=%2BG5uw@mail.gmail.com> In-Reply-To: <ia9RXdtQafOfdOfg9wml1ApOEb4ivdf8lbRf74J1XYzA8HIDoEWQ75ScEQY8DpmUHlfMraZmgY0XlgaMWid46UBEIOeCBiOQxsFI4TIoIW4=@igalic.co> References: <ia9RXdtQafOfdOfg9wml1ApOEb4ivdf8lbRf74J1XYzA8HIDoEWQ75ScEQY8DpmUHlfMraZmgY0XlgaMWid46UBEIOeCBiOQxsFI4TIoIW4=@igalic.co>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <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/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 <div dir=3D"ltr"><div>Hi,</div><div>=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.<br= ></div><div><br></div><div>However:</div><div><ul><li>per-virtqueue MSIX in= terrupts are now available (e.g. look at vtpci_setup_interrupts()), and</li= ><li>virtiqueues interrupt setup happens in a separate API, i.e. virtio_set= up_intr(), which takes care all the possible cases<br></li></ul><div>So as = far as I can tell that comment is not relevant anymore and can be removed t= ogether with the flags.</div><div>Unless I'm wrong, ofc.<br></div><div>= <br></div><div>Cheers,</div><div>=C2=A0 Vincenzo<br></div></div></div><br><= div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"gmail_attr">Il giorno v= en 8 set 2023 alle ore 21:05 Mina Gali=C4=87 <<a href=3D"mailto:freebsd@= igalic.co">freebsd@igalic.co</a>> ha scritto:<br></div><blockquote class= =3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rg= b(204,204,204);padding-left:1ex">Hi folks,<br> <br> for the past two or so weeks, I've been trying to document the<br> virtio functions: You can see some of my progress here:<br> <br> <a href=3D"https://codeberg.org/meena/freebsd-src/commits/branch/improve/vi= rtio" rel=3D"noreferrer" target=3D"_blank">https://codeberg.org/meena/freeb= sd-src/commits/branch/improve/virtio</a><br> <br> I'm currently trying to document virtio_alloc_virtqueues.<br> The second argument, flags, is only ever called with 0, and<br> never passed on to anything. So I thought I'd remove it.<br> However, there *is* this comment in if_vtnet.c:<br> <br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 /*<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* TODO: Enable interrupt binding if this = is multiqueue. This will<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0* only matter when per-virtqueue MSIX is = available.<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0*/<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (sc->vtnet_flags & VTNET_FLAG_MQ)<br> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 flags |=3D 0;<br> <br> <br> after which flags are still set to 0. for now??<br> What does this mean?<br> <br> Kind regards,<br> <br> Mina Gali=C4=87<br> <br> </blockquote></div> --00000000000046b0630604eae632--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CA%2B_eA9h_AAh95sJ7q1p3J4xCZcd73WWzHkA=BfR6dFYA=%2BG5uw>