Module Name:    src
Committed By:   pgoyette
Date:           Tue Jun 29 21:03:37 UTC 2021

Modified Files:
        src/lib/libpci: Makefile
        src/sys/arch/arm/amlogic: gxlphy.c
        src/sys/dev: dev_verbose.c dev_verbose.h devlist2h.awk
        src/sys/dev/hdaudio: hdaudio.c
        src/sys/dev/mii: Makefile.miidevs gentbi.c mii_physubr.c mii_verbose.c
            mii_verbose.h miivar.h ukphy.c
        src/sys/dev/pci: pci_subr.c
        src/sys/dev/pci/ixgbe: ixgbe.c
        src/sys/rump/librump/rumpdev: Makefile.rumpdev
        src/sys/sys: param.h
Removed Files:
        src/sys/dev/mii: devlist2h.awk

Log Message:
Rework the xxxVERBOSE option to share the common module-hook-based
verbose mechanism with MIIVERBOSE.  This reduces some duplicated code
and allows us to once again permit auto-unload of MIIVERBOSE.

Change details:
* Update dev/devlist2h.awk to accomodate miidevs, including generation
  of MII_STR_oui_model definitions and use of oui and model rather than
  vendor and product.  This also changes the compressed data in the
  xxxdevs_data.h files to uint32_t (since mii oui's are up to 6 hex
  digits long)
* Update a couple of phy drivers to use new calls to get verbose data
* Regen all of the xxxdevs{,_data}.h files (separate commit, coming
  very soon)
* Update mii/mii_verbose.[ch] and mii/mii_physubr.c to use the various
  DEV_VERBOSE_xxx macros
* Update the pci, usb, and hdaudio code as needed, to #include the
  xxxdevs.h files (in order to get the proper printf format strings)
* Since dev/dev_verbose.c now uses non-literal printf format strings,
  (to deal with the vendor/product vs oui/model issue), we need to
  make sure it gets compiled with -Wno-error=format-nonliteral, even
  in userland's libpci and librumpdev!
* Bump kernel version for the change in module interfaces

Welcome to 9.99.86!

XXX It might be useful in the future to extend the MII_STR_oui_model
XXX definitions to PCI as well (and perhaps USB and HDAUDIO).  This
XXX would allow for a single centralized location for the products'
XXX descriptions, rather than being dispersed among individual
XXX drivers' xxx_match tables.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/lib/libpci/Makefile
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/amlogic/gxlphy.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/dev_verbose.c src/sys/dev/devlist2h.awk
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/dev_verbose.h
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/hdaudio/hdaudio.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/mii/Makefile.miidevs
cvs rdiff -u -r1.11 -r0 src/sys/dev/mii/devlist2h.awk
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/mii/gentbi.c
cvs rdiff -u -r1.94 -r1.95 src/sys/dev/mii/mii_physubr.c
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/mii/mii_verbose.c
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/mii/mii_verbose.h
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/mii/miivar.h
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/mii/ukphy.c
cvs rdiff -u -r1.225 -r1.226 src/sys/dev/pci/pci_subr.c
cvs rdiff -u -r1.284 -r1.285 src/sys/dev/pci/ixgbe/ixgbe.c
cvs rdiff -u -r1.13 -r1.14 src/sys/rump/librump/rumpdev/Makefile.rumpdev
cvs rdiff -u -r1.696 -r1.697 src/sys/sys/param.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libpci/Makefile
diff -u src/lib/libpci/Makefile:1.5 src/lib/libpci/Makefile:1.6
--- src/lib/libpci/Makefile:1.5	Sun Sep 21 14:32:37 2014
+++ src/lib/libpci/Makefile	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.5 2014/09/21 14:32:37 christos Exp $
+#	$NetBSD: Makefile,v 1.6 2021/06/29 21:03:36 pgoyette Exp $
 
 .include <bsd.own.mk>
 
@@ -10,6 +10,8 @@ SYSDIR= ${NETBSDSRCDIR}/sys/
 .PATH.c: ${SYSDIR}/dev/pci ${SYSDIR}/dev
 CPPFLAGS+= -I${SYSDIR}
 
+COPTS.dev_verbose.c+= -Wno-error=format-nonliteral
+
 MAN=	pci.3
 
 MLINKS=	pci.3 pcibus_conf_read.3 \

