Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add intrctl(8).
details: https://anonhg.NetBSD.org/src/rev/6addc16d956d
branches: trunk
changeset: 339909:6addc16d956d
user: knakahara <knakahara%NetBSD.org@localhost>
date: Mon Aug 17 06:42:45 2015 +0000
description:
Add intrctl(8).
diffstat:
distrib/sets/lists/base/mi | 3 +-
distrib/sets/lists/comp/mi | 4 +-
distrib/sets/lists/debug/mi | 3 +-
sbin/sysctl/sysctl.c | 9 +-
usr.sbin/Makefile | 4 +-
usr.sbin/intrctl/Makefile | 9 +
usr.sbin/intrctl/intrctl.c | 271 ++++++++++++++++++++++++++++++++++++++++++
usr.sbin/intrctl/intrctl_io.c | 131 ++++++++++++++++++++
usr.sbin/intrctl/intrctl_io.h | 44 ++++++
9 files changed, 471 insertions(+), 7 deletions(-)
diffs (truncated from 571 to 300 lines):
diff -r 22254a7977da -r 6addc16d956d distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi Mon Aug 17 06:28:11 2015 +0000
+++ b/distrib/sets/lists/base/mi Mon Aug 17 06:42:45 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1109 2015/08/10 02:44:36 mrg Exp $
+# $NetBSD: mi,v 1.1110 2015/08/17 06:42:45 knakahara Exp $
#
# Note: Don't delete entries from here - mark them as "obsolete" instead,
# unless otherwise stated below.
@@ -1641,6 +1641,7 @@
./usr/sbin/ifwatchd base-netutil-bin
./usr/sbin/inetd base-netutil-bin
./usr/sbin/installboot base-sysutil-bin
+./usr/sbin/intrctl base-sysutil-bin
./usr/sbin/iopctl base-sysutil-bin
./usr/sbin/iostat base-sysutil-bin
./usr/sbin/ipfs base-ipf-bin ipfilter
diff -r 22254a7977da -r 6addc16d956d distrib/sets/lists/comp/mi
--- a/distrib/sets/lists/comp/mi Mon Aug 17 06:28:11 2015 +0000
+++ b/distrib/sets/lists/comp/mi Mon Aug 17 06:42:45 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1980 2015/08/17 06:28:11 knakahara Exp $
+# $NetBSD: mi,v 1.1981 2015/08/17 06:42:45 knakahara Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -2791,6 +2791,8 @@
./usr/include/sys/gpio.h comp-c-include
./usr/include/sys/hash.h comp-c-include
./usr/include/sys/ieee754.h comp-c-include
+./usr/include/sys/intr.h comp-c-include
+./usr/include/sys/intrio.h comp-c-include
./usr/include/sys/inttypes.h comp-c-include
./usr/include/sys/ioccom.h comp-c-include
./usr/include/sys/ioctl.h comp-c-include
diff -r 22254a7977da -r 6addc16d956d distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Mon Aug 17 06:28:11 2015 +0000
+++ b/distrib/sets/lists/debug/mi Mon Aug 17 06:42:45 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.126 2015/08/10 03:21:44 mrg Exp $
+# $NetBSD: mi,v 1.127 2015/08/17 06:42:46 knakahara Exp $
./etc/mtree/set.debug comp-sys-root
./usr/lib comp-sys-usr compatdir
@@ -1053,6 +1053,7 @@
./usr/libdata/debug/usr/sbin/ifwatchd.debug comp-netutil-debug debug
./usr/libdata/debug/usr/sbin/inetd.debug comp-netutil-debug debug
./usr/libdata/debug/usr/sbin/installboot.debug comp-sysutil-debug debug
+./usr/libdata/debug/usr/sbin/intrctl.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/iopctl.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/iostat.debug comp-sysutil-debug debug
./usr/libdata/debug/usr/sbin/ipfs.debug comp-ipf-debug ipfilter,debug
diff -r 22254a7977da -r 6addc16d956d sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c Mon Aug 17 06:28:11 2015 +0000
+++ b/sbin/sysctl/sysctl.c Mon Aug 17 06:42:45 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.c,v 1.155 2014/11/09 22:50:38 christos Exp $ */
+/* $NetBSD: sysctl.c,v 1.156 2015/08/17 06:42:46 knakahara Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#if 0
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: sysctl.c,v 1.155 2014/11/09 22:50:38 christos Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.156 2015/08/17 06:42:46 knakahara Exp $");
#endif
#endif /* not lint */
@@ -197,6 +197,11 @@
{ "/kern/coredump/setid/mode", mode_bits, mode_bits, NULL },
{ "/kern/drivers", kern_drivers, NULL, NULL },
+ { "/kern/intr/list", printother, NULL, "intrctl" },
+ { "/kern/intr/affinity", printother, NULL, "intrctl" },
+ { "/kern/intr/intr", printother, NULL, "intrctl" },
+ { "/kern/intr/nointr", printother, NULL, "intrctl" },
+
{ "/vm/vmmeter", printother, NULL,
"vmstat' or 'systat" },
{ "/vm/loadavg", vm_loadavg, NULL, NULL },
diff -r 22254a7977da -r 6addc16d956d usr.sbin/Makefile
--- a/usr.sbin/Makefile Mon Aug 17 06:28:11 2015 +0000
+++ b/usr.sbin/Makefile Mon Aug 17 06:42:45 2015 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.270 2015/03/22 09:57:42 ast Exp $
+# $NetBSD: Makefile,v 1.271 2015/08/17 06:42:46 knakahara Exp $
# from: @(#)Makefile 5.20 (Berkeley) 6/12/93
.include <bsd.own.mk>
@@ -11,7 +11,7 @@
flashctl fssconfig fusermount fwctl \
gpioctl grfconfig gspa \
hdaudioctl \
- i2cscan ifwatchd inetd installboot iopctl iostat ipwctl irdaattach \
+ i2cscan ifwatchd inetd installboot intrctl iopctl iostat ipwctl irdaattach \
isdn isibootd iteconfig iwictl \
kgmon \
lastlogin ldpd link lmcconfig lockstat lpr \
diff -r 22254a7977da -r 6addc16d956d usr.sbin/intrctl/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/intrctl/Makefile Mon Aug 17 06:42:45 2015 +0000
@@ -0,0 +1,9 @@
+# $NetBSD: Makefile,v 1.1 2015/08/17 06:42:46 knakahara Exp $
+
+.include <bsd.own.mk>
+
+PROG= intrctl
+MAN= intrctl.8
+SRCS= intrctl.c intrctl_io.c
+
+.include <bsd.prog.mk>
diff -r 22254a7977da -r 6addc16d956d usr.sbin/intrctl/intrctl.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/intrctl/intrctl.c Mon Aug 17 06:42:45 2015 +0000
@@ -0,0 +1,271 @@
+/* $NetBSD: intrctl.c,v 1.1 2015/08/17 06:42:46 knakahara Exp $ */
+
+/*
+ * Copyright (c) 2015 Internet Initiative Japan Inc.
+ * 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 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.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: intrctl.c,v 1.1 2015/08/17 06:42:46 knakahara Exp $");
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/intrio.h>
+#include <sys/types.h>
+
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <paths.h>
+#include <sched.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "intrctl_io.h"
+
+__dead static void usage(void);
+
+int verbose;
+
+static void intrctl_list(int, char **);
+static void intrctl_affinity(int, char **);
+static void intrctl_intr(int, char **);
+static void intrctl_nointr(int, char **);
+
+static struct cmdtab {
+ const char *label;
+ void (*func)(int, char **);
+} const intrctl_cmdtab[] = {
+ { "list", intrctl_list },
+ { "affinity", intrctl_affinity },
+ { "intr", intrctl_intr },
+ { "nointr", intrctl_nointr },
+ { NULL, NULL },
+};
+
+int
+main(int argc, char **argv)
+{
+ const struct cmdtab *ct;
+ char *cmdname;
+
+ if (argc < 2)
+ usage();
+
+ cmdname = argv[1];
+ argv += 1;
+ argc -= 1;
+
+ for (ct = intrctl_cmdtab; ct->label != NULL; ct++) {
+ if (strcmp(cmdname, ct->label) == 0) {
+ break;
+ }
+ }
+ if (ct->label == NULL)
+ errx(EXIT_FAILURE, "unknown command ``%s''", cmdname);
+
+ (*ct->func)(argc, argv);
+ exit(EXIT_SUCCESS);
+ /* NOTREACHED */
+}
+
+static void
+usage(void)
+{
+ const char *progname = getprogname();
+
+ fprintf(stderr, "usage: %s list\n", progname);
+ fprintf(stderr, " %s affinity -i interrupt_name -c cpu_index\n", progname);
+ fprintf(stderr, " %s intr -c cpu_index\n", progname);
+ fprintf(stderr, " %s nointr -c cpu_index\n", progname);
+ exit(EXIT_FAILURE);
+ /* NOTREACHED */
+}
+
+static int intrctl_io_alloc_retry_count = 4;
+
+static void
+intrctl_list(int argc, char **argv)
+{
+ struct intrio_list_line *illine;
+ int i, ncpus;
+ void *handle;
+
+ handle = intrctl_io_alloc(intrctl_io_alloc_retry_count);
+ if (handle == NULL)
+ err(EXIT_FAILURE, "intrctl_io_alloc");
+
+ /* header */
+ ncpus = intrctl_io_ncpus(handle);
+ printf("interrupt id\t");
+ for (i = 0; i < ncpus; i++) {
+ printf(" CPU#%02u\t", i);
+ }
+ printf("device name(s)\n");
+
+ /* body */
+ illine = intrctl_io_firstline(handle);
+ for (; illine != NULL; illine = intrctl_io_nextline(handle, illine)) {
+ printf("%s\t", illine->ill_intrid);
+ for (i = 0; i < ncpus; i++) {
+ struct intrio_list_line_cpu *illc = &illine->ill_cpu[i];
+ printf("%8" PRIu64 "%c\t", illc->illc_count,
+ illc->illc_assigned ? '*' : ' ');
+ }
+
+ printf("%s\n", illine->ill_xname);
+ }
+
+ intrctl_io_free(handle);
+}
+
+static void
+intrctl_affinity(int argc, char **argv)
+{
+ struct intrio_set iset;
+ cpuset_t *cpuset;
+ unsigned long index;
+ int ch, error;
+
+ index = ULONG_MAX;
+ memset(&iset.intrid, 0, sizeof(iset.intrid));
+
+ while ((ch = getopt(argc, argv, "c:i:")) != -1) {
+ switch (ch) {
+ case 'c':
+ index = strtoul(optarg, NULL, 10);
+ break;
+ case 'i':
+ if (strnlen(optarg, ARG_MAX) > INTRIDBUF)
+ usage();
+ strlcpy(iset.intrid, optarg, INTRIDBUF);
+ break;
+ default:
+ usage();
+ }
+ }
+
+ if (iset.intrid[0] == '\0' || index == ULONG_MAX)
+ usage();
+
+ if (index >= (u_long)sysconf(_SC_NPROCESSORS_CONF))
+ err(EXIT_FAILURE, "invalid cpu index");
+
+ cpuset = cpuset_create();
+ if (cpuset == NULL)
+ err(EXIT_FAILURE, "create_cpuset()");
+
+ cpuset_zero(cpuset);
Home |
Main Index |
Thread Index |
Old Index