Date: Tue, 6 Jun 2023 06:04:28 +0100 From: Jessica Clarke <jrtc27@freebsd.org> To: Warner Losh <imp@bsdimp.com> Cc: Xin LI <delphij@freebsd.org>, src-committers <src-committers@freebsd.org>, "<dev-commits-src-all@freebsd.org>" <dev-commits-src-all@freebsd.org>, "<dev-commits-src-main@freebsd.org>" <dev-commits-src-main@freebsd.org> Subject: Re: git: 1bbdfb0b4386 - main - gve: Add PNP info to PCI attachment of gve(4) driver. Message-ID: <DC93BFBE-CDAE-4C12-BE01-24C24D7EE5B0@freebsd.org> In-Reply-To: <CANCZdfpKY4OYKcuyEfD0bJ06NzaTj6PKmyWBm=uSt6vfy1qzqA@mail.gmail.com> References: <202306060406.35646hbA078041@gitrepo.freebsd.org> <6A5F859A-033A-43E1-81CB-B364662DE2F3@freebsd.org> <CANCZdfpKY4OYKcuyEfD0bJ06NzaTj6PKmyWBm=uSt6vfy1qzqA@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 6 Jun 2023, at 05:31, Warner Losh <imp@bsdimp.com> wrote: >=20 >=20 >=20 > On Mon, Jun 5, 2023, 10:15 PM Jessica Clarke <jrtc27@freebsd.org> = wrote: > On 6 Jun 2023, at 05:06, Xin LI <delphij@FreeBSD.org> wrote: > >=20 > > The branch main has been updated by delphij: > >=20 > > URL: = https://cgit.FreeBSD.org/src/commit/?id=3D1bbdfb0b438689a839e29094fcb582a1= 04cbabd9 > >=20 > > commit 1bbdfb0b438689a839e29094fcb582a104cbabd9 > > Author: Xin LI <delphij@FreeBSD.org> > > AuthorDate: 2023-06-06 00:58:43 +0000 > > Commit: Xin LI <delphij@FreeBSD.org> > > CommitDate: 2023-06-06 04:05:55 +0000 > >=20 > > gve: Add PNP info to PCI attachment of gve(4) driver. > >=20 > > Reviewed-by: imp > > Differential Revision: https://reviews.freebsd.org/D40429 > > --- > > sys/dev/gve/gve_main.c | 28 ++++++++++++++++++++++++---- > > 1 file changed, 24 insertions(+), 4 deletions(-) > >=20 > > diff --git a/sys/dev/gve/gve_main.c b/sys/dev/gve/gve_main.c > > index ae45a0cfc24a..383fd326d33a 100644 > > --- a/sys/dev/gve/gve_main.c > > +++ b/sys/dev/gve/gve_main.c > > @@ -38,6 +38,16 @@ > >=20 > > #define GVE_DEFAULT_RX_COPYBREAK 256 > >=20 > > +/* Devices supported by this driver. */ > > +static struct gve_dev { > > + uint16_t vendor_id; > > + uint16_t device_id; > > + const char *name; > > +} gve_devs[] =3D { > > + { PCI_VENDOR_ID_GOOGLE, PCI_DEV_ID_GVNIC, "gVNIC" } > > +}; > > +#define GVE_DEVS_COUNT nitems(gve_devs) >=20 > IMO this obfuscates rather than helps given the loop iterates over > gve_devs (and the macro references it). >=20 > > + > > struct sx gve_global_lock; > >=20 > > static int > > @@ -701,10 +711,18 @@ gve_service_task(void *arg, int pending) > > static int > > gve_probe(device_t dev) > > { > > - if (pci_get_vendor(dev) =3D=3D PCI_VENDOR_ID_GOOGLE && > > - pci_get_device(dev) =3D=3D PCI_DEV_ID_GVNIC) { > > - device_set_desc(dev, "gVNIC"); > > - return (BUS_PROBE_DEFAULT); > > + uint16_t deviceid, vendorid; > > + int i; > > + > > + vendorid =3D pci_get_vendor(dev); > > + deviceid =3D pci_get_device(dev); > > + > > + for (i =3D 0; i < GVE_DEVS_COUNT; i++) { > > + if (vendorid =3D=3D gve_devs[i].vendor_id && > > + deviceid =3D=3D gve_devs[i].device_id) { > > + device_set_desc(dev, gve_devs[i].name); > > + return (BUS_PROBE_DEFAULT); > > + } > > } > > return (ENXIO); > > } > > @@ -851,3 +869,5 @@ DRIVER_MODULE(gve, pci, gve_driver, = gve_devclass, 0, 0); > > #else > > DRIVER_MODULE(gve, pci, gve_driver, 0, 0); > > #endif > > +MODULE_PNP_INFO("U16:vendor;U16:device", pci, gve, gve_devs, >=20 > This is missing ;D:# so it will break as soon as you have a second > entry in the table. >=20 > While the first bit is true, I though we encoded the per entry size so = trailing garbage didn't matter.. d# will be more useful in the future = maybe. Hm indeed you=E2=80=99re right. Might as well include it still though. Jess > Warner >=20 > Jess >=20 > > + GVE_DEVS_COUNT);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DC93BFBE-CDAE-4C12-BE01-24C24D7EE5B0>