Index: src/sys/arch/arm/amlogic/gxlphy.c
diff -u src/sys/arch/arm/amlogic/gxlphy.c:1.4 src/sys/arch/arm/amlogic/gxlphy.c:1.5
--- src/sys/arch/arm/amlogic/gxlphy.c:1.4	Sat Mar 28 18:37:18 2020
+++ src/sys/arch/arm/amlogic/gxlphy.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: gxlphy.c,v 1.4 2020/03/28 18:37:18 thorpej Exp $ */
+/* $NetBSD: gxlphy.c,v 1.5 2021/06/29 21:03:36 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2019 Jared McNeill <jmcne...@invisible.ca>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gxlphy.c,v 1.4 2020/03/28 18:37:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gxlphy.c,v 1.5 2021/06/29 21:03:36 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -148,9 +148,10 @@ gxlphyattach(device_t parent, device_t s
 	int oui = MII_OUI(ma->mii_id1, ma->mii_id2);
 	int model = MII_MODEL(ma->mii_id2);
 	int rev = MII_REV(ma->mii_id2);
-	const char *descr;
+	char descr[MII_MAX_DESCR_LEN];
 
-	if ((descr = mii_get_descr(oui, model)) != NULL)
+	mii_get_descr(descr, sizeof(descr), oui, model);
+	if (descr[0])
 		aprint_normal(": %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
 		       descr, oui, model, rev);
 	else

Index: src/sys/dev/dev_verbose.c
diff -u src/sys/dev/dev_verbose.c:1.3 src/sys/dev/dev_verbose.c:1.4
--- src/sys/dev/dev_verbose.c:1.3	Wed Oct 26 06:10:39 2016
+++ src/sys/dev/dev_verbose.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dev_verbose.c,v 1.3 2016/10/26 06:10:39 pgoyette Exp $	*/
+/*	$NetBSD: dev_verbose.c,v 1.4 2021/06/29 21:03:36 pgoyette Exp $	*/
 
 /*
  * Redistribution and use in source and binary forms, with or without
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dev_verbose.c,v 1.3 2016/10/26 06:10:39 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dev_verbose.c,v 1.4 2021/06/29 21:03:36 pgoyette Exp $");
 
 #include <sys/param.h>
 
@@ -37,7 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: dev_verbose.
 #include <dev/dev_verbose.h>
 
 static const char *
-dev_untokenstring(const char *words, const uint16_t *token, char *buf,
+dev_untokenstring(const char *words, const uint32_t *token, char *buf,
     size_t len)
 {
 	char *cp = buf;
@@ -58,7 +58,8 @@ dev_untokenstring(const char *words, con
 
 const char *
 dev_findvendor(char *buf, size_t len, const char *words, size_t nwords,
-    const uint16_t *vendors, size_t nvendors, uint16_t vendor)
+    const uint32_t *vendors, size_t nvendors, uint32_t vendor,
+    const char *fmt)
 {
 	size_t n;
 
@@ -72,14 +73,14 @@ dev_findvendor(char *buf, size_t len, co
 		while (n < nvendors && vendors[n] != 0)
 			n++;
 	}
-	snprintf(buf, len, "vendor %4.4x", vendor);
+	snprintf(buf, len, fmt, vendor);
 	return NULL;
 }
 
 const char *
 dev_findproduct(char *buf, size_t len, const char *words, size_t nwords,
-    const uint16_t *products, size_t nproducts, uint16_t vendor,
-    uint16_t product)
+    const uint32_t *products, size_t nproducts, uint32_t vendor,
+    uint32_t product, const char *fmt)
 {
 	size_t n;
 
@@ -93,6 +94,6 @@ dev_findproduct(char *buf, size_t len, c
 		while (n < nproducts && products[n] != 0)
 			n++;
 	}
-	snprintf(buf, len, "product %4.4x", product);
+	snprintf(buf, len, fmt, product);
 	return NULL;
 }
Index: src/sys/dev/devlist2h.awk
diff -u src/sys/dev/devlist2h.awk:1.3 src/sys/dev/devlist2h.awk:1.4
--- src/sys/dev/devlist2h.awk:1.3	Tue Jun 27 08:09:14 2017
+++ src/sys/dev/devlist2h.awk	Tue Jun 29 21:03:36 2021
@@ -1,5 +1,5 @@
 #! /usr/bin/awk -f
-#	$NetBSD: devlist2h.awk,v 1.3 2017/06/27 08:09:14 wiz Exp $
+#	$NetBSD: devlist2h.awk,v 1.4 2021/06/29 21:03:36 pgoyette Exp $
 #
 # Copyright (c) 1995, 1996 Christopher G. Demetriou
 # All rights reserved.
@@ -29,6 +29,34 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
+
+function collectline(f) {
+	oparen = 0 
+	line = ""
+	while (f <= NF) {
+		if ($f == "#") {
+			line = line "("
+			oparen = 1
+			f++
+			continue
+		}
+		if (oparen) {  
+			line = line $f
+			if (f < NF)
+			line = line " "
+			f++
+			continue
+		}
+		line = line $f
+		if (f < NF)
+			line = line " "
+		f++
+	}
+	if (oparen)
+		line = line ")"
+	return line
+}
+
 NR == 1 {
 	nproducts = nvendors = blanklines = 0
 	vendormaxlen = productmaxlen = 0
@@ -42,6 +70,22 @@ NR == 1 {
 	gsub("\\$", "", VERSION)
 	gsub(/ $/, "", VERSION)
 
+	if ( PREFIX == "MII" ) {
+		VENDOR="OUI"
+		PRODUCT="MODEL"
+		vendor="oui"
+		product="model"
+		fmt_vendor="oui %6.6x"
+		fmt_product="model %4.4x"
+	} else {
+		VENDOR="VENDOR"
+		PRODUCT="PRODUCT"
+		vendor="vendor"
+		product="product"
+		fmt_vendor="vendor %4.4x"
+		fmt_product="product %4.4x"
+	}
+
 	printf("/*\t$NetBSD" "$\t*/\n\n") > dfile
 	printf("/*\n") > dfile
 	printf(" * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.\n") \
@@ -62,13 +106,13 @@ NR == 1 {
 
 	next
 }
-NF > 0 && $1 == "vendor" {
+NF > 0 && $1 == vendor {
 	nvendors++
 
 	vendorindex[$2] = nvendors;		# record index for this name, for later.
 	vendors[nvendors, 1] = $2;		# name
 	vendors[nvendors, 2] = $3;		# id
-	printf("#define\t%s_VENDOR_%s\t%s", PREFIX, vendors[nvendors, 1],
+	printf("#define\t%s_%s_%s\t%s", PREFIX, VENDOR, vendors[nvendors, 1],
 	    vendors[nvendors, 2]) > hfile
 
 	i = 3; f = 4;
@@ -124,14 +168,15 @@ NF > 0 && $1 == "vendor" {
 
 	next
 }
-NF > 0 && $1 == "product" {
+NF > 0 && $1 == product {
 	nproducts++
 
 	products[nproducts, 1] = $2;		# vendor name
 	products[nproducts, 2] = $3;		# product id
 	products[nproducts, 3] = $4;		# id
-	printf("#define\t%s_PRODUCT_%s_%s\t%s", PREFIX, products[nproducts, 1],
-	    products[nproducts, 2], products[nproducts, 3]) > hfile
+	printf("#define\t%s_%s_%s_%s\t%s", PREFIX, PRODUCT,
+	    products[nproducts, 1], products[nproducts, 2],
+	    products[nproducts, 3]) > hfile
 
 	i=4; f = 5;
 
@@ -184,6 +229,12 @@ NF > 0 && $1 == "product" {
 		productmaxlen = productlen;
 	}
 
+	if (PREFIX == "MII") {
+		printf("#define\tMII_STR_%s_%s\t\"%s\"\n",
+		    products[nproducts, 1], products[nproducts, 2],
+		    collectline(5)) > hfile
+	}
+
 	next
 }
 {
@@ -198,9 +249,9 @@ END {
 
 	printf("\n") > dfile
 
-	printf("static const uint16_t %s_vendors[] = {\n", prefix) > dfile
+	printf("static const uint32_t %s_vendors[] = {\n", prefix) > dfile
 	for (i = 1; i <= nvendors; i++) {
-		printf("\t    %s_VENDOR_%s", PREFIX, vendors[i, 1]) \
+		printf("\t    %s_%s_%s", PREFIX, VENDOR, vendors[i, 1]) \
 		    > dfile
 
 		j = 3;
@@ -218,11 +269,11 @@ END {
 
 	printf("\n") > dfile
 
-	printf("static const uint16_t %s_products[] = {\n", prefix) > dfile
+	printf("static const uint32_t %s_products[] = {\n", prefix) > dfile
 	for (i = 1; i <= nproducts; i++) {
-		printf("\t    %s_VENDOR_%s, %s_PRODUCT_%s_%s, \n",
-		    PREFIX, products[i, 1], PREFIX, products[i, 1],
-		    products[i, 2]) > dfile
+		printf("\t    %s_%s_%s, %s_%s_%s_%s, \n",
+		    PREFIX, VENDOR, products[i, 1], PREFIX, PRODUCT,
+		    products[i, 1], products[i, 2]) > dfile
 
 		printf("\t    ") > dfile
 		j = 4
@@ -250,8 +301,13 @@ END {
 
 	printf("\n") > dfile
 
-	printf("Maximum vendor string length:  %d\n", vendormaxlen + 1)
-	printf("Maximum product string length: %d\n", productmaxlen + 1)
+	printf("\n") > hfile
+	printf("/* Define format strings for non-existent values */\n") > hfile
+	printf("#define %s_id1_format\t\"%s\"\n", prefix, fmt_vendor) > hfile
+	printf("#define %s_id2_format\t\"%s\"\n", prefix, fmt_product) > hfile
+
+	printf("Maximum %s string length:  %d\n", vendor, vendormaxlen + 1)
+	printf("Maximum %s string length: %d\n", product, productmaxlen + 1)
 	printf("\nEnsure that device-specific values are sufficiently large");
 	printf("\ncheck Makefile.%s for details).\n", FILENAME);
 

Index: src/sys/dev/dev_verbose.h
diff -u src/sys/dev/dev_verbose.h:1.7 src/sys/dev/dev_verbose.h:1.8
--- src/sys/dev/dev_verbose.h:1.7	Tue Jun 15 23:24:57 2021
+++ src/sys/dev/dev_verbose.h	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dev_verbose.h,v 1.7 2021/06/15 23:24:57 riastradh Exp $ */
+/*	$NetBSD: dev_verbose.h,v 1.8 2021/06/29 21:03:36 pgoyette Exp $ */
 
 /*
  * Redistribution and use in source and binary forms, with or without
@@ -30,35 +30,36 @@
 #endif
 
 const char *dev_findvendor(char *, size_t, const char *, size_t, 
-	const uint16_t *, size_t, uint16_t);
+	const uint32_t *, size_t, uint32_t, const char *);
 const char *dev_findproduct(char *, size_t, const char *, size_t, 
-	const uint16_t *, size_t, uint16_t, uint16_t);
+	const uint32_t *, size_t, uint32_t, uint32_t, const char *);
 
 #define DEV_VERBOSE_COMMON_DEFINE(tag)					\
 static const char *							\
-tag ## _findvendor_real(char *buf, size_t len, uint16_t vendor)		\
+tag ## _findvendor_real(char *buf, size_t len, uint32_t vendor)		\
 {									\
 	return dev_findvendor(buf, len, tag ## _words,			\
 	    __arraycount(tag ## _words), tag ## _vendors,		\
-	    __arraycount(tag ## _vendors), vendor);			\
+	    __arraycount(tag ## _vendors), vendor, tag ## _id1_format);	\
 }									\
 									\
 static const char *							\
-tag ## _findproduct_real(char *buf, size_t len, uint16_t vendor,	\
-    uint16_t product)							\
+tag ## _findproduct_real(char *buf, size_t len, uint32_t vendor,	\
+    uint32_t product)							\
 {									\
 	return dev_findproduct(buf, len, tag ## _words,			\
 	    __arraycount(tag ## _words), tag ## _products,		\
-	    __arraycount(tag ## _products), vendor, product);		\
+	    __arraycount(tag ## _products), vendor, product,		\
+	    tag ## _id2_format);					\
 }									\
 
 #ifdef _KERNEL
 
 #define DEV_VERBOSE_KERNEL_DECLARE(tag)					\
 MODULE_HOOK(tag ## _findvendor_hook, const char *,			\
-	(char *, size_t, uint16_t));					\
+	(char *, size_t, uint32_t));					\
 MODULE_HOOK(tag ## _findproduct_hook, const char *,			\
-	(char *, size_t, uint16_t, uint16_t));				\
+	(char *, size_t, uint32_t, uint32_t));				\
 extern int tag ## verbose_loaded;
 
 #define DEV_VERBOSE_MODULE_DEFINE(tag, deps)				\
@@ -91,8 +92,8 @@ MODULE(MODULE_CLASS_DRIVER, tag ## verbo
 #endif /* KERNEL */
 
 #define DEV_VERBOSE_DECLARE(tag)					\
-extern const char * tag ## _findvendor(char *, size_t, uint16_t);	\
-extern const char * tag ## _findproduct(char *, size_t, uint16_t, uint16_t)
+extern const char * tag ## _findvendor(char *, size_t, uint32_t);	\
+extern const char * tag ## _findproduct(char *, size_t, uint32_t, uint32_t)
 
 #if defined(_KERNEL)
 
@@ -111,27 +112,27 @@ tag ## _load_verbose(void)						\
 }									\
 									\
 const char *								\
-tag ## _findvendor(char *buf, size_t len, uint16_t vendor)		\
+tag ## _findvendor(char *buf, size_t len, uint32_t vendor)		\
 {									\
 	const char *retval = NULL;					\
 									\
 	tag ## _load_verbose();						\
 	MODULE_HOOK_CALL(tag ## _findvendor_hook, (buf, len, vendor),	\
-		(snprintf(buf, len, "vendor %4.4x", vendor), NULL),	\
+		(snprintf(buf, len, tag ## _id1_format, vendor), NULL),	\
 		retval);						\
 	return retval;							\
 }									\
 									\
 const char *								\
-tag ## _findproduct(char *buf, size_t len, uint16_t vendor,		\
-    uint16_t product)							\
+tag ## _findproduct(char *buf, size_t len, uint32_t vendor,		\
+    uint32_t product)							\
 {									\
 	const char *retval = NULL;					\
 									\
 	tag ## _load_verbose();						\
 	MODULE_HOOK_CALL(tag ## _findproduct_hook,			\
 		(buf, len, vendor, product),				\
-		(snprintf(buf, len, "product %4.4x", product), NULL),	\
+		(snprintf(buf, len, tag ## _id2_format, product), NULL), \
 		retval);						\
 	return retval;							\
 }									\
@@ -140,14 +141,14 @@ tag ## _findproduct(char *buf, size_t le
 
 #define DEV_VERBOSE_DEFINE(tag)						\
 DEV_VERBOSE_COMMON_DEFINE(tag)						\
-const char *tag ## _findvendor(char *buf, size_t len, uint16_t vendor)	\
+const char *tag ## _findvendor(char *buf, size_t len, uint32_t vendor)	\
 {									\
 									\
 	return tag ## _findvendor_real(buf, len, vendor);		\
 }									\
 									\
-const char *tag ## _findproduct(char *buf, size_t len, uint16_t vendor,	\
-		uint16_t product)					\
+const char *tag ## _findproduct(char *buf, size_t len, uint32_t vendor,	\
+		uint32_t product)					\
 {									\
 									\
 	return tag ## _findproduct_real(buf, len, vendor, product);	\

Index: src/sys/dev/hdaudio/hdaudio.c
diff -u src/sys/dev/hdaudio/hdaudio.c:1.14 src/sys/dev/hdaudio/hdaudio.c:1.15
--- src/sys/dev/hdaudio/hdaudio.c:1.14	Sat Apr 24 23:36:54 2021
+++ src/sys/dev/hdaudio/hdaudio.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: hdaudio.c,v 1.14 2021/04/24 23:36:54 thorpej Exp $ */
+/* $NetBSD: hdaudio.c,v 1.15 2021/06/29 21:03:36 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2009 Precedence Technologies Ltd <supp...@precedence.co.uk>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.14 2021/04/24 23:36:54 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 1.15 2021/06/29 21:03:36 pgoyette Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: hdaudio.c,v 
 #include "hdaudioreg.h"
 #include "hdaudioio.h"
 #include "hdaudio_verbose.h"
+#include "hdaudiodevs.h"
 
 /* #define	HDAUDIO_DEBUG */
 

Index: src/sys/dev/mii/Makefile.miidevs
diff -u src/sys/dev/mii/Makefile.miidevs:1.3 src/sys/dev/mii/Makefile.miidevs:1.4
--- src/sys/dev/mii/Makefile.miidevs:1.3	Sun Oct 19 22:05:22 2008
+++ src/sys/dev/mii/Makefile.miidevs	Tue Jun 29 21:03:36 2021
@@ -1,9 +1,19 @@
-#	$NetBSD: Makefile.miidevs,v 1.3 2008/10/19 22:05:22 apb Exp $
+#	$NetBSD: Makefile.miidevs,v 1.4 2021/06/29 21:03:36 pgoyette Exp $
+#
+# As per t...@netbsd.org, the proper procedure is (adapted from dev/hdaudio)
+#
+# 1.) Change "src/sys/dev/mii/miidevs".
+# 2.) Commit "src/sys/dev/mii/miidevs".
+# 3.) Execute "make -f Makefile.miidevs" in "src/sys/dev/mii".
+# 4.) Ensure that the value of MII_MAX_DESCR_LEN is at least as large as
+#     the values reported.  If necessary, update "src/sys/dev/mii/miivar.h"
+#     and bump the kernel version in "src/sys/sys/param/h".
+# 5.) Commit "src/sys/dev/mii/miidevs.h" and
+#     "src/sys/dev/mii/miidevs_data.h"; if you changed them, also
+#     commit "src/sys/dev/mii/miivar.h" and "src/sys/sys/param.h".
 
 .include <bsd.own.mk>
 
-RM=	rm
-
-miidevs.h: miidevs devlist2h.awk
-	${RM} -f miidevs.h miidevs_data.h
-	${TOOL_AWK} -f devlist2h.awk miidevs
+miidevs.h miidevs_data.h: ${.CURDIR}/../devlist2h.awk miidevs
+	/bin/rm -f miidevs.h miidevs_data.h
+	${TOOL_AWK} -f ${.ALLSRC}

Index: src/sys/dev/mii/gentbi.c
diff -u src/sys/dev/mii/gentbi.c:1.31 src/sys/dev/mii/gentbi.c:1.32
--- src/sys/dev/mii/gentbi.c:1.31	Sun Mar 15 23:04:50 2020
+++ src/sys/dev/mii/gentbi.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gentbi.c,v 1.31 2020/03/15 23:04:50 thorpej Exp $	*/
+/*	$NetBSD: gentbi.c,v 1.32 2021/06/29 21:03:36 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gentbi.c,v 1.31 2020/03/15 23:04:50 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gentbi.c,v 1.32 2021/06/29 21:03:36 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -141,9 +141,10 @@ gentbiattach(device_t parent, device_t s
 	int oui = MII_OUI(ma->mii_id1, ma->mii_id2);
 	int model = MII_MODEL(ma->mii_id2);
 	int rev = MII_REV(ma->mii_id2);
-	const char *descr;
+	char descr[MII_MAX_DESCR_LEN];
 
-	if ((descr = mii_get_descr(oui, model)) != NULL)
+	mii_get_descr(descr, sizeof(descr), oui, model);
+	if (descr[0])
 		aprint_normal(": %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
 		    descr, oui, model, rev);
 	else

Index: src/sys/dev/mii/mii_physubr.c
diff -u src/sys/dev/mii/mii_physubr.c:1.94 src/sys/dev/mii/mii_physubr.c:1.95
--- src/sys/dev/mii/mii_physubr.c:1.94	Thu Aug 27 10:10:23 2020
+++ src/sys/dev/mii/mii_physubr.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mii_physubr.c,v 1.94 2020/08/27 10:10:23 kardel Exp $	*/
+/*	$NetBSD: mii_physubr.c,v 1.95 2021/06/29 21:03:36 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.94 2020/08/27 10:10:23 kardel Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_physubr.c,v 1.95 2021/06/29 21:03:36 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -44,37 +44,43 @@ __KERNEL_RCSID(0, "$NetBSD: mii_physubr.
 #include <sys/socket.h>
 #include <sys/errno.h>
 #include <sys/module.h>
+#include <sys/module_hook.h>
 #include <sys/proc.h>
 
 #include <net/if.h>
 #include <net/if_media.h>
 #include <net/route.h>
 
+#include <dev/dev_verbose.h>
+
 #include <dev/mii/mii.h>
+#include <dev/mii/miidevs.h>
 #include <dev/mii/miivar.h>
 
-const char *(*mii_get_descr)(int, int) = mii_get_descr_stub;
-
-int mii_verbose_loaded = 0;
+DEV_VERBOSE_DEFINE(mii);
 
 const char *
-mii_get_descr_stub(int oui, int model)
+mii_get_descr(char *descr, size_t len, uint32_t oui, uint32_t model)
 {
-	mii_load_verbose();
-	if (mii_verbose_loaded)
-		return mii_get_descr(oui, model);
-	else
-		return NULL;
-}
+	char temp[MII_MAX_DESCR_LEN];
 
-/*
- * Routine to load the miiverbose kernel module as needed
- */
-void
-mii_load_verbose(void)
-{
-	if (mii_verbose_loaded == 0)
-		module_autoload("miiverbose", MODULE_CLASS_MISC);
+	mii_load_verbose();
+	if (miiverbose_loaded) {
+		if (mii_findvendor(temp, sizeof(temp), oui) == NULL) {
+			descr[0] = '\0';
+			return NULL;
+		}
+		strlcpy(descr, temp, len);
+		strlcat(descr, " ", len);
+		if (mii_findproduct(temp, sizeof(temp), oui, model) == NULL) {
+			descr[0] = '\0';
+			return NULL;
+		}
+		strlcat(descr, temp, len);
+		return descr;
+	}
+	snprintf(descr, len, "oui 0x%6x model 0x%04x", oui, model);
+	return NULL;
 }
 
 static void mii_phy_statusmsg(struct mii_softc *);
@@ -683,7 +689,7 @@ const struct mii_phydesc *
 mii_phy_match(const struct mii_attach_args *ma, const struct mii_phydesc *mpd)
 {
 
-	for (; mpd->mpd_name != NULL; mpd++) {
+	for (; mpd->mpd_oui != 0; mpd++) {
 		if (MII_OUI(ma->mii_id1, ma->mii_id2) == mpd->mpd_oui &&
 		    MII_MODEL(ma->mii_id2) == mpd->mpd_model)
 			return mpd;

Index: src/sys/dev/mii/mii_verbose.c
diff -u src/sys/dev/mii/mii_verbose.c:1.8 src/sys/dev/mii/mii_verbose.c:1.9
--- src/sys/dev/mii/mii_verbose.c:1.8	Sat Jun  5 22:45:03 2021
+++ src/sys/dev/mii/mii_verbose.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mii_verbose.c,v 1.8 2021/06/05 22:45:03 pgoyette Exp $ */
+/*	$NetBSD: mii_verbose.c,v 1.9 2021/06/29 21:03:36 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -55,47 +55,11 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mii_verbose.c,v 1.8 2021/06/05 22:45:03 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mii_verbose.c,v 1.9 2021/06/29 21:03:36 pgoyette Exp $");
 
 #include <sys/module.h>
 #include <dev/mii/miidevs.h>
 #include <dev/mii/miidevs_data.h>
 #include <dev/mii/mii_verbose.h>
 
-const char * mii_get_descr_real(int, int);
-
-MODULE(MODULE_CLASS_MISC, miiverbose, NULL);
-
-static int
-miiverbose_modcmd(modcmd_t cmd, void *arg)
-{
-	static const char *(*saved_mii_get_descr)(int, int);
-
-	switch (cmd) {
-	case MODULE_CMD_INIT:
-		saved_mii_get_descr = mii_get_descr;
-		mii_get_descr = mii_get_descr_real;
-		mii_verbose_loaded = 1;
-		return 0;
-	case MODULE_CMD_FINI:
-		mii_get_descr = saved_mii_get_descr;
-		mii_verbose_loaded = 0;
-		return 0;
-	case MODULE_CMD_AUTOUNLOAD:
-		return EBUSY;
-	default:
-		return ENOTTY;
-	}
-}
-
-const char *
-mii_get_descr_real(int oui, int model)
-{
-	int i;
-
-	for (i = 0; mii_knowndevs[i].descr != NULL; i++)
-		if (mii_knowndevs[i].oui == oui &&
-		    mii_knowndevs[i].model == model)
-			break;
-	return mii_knowndevs[i].descr;
-}
+DEV_VERBOSE_MODULE_DEFINE(mii, NULL)

Index: src/sys/dev/mii/mii_verbose.h
diff -u src/sys/dev/mii/mii_verbose.h:1.2 src/sys/dev/mii/mii_verbose.h:1.3
--- src/sys/dev/mii/mii_verbose.h:1.2	Sun Jun  6 18:58:22 2010
+++ src/sys/dev/mii/mii_verbose.h	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mii_verbose.h,v 1.2 2010/06/06 18:58:22 pgoyette Exp $ */
+/*	$NetBSD: mii_verbose.h,v 1.3 2021/06/29 21:03:36 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -33,16 +33,17 @@
 #ifndef _DEV_MII_MII_VERBOSE_H_
 #define	_DEV_MII_MII_VERBOSE_H_
 
+#include <dev/dev_verbose.h>
+
+DEV_VERBOSE_DECLARE(mii);
+
 #ifdef _KERNEL
 
 /* Misc. stuff for miiverbose module */
 
-extern const char *	(*mii_get_descr)(int, int);
-
-const char *	mii_get_descr_stub(int, int);
-void		mii_load_verbose(void);
+const char *	mii_get_descr(char *, size_t, uint32_t, uint32_t);
 
-extern int	mii_verbose_loaded;
+extern int	miiverbose_loaded;
 
 #endif /* _KERNEL */
 

Index: src/sys/dev/mii/miivar.h
diff -u src/sys/dev/mii/miivar.h:1.73 src/sys/dev/mii/miivar.h:1.74
--- src/sys/dev/mii/miivar.h:1.73	Mon Aug 24 04:23:41 2020
+++ src/sys/dev/mii/miivar.h	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: miivar.h,v 1.73 2020/08/24 04:23:41 msaitoh Exp $	*/
+/*	$NetBSD: miivar.h,v 1.74 2021/06/29 21:03:36 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001, 2020 The NetBSD Foundation, Inc.
@@ -352,6 +352,9 @@ u_int	mii_oui(uint16_t, uint16_t);
 #define	MII_MODEL(id2)		(((id2) & IDR2_MODEL) >> 4)
 #define	MII_REV(id2)		((id2) & IDR2_REV)
 
+/* Max length for phy's verbose oui+model */
+#define	MII_MAX_DESCR_LEN	68
+
 #endif /* _KERNEL */
 
 #endif /* _DEV_MII_MIIVAR_H_ */

Index: src/sys/dev/mii/ukphy.c
diff -u src/sys/dev/mii/ukphy.c:1.54 src/sys/dev/mii/ukphy.c:1.55
--- src/sys/dev/mii/ukphy.c:1.54	Sat Mar 28 18:37:18 2020
+++ src/sys/dev/mii/ukphy.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ukphy.c,v 1.54 2020/03/28 18:37:18 thorpej Exp $	*/
+/*	$NetBSD: ukphy.c,v 1.55 2021/06/29 21:03:36 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.54 2020/03/28 18:37:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.55 2021/06/29 21:03:36 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mii.h"
@@ -109,9 +109,9 @@ ukphyattach(device_t parent, device_t se
 	int oui = MII_OUI(ma->mii_id1, ma->mii_id2);
 	int model = MII_MODEL(ma->mii_id2);
 	int rev = MII_REV(ma->mii_id2);
-	const char *descr;
+	char descr[MII_MAX_DESCR_LEN];
 
-	if ((descr = mii_get_descr(oui, model)) != NULL)
+	if (mii_get_descr(descr, sizeof(descr), oui, model) && descr[0])
 		aprint_normal(": %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
 		       descr, oui, model, rev);
 	else

Index: src/sys/dev/pci/pci_subr.c
diff -u src/sys/dev/pci/pci_subr.c:1.225 src/sys/dev/pci/pci_subr.c:1.226
--- src/sys/dev/pci/pci_subr.c:1.225	Wed Jan 27 05:00:15 2021
+++ src/sys/dev/pci/pci_subr.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pci_subr.c,v 1.225 2021/01/27 05:00:15 thorpej Exp $	*/
+/*	$NetBSD: pci_subr.c,v 1.226 2021/06/29 21:03:36 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1997 Zubin D. Dittia.  All rights reserved.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.225 2021/01/27 05:00:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v 1.226 2021/06/29 21:03:36 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pci.h"
@@ -71,11 +71,11 @@ __KERNEL_RCSID(0, "$NetBSD: pci_subr.c,v
 #endif
 
 #include <dev/pci/pcireg.h>
+#include <dev/pci/pcidevs.h>
 #ifdef _KERNEL
 #include <dev/pci/pcivar.h>
 #else
 #include <dev/pci/pci_verbose.h>
-#include <dev/pci/pcidevs.h>
 #include <dev/pci/pcidevs_data.h>
 #endif
 

Index: src/sys/dev/pci/ixgbe/ixgbe.c
diff -u src/sys/dev/pci/ixgbe/ixgbe.c:1.284 src/sys/dev/pci/ixgbe/ixgbe.c:1.285
--- src/sys/dev/pci/ixgbe/ixgbe.c:1.284	Wed Jun 16 00:21:18 2021
+++ src/sys/dev/pci/ixgbe/ixgbe.c	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ixgbe.c,v 1.284 2021/06/16 00:21:18 riastradh Exp $ */
+/* $NetBSD: ixgbe.c,v 1.285 2021/06/29 21:03:36 pgoyette Exp $ */
 
 /******************************************************************************
 
@@ -64,7 +64,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.284 2021/06/16 00:21:18 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixgbe.c,v 1.285 2021/06/29 21:03:36 pgoyette Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1177,14 +1177,15 @@ ixgbe_attach(device_t parent, device_t d
 	if (hw->phy.media_type == ixgbe_media_type_copper) {
 		uint16_t id1, id2;
 		int oui, model, rev;
-		const char *descr;
+		char descr[MII_MAX_DESCR_LEN];
 
 		id1 = hw->phy.id >> 16;
 		id2 = hw->phy.id & 0xffff;
 		oui = MII_OUI(id1, id2);
 		model = MII_MODEL(id2);
 		rev = MII_REV(id2);
-		if ((descr = mii_get_descr(oui, model)) != NULL)
+		mii_get_descr(descr, sizeof(descr), oui, model);
+		if (descr[0])
 			aprint_normal_dev(dev,
 			    "PHY: %s (OUI 0x%06x, model 0x%04x), rev. %d\n",
 			    descr, oui, model, rev);

Index: src/sys/rump/librump/rumpdev/Makefile.rumpdev
diff -u src/sys/rump/librump/rumpdev/Makefile.rumpdev:1.13 src/sys/rump/librump/rumpdev/Makefile.rumpdev:1.14
--- src/sys/rump/librump/rumpdev/Makefile.rumpdev:1.13	Mon May 13 17:49:05 2019
+++ src/sys/rump/librump/rumpdev/Makefile.rumpdev	Tue Jun 29 21:03:36 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.rumpdev,v 1.13 2019/05/13 17:49:05 bad Exp $
+#	$NetBSD: Makefile.rumpdev,v 1.14 2021/06/29 21:03:36 pgoyette Exp $
 #
 
 LIB=	rumpdev
@@ -15,6 +15,7 @@ SRCS+=	kern_pmf.c
 
 # sys/dev
 SRCS+=	dev_verbose.c
+COPTS.dev_verbose.c+= -Wno-error=format-nonliteral
 
 CPPFLAGS+=	-I${RUMPTOP}/librump/rumpkern
 

Index: src/sys/sys/param.h
diff -u src/sys/sys/param.h:1.696 src/sys/sys/param.h:1.697
--- src/sys/sys/param.h:1.696	Sun Jun 13 15:11:20 2021
+++ src/sys/sys/param.h	Tue Jun 29 21:03:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.696 2021/06/13 15:11:20 martin Exp $	*/
+/*	$NetBSD: param.h,v 1.697 2021/06/29 21:03:37 pgoyette Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999008500	/* NetBSD 9.99.85 */
+#define	__NetBSD_Version__	999008600	/* NetBSD 9.99.86 */
 
 #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \
     (m) * 1000000) + (p) * 100) <= __NetBSD_Version__)

Reply via email to