Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add a control utility for `mlx' devices. Derived from FreeBS...



details:   https://anonhg.NetBSD.org/src/rev/4968b3b6fd49
branches:  trunk
changeset: 503280:4968b3b6fd49
user:      ad <ad%NetBSD.org@localhost>
date:      Sun Feb 04 17:30:35 2001 +0000

description:
Add a control utility for `mlx' devices. Derived from FreeBSD's `mlxcontrol'.

diffstat:

 distrib/sets/lists/base/mi |    3 +-
 distrib/sets/lists/man/mi  |    3 +-
 usr.sbin/Makefile          |    4 +-
 usr.sbin/mlxctl/Makefile   |   10 +
 usr.sbin/mlxctl/cmds.c     |  406 +++++++++++++++++++++++++++++++++++++++++++++
 usr.sbin/mlxctl/config.c   |  237 ++++++++++++++++++++++++++
 usr.sbin/mlxctl/dklist.c   |  234 +++++++++++++++++++++++++
 usr.sbin/mlxctl/extern.h   |   88 +++++++++
 usr.sbin/mlxctl/main.c     |  160 +++++++++++++++++
 usr.sbin/mlxctl/mlxctl.8   |  176 +++++++++++++++++++
 usr.sbin/mlxctl/util.c     |  287 +++++++++++++++++++++++++++++++
 11 files changed, 1604 insertions(+), 4 deletions(-)

diffs (truncated from 1682 to 300 lines):

diff -r b209f62a2d8b -r 4968b3b6fd49 distrib/sets/lists/base/mi
--- a/distrib/sets/lists/base/mi        Sun Feb 04 17:15:37 2001 +0000
+++ b/distrib/sets/lists/base/mi        Sun Feb 04 17:30:35 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.224 2001/02/03 02:57:12 jwise Exp $
+# $NetBSD: mi,v 1.225 2001/02/04 17:30:36 ad Exp $
 .                      base-sys-root
 ./altroot              base-sys-root
 ./bin                  base-sys-root
@@ -646,6 +646,7 @@
 ./usr/sbin/mkalias             base-nis-bin
 ./usr/sbin/mknetid             base-nis-bin
 ./usr/sbin/mld6query           base-netutil-bin
+./usr/sbin/mlxctl              base-sysutil-bin
 ./usr/sbin/mopa.out            base-bootserver-bin
 ./usr/sbin/mopchk              base-bootserver-bin
 ./usr/sbin/mopd                        base-bootserver-bin
diff -r b209f62a2d8b -r 4968b3b6fd49 distrib/sets/lists/man/mi
--- a/distrib/sets/lists/man/mi Sun Feb 04 17:15:37 2001 +0000
+++ b/distrib/sets/lists/man/mi Sun Feb 04 17:30:35 2001 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.319 2001/02/04 17:05:14 ad Exp $
+# $NetBSD: mi,v 1.320 2001/02/04 17:30:36 ad Exp $
 ./usr/share/info/am-utils.info                 man-amd-info
 ./usr/share/info/as.info                       man-computil-info
 ./usr/share/info/awk.info                      man-util-info
@@ -2718,6 +2718,7 @@
 ./usr/share/man/man8/mknetid.8                 man-nis-man
 ./usr/share/man/man8/mknod.8                   man-sysutil-man
 ./usr/share/man/man8/mld6query.8               man-netutil-man
+./usr/share/man/man8/mlxctl.8                  man-sysutil-man
 ./usr/share/man/man8/modload.8                 man-sysutil-man
 ./usr/share/man/man8/modstat.8                 man-sysutil-man
 ./usr/share/man/man8/modunload.8               man-sysutil-man
diff -r b209f62a2d8b -r 4968b3b6fd49 usr.sbin/Makefile
--- a/usr.sbin/Makefile Sun Feb 04 17:15:37 2001 +0000
+++ b/usr.sbin/Makefile Sun Feb 04 17:30:35 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.154 2001/01/06 13:03:49 martin Exp $
+#      $NetBSD: Makefile,v 1.155 2001/02/04 17:30:35 ad Exp $
 #      from: @(#)Makefile      5.20 (Berkeley) 6/12/93
 
 .include <bsd.own.mk>
@@ -10,7 +10,7 @@
        grfconfig grfinfo gspa hilinfo inetd iopctl iostat ipf isdn iteconfig \
        kgmon kvm_mkdb lastlogin link lpr mailwrapper map-mbone \
        mdconfig mdsetimage \
-       memswitch mopd mountd mrinfo mrouted mtrace mtree \
+       memswitch mlxctl mopd mountd mrinfo mrouted mtrace mtree \
        netgroup_mkdb nfsd ntp pkg_install pppd pstat \
        pwd_mkdb quot quotacheck quotaon rarpd rbootd rdate \
        repquota rmt rpc.bootparamd rpc.lockd rpc.pcnfsd \
diff -r b209f62a2d8b -r 4968b3b6fd49 usr.sbin/mlxctl/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/mlxctl/Makefile  Sun Feb 04 17:30:35 2001 +0000
@@ -0,0 +1,10 @@
+#      $NetBSD: Makefile,v 1.1 2001/02/04 17:30:37 ad Exp $
+
+PROG=  mlxctl
+SRCS=  cmds.c config.c dklist.c main.c util.c
+MAN=   mlxctl.8
+
+LDADD= -lkvm
+DPADD= ${LIBKVM}
+
+.include <bsd.prog.mk>
diff -r b209f62a2d8b -r 4968b3b6fd49 usr.sbin/mlxctl/cmds.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/mlxctl/cmds.c    Sun Feb 04 17:30:35 2001 +0000
@@ -0,0 +1,406 @@
+/*     $NetBSD: cmds.c,v 1.1 2001/02/04 17:30:37 ad Exp $      */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Andrew Doran.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * 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) 1999 Michael Smith
+ * 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 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 AUTHOR 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.
+ *
+ * from FreeBSD: command.c,v 1.2 2000/04/11 23:04:17 msmith Exp
+ */
+
+#ifndef lint
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: cmds.c,v 1.1 2001/02/04 17:30:37 ad Exp $");
+#endif /* not lint */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <sys/queue.h>
+#include <sys/endian.h>
+
+#include <dev/ic/mlxreg.h>
+#include <dev/ic/mlxio.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <getopt.h>
+
+#include "extern.h"
+
+static void    cmd_status0(struct mlx_disk *);
+static void    cmd_check0(struct mlx_disk *);
+static void    cmd_detach0(struct mlx_disk *);
+
+static struct  mlx_rebuild_status rs;
+static int     rstatus;
+
+struct {
+       int     hwid;
+       const char      *name;
+} static const mlx_ctlr_names[] = {
+       { 0x01, "960P/PD" },
+       { 0x02, "960PL" },
+       { 0x10, "960PG" },
+       { 0x11, "960PJ" },
+       { 0x12, "960PR" },
+       { 0x13, "960PT" }, 
+       { 0x14, "960PTL0" },
+       { 0x15, "960PRL" } ,
+       { 0x16, "960PTL1" },
+       { 0x20, "1100PVX" },
+       { -1,   NULL },
+};
+
+/*
+ * Status output
+ */
+static void
+cmd_status0(struct mlx_disk *md)
+{
+       const char *statusfmt;
+       int result;
+ 
+       result = md->hwunit;
+       if (ioctl(mlxfd, MLXD_STATUS, &result) < 0)
+               err(EXIT_FAILURE, "ioctl(MLXD_STATUS)");
+
+       switch(result) {
+       case MLX_SYSD_ONLINE:
+               statusfmt = "%s: online\n";
+               break;
+
+       case MLX_SYSD_CRITICAL:
+               statusfmt = "%s: critical\n";
+               if (!rstatus)
+                       rstatus = 1;
+               break;
+
+       case MLX_SYSD_OFFLINE:
+               statusfmt = "%s: offline\n";
+               rstatus = 2;
+               break;
+
+       default:
+               statusfmt = "%s: unknown status 0x%02x\n";
+               break;
+       }
+
+       printf(statusfmt, md->name, result);
+
+       /* Rebuild/check in progress on this drive? */
+       if (rs.rs_drive == md->hwunit &&
+           rs.rs_code != MLX_REBUILDSTAT_IDLE) {
+               switch(rs.rs_code) {
+               case MLX_REBUILDSTAT_REBUILDCHECK:
+                       printf(" [consistency check");
+                       break;
+
+               case MLX_REBUILDSTAT_ADDCAPACITY:
+                       printf(" [add capacity");
+                       break;
+
+               case MLX_REBUILDSTAT_ADDCAPACITYINIT:
+                       printf(" [add capacity init");
+                       break;
+
+               default:
+                       printf(" [unknown operation");
+                       break;
+               }
+
+               printf(": %d/%d, %d%% complete]\n", rs.rs_remaining, rs.rs_size,
+                  ((rs.rs_size - rs.rs_remaining) / (rs.rs_size / 100)));
+       }
+}
+
+int
+cmd_status(char **argv)
+{
+
+       if (ioctl(mlxfd, MLX_REBUILDSTAT, &rs) < 0)
+               err(EXIT_FAILURE, "ioctl(MLX_REBUILDSTAT)");
+
+       mlx_disk_iterate(cmd_status0);
+       return (rstatus);
+}
+
+/*
+ * Display controller status.
+ */
+int
+cmd_cstatus(char **argv)
+{
+       struct mlx_enquiry2 enq;
+       struct mlx_phys_drv pd;
+       static char buf[80];
+       const char *model;
+       int i, channel, target;
+
+       mlx_enquiry(&enq);
+
+       for (i = 0; i < sizeof(mlx_ctlr_names) / sizeof(mlx_ctlr_names[0]); i++)
+               if (enq.me_hardware_id[0] == mlx_ctlr_names[i].hwid) {
+                       model = mlx_ctlr_names[i].name;
+                       break;
+               }
+
+       if (i == sizeof(mlx_ctlr_names) / sizeof(mlx_ctlr_names[0])) {
+               sprintf(buf, " model 0x%x", enq.me_hardware_id[0]);
+               model = buf;
+       }
+
+       printf("DAC%s, %d channel%s, firmware %d.%02d-%c-%02d, %dMB RAM\n",
+           model, enq.me_actual_channels,
+           enq.me_actual_channels > 1 ? "s" : "",
+           enq.me_firmware_id[0], enq.me_firmware_id[1],
+           enq.me_firmware_id[2], enq.me_firmware_id[3],
+           le32toh(enq.me_mem_size) / (1024 * 1024));
+
+       if (verbosity > 0) {
+               printf("  Hardware ID\t\t\t0x%08x\n",
+                   le32toh(*(u_int32_t *)enq.me_hardware_id));
+               printf("  Firmware ID\t\t\t0x%08x\n",
+                   le32toh(*(u_int32_t *)enq.me_firmware_id));
+               printf("  Configured/Actual channels\t%d/%d\n",
+                   enq.me_configured_channels, enq.me_actual_channels);
+               printf("  Max Targets\t\t\t%d\n", enq.me_max_targets);
+               printf("  Max Tags\t\t\t%d\n", enq.me_max_tags);
+               printf("  Max System Drives\t\t%d\n", enq.me_max_sys_drives);
+               printf("  Max Arms\t\t\t%d\n", enq.me_max_arms);



Home | Main Index | Thread Index | Old Index