Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Extract MIIVERBOSE into a kernel module. The module can be ...
details: https://anonhg.NetBSD.org/src/rev/1ea5dfd81fdb
branches: trunk
changeset: 755276:1ea5dfd81fdb
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun May 30 17:44:07 2010 +0000
description:
Extract MIIVERBOSE into a kernel module. The module can be builtin
by defining 'options MIIVERBOSE' in the kernel config file (no change
from current behavior), or it can be loaded at boot time on those
architectures that support the boot loader's "load" command.
diffstat:
distrib/sets/lists/modules/mi | 4 +-
sys/dev/mii/files.mii | 3 +-
sys/dev/mii/mii_verbose.c | 99 +++++++++++++++++++++++++++++++++++++++++
sys/dev/mii/mii_verbose.h | 47 +++++++++++++++++++
sys/dev/mii/miivar.h | 4 +-
sys/dev/mii/ukphy.c | 58 ++++++++++++++---------
sys/modules/Makefile | 5 +-
sys/modules/miiverbose/Makefile | 10 ++++
8 files changed, 201 insertions(+), 29 deletions(-)
diffs (truncated from 353 to 300 lines):
diff -r e9043fcbea7d -r 1ea5dfd81fdb distrib/sets/lists/modules/mi
--- a/distrib/sets/lists/modules/mi Sun May 30 13:50:16 2010 +0000
+++ b/distrib/sets/lists/modules/mi Sun May 30 17:44:07 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.16 2010/05/30 04:38:04 pgoyette Exp $
+# $NetBSD: mi,v 1.17 2010/05/30 17:44:07 pgoyette Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -62,6 +62,8 @@
./@MODULEDIR@/lfs/lfs.kmod base-kernel-modules kmod
./@MODULEDIR@/mfs base-kernel-modules kmod
./@MODULEDIR@/mfs/mfs.kmod base-kernel-modules kmod
+./@MODULEDIR@/miiverbose base-kernel-modules kmod
+./@MODULEDIR@/miiverbose/miiverbose.kmod base-kernel-modules kmod
./@MODULEDIR@/miniroot base-kernel-modules kmod
./@MODULEDIR@/miniroot/miniroot.kmod base-kernel-modules kmod
./@MODULEDIR@/mqueue base-kernel-modules kmod
diff -r e9043fcbea7d -r 1ea5dfd81fdb sys/dev/mii/files.mii
--- a/sys/dev/mii/files.mii Sun May 30 13:50:16 2010 +0000
+++ b/sys/dev/mii/files.mii Sun May 30 17:44:07 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: files.mii,v 1.44 2009/04/19 11:17:46 msaitoh Exp $
+# $NetBSD: files.mii,v 1.45 2010/05/30 17:44:08 pgoyette Exp $
defflag opt_mii.h MIIVERBOSE
@@ -12,6 +12,7 @@
file dev/mii/mii_physubr.c mii_phy
file dev/mii/mii_ethersubr.c mii & ether
+file dev/mii/mii_verbose.c mii & miiverbose
define ukphy_subr
file dev/mii/ukphy_subr.c ukphy_subr
diff -r e9043fcbea7d -r 1ea5dfd81fdb sys/dev/mii/mii_verbose.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/mii/mii_verbose.c Sun May 30 17:44:07 2010 +0000
@@ -0,0 +1,99 @@
+/* $NetBSD: mii_verbose.c,v 1.1 2010/05/30 17:44:07 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center, and by Frank van der Linden.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 1997 Manuel Bouyer. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: mii_verbose.c,v 1.1 2010/05/30 17:44:07 pgoyette Exp $");
+
+#include <sys/module.h>
+#include <dev/mii/mii_verbose.h>
+
+struct mii_knowndev {
+ int oui;
+ int model;
+ const char *descr;
+};
+#include <dev/mii/miidevs.h>
+#include <dev/mii/miidevs_data.h>
+
+const char * mii_get_descr_real(int, int);
+
+MODULE(MODULE_CLASS_MISC, miiverbose, NULL);
+
+static int
+miiverbose_modcmd(modcmd_t cmd, void *arg)
+{
+ switch (cmd) {
+ case MODULE_CMD_INIT:
+ mii_get_descr = mii_get_descr_real;
+ return 0;
+ case MODULE_CMD_FINI:
+ mii_get_descr = mii_get_descr_stub;
+ return 0;
+ 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);
+}
diff -r e9043fcbea7d -r 1ea5dfd81fdb sys/dev/mii/mii_verbose.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/dev/mii/mii_verbose.h Sun May 30 17:44:07 2010 +0000
@@ -0,0 +1,47 @@
+/* $NetBSD: mii_verbose.h,v 1.1 2010/05/30 17:44:08 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
+ * NASA Ames Research Center.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _DEV_MII_MII_VERBOSE_H_
+#define _DEV_MII_MII_VERBOSE_H_
+
+#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_verbose_ctl(bool);
+
+#endif /* _KERNEL */
+
+#endif /* _DEV_MII_MII_VERBOSE_H_ */
diff -r e9043fcbea7d -r 1ea5dfd81fdb sys/dev/mii/miivar.h
--- a/sys/dev/mii/miivar.h Sun May 30 13:50:16 2010 +0000
+++ b/sys/dev/mii/miivar.h Sun May 30 17:44:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: miivar.h,v 1.58 2010/02/24 22:37:59 dyoung Exp $ */
+/* $NetBSD: miivar.h,v 1.59 2010/05/30 17:44:08 pgoyette Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -36,6 +36,8 @@
#include <sys/queue.h>
#include <sys/callout.h>
+#include <dev/mii/mii_verbose.h>
+
/*
* Media Independent Interface datat structure definitions.
*/
diff -r e9043fcbea7d -r 1ea5dfd81fdb sys/dev/mii/ukphy.c
--- a/sys/dev/mii/ukphy.c Sun May 30 13:50:16 2010 +0000
+++ b/sys/dev/mii/ukphy.c Sun May 30 17:44:07 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ukphy.c,v 1.40 2010/03/11 04:19:56 mrg Exp $ */
+/* $NetBSD: ukphy.c,v 1.41 2010/05/30 17:44:08 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.40 2010/03/11 04:19:56 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ukphy.c,v 1.41 2010/05/30 17:44:08 pgoyette Exp $");
#include "opt_mii.h"
@@ -69,6 +69,7 @@
#include <sys/device.h>
#include <sys/socket.h>
#include <sys/errno.h>
+#include <sys/module.h>
#include <net/if.h>
#include <net/if_media.h>
@@ -76,19 +77,11 @@
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
-#ifdef MIIVERBOSE
-struct mii_knowndev {
- int oui;
- int model;
- const char *descr;
-};
-#include <dev/mii/miidevs.h>
-#include <dev/mii/miidevs_data.h>
-#endif
-
static int ukphymatch(device_t, cfdata_t, void *);
static void ukphyattach(device_t, device_t, void *);
+const char *(*mii_get_descr)(int, int) = mii_get_descr_stub;
+
CFATTACH_DECL3_NEW(ukphy, sizeof(struct mii_softc),
ukphymatch, ukphyattach, mii_phy_detach, mii_phy_activate, NULL, NULL,
DVF_DETACH_SHUTDOWN);
@@ -99,6 +92,31 @@
ukphy_service, ukphy_status, mii_phy_reset,
};
+const char *mii_get_descr_stub(int oui, int model)
+{
+ return NULL;
+}
+
+/*
+ * Routine to load/unload the miiverbose kernel module as needed
+ */
+void mii_verbose_ctl(bool load)
+{
+ static int loaded = 0;
+
+ if (load) {
+ if (loaded++ == 0)
+ if (module_load("miiverbose", MODCTL_LOAD_FORCE,
+ NULL, MODULE_CLASS_MISC) !=0 )
+ loaded = 0;
+ return;
+ }
+ if (loaded == 0)
+ return;
+ if (--loaded == 0)
+ module_unload("miiverbose");
+}
+
static int
ukphymatch(device_t parent, cfdata_t match, void *aux)
{
@@ -118,21 +136,13 @@
int oui = MII_OUI(ma->mii_id1, ma->mii_id2);
int model = MII_MODEL(ma->mii_id2);
int rev = MII_REV(ma->mii_id2);
-#ifdef MIIVERBOSE
- int i;
-#endif
+ const char *descr;
-#ifdef MIIVERBOSE
- for (i = 0; mii_knowndevs[i].descr != NULL; i++)
- if (mii_knowndevs[i].oui == oui &&
- mii_knowndevs[i].model == model)
Home |
Main Index |
Thread Index |
Old Index