[Midnightbsd-cvs] src [10464] trunk/usr.sbin/mfiutil: sync mfiutil with freebsd 10
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Wed Jun 6 19:59:22 EDT 2018
Revision: 10464
http://svnweb.midnightbsd.org/src/?rev=10464
Author: laffer1
Date: 2018-06-06 19:59:21 -0400 (Wed, 06 Jun 2018)
Log Message:
-----------
sync mfiutil with freebsd 10
Modified Paths:
--------------
trunk/usr.sbin/mfiutil/Makefile
trunk/usr.sbin/mfiutil/mfi_bbu.c
trunk/usr.sbin/mfiutil/mfi_cmd.c
trunk/usr.sbin/mfiutil/mfi_config.c
trunk/usr.sbin/mfiutil/mfi_drive.c
trunk/usr.sbin/mfiutil/mfi_evt.c
trunk/usr.sbin/mfiutil/mfi_flash.c
trunk/usr.sbin/mfiutil/mfi_patrol.c
trunk/usr.sbin/mfiutil/mfi_show.c
trunk/usr.sbin/mfiutil/mfi_volume.c
trunk/usr.sbin/mfiutil/mfiutil.8
trunk/usr.sbin/mfiutil/mfiutil.c
trunk/usr.sbin/mfiutil/mfiutil.h
Added Paths:
-----------
trunk/usr.sbin/mfiutil/mfi_foreign.c
trunk/usr.sbin/mfiutil/mfi_properties.c
Property Changed:
----------------
trunk/usr.sbin/mfiutil/mfiutil.8
Modified: trunk/usr.sbin/mfiutil/Makefile
===================================================================
--- trunk/usr.sbin/mfiutil/Makefile 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/Makefile 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,11 +1,13 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.sbin/mfiutil/Makefile 272041 2014-09-23 21:38:05Z smh $
PROG= mfiutil
SRCS= mfiutil.c mfi_bbu.c mfi_cmd.c mfi_config.c mfi_drive.c mfi_evt.c \
- mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c
+ mfi_flash.c mfi_patrol.c mfi_show.c mfi_volume.c mfi_foreign.c \
+ mfi_properties.c
MAN8= mfiutil.8
-CFLAGS+= -fno-builtin-strftime
+CFLAGS.gcc+= -fno-builtin-strftime
DPADD= ${LIBUTIL}
LDADD= -lutil
Modified: trunk/usr.sbin/mfiutil/mfi_bbu.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_bbu.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_bbu.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2013 Sandvine Inc.
* All rights reserved.
@@ -23,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $FreeBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_bbu.c 249258 2013-04-08 18:25:07Z markj $
*/
#include <sys/param.h>
Modified: trunk/usr.sbin/mfiutil/mfi_cmd.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_cmd.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_cmd.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_cmd.c 237259 2012-06-19 06:18:37Z eadler $
*/
#include <sys/errno.h>
Modified: trunk/usr.sbin/mfiutil/mfi_config.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_config.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_config.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_config.c 251516 2013-06-08 02:54:59Z sbruno $
*/
#include <sys/param.h>
@@ -37,9 +38,7 @@
#include <errno.h>
#include <fcntl.h>
#include <libutil.h>
-#ifdef DEBUG
#include <stdint.h>
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -46,10 +45,6 @@
#include <unistd.h>
#include "mfiutil.h"
-#ifdef DEBUG
-static void dump_config(int fd, struct mfi_config_data *config);
-#endif
-
static int add_spare(int ac, char **av);
static int remove_spare(int ac, char **av);
@@ -81,9 +76,17 @@
}
return (iv);
}
+
int
mfi_config_read(int fd, struct mfi_config_data **configp)
{
+ return mfi_config_read_opcode(fd, MFI_DCMD_CFG_READ, configp, NULL, 0);
+}
+
+int
+mfi_config_read_opcode(int fd, uint32_t opcode, struct mfi_config_data **configp,
+ uint8_t *mbox, size_t mboxlen)
+{
struct mfi_config_data *config;
uint32_t config_size;
int error;
@@ -98,8 +101,8 @@
config = reallocf(config, config_size);
if (config == NULL)
return (-1);
- if (mfi_dcmd_command(fd, MFI_DCMD_CFG_READ, config,
- config_size, NULL, 0, NULL) < 0) {
+ if (mfi_dcmd_command(fd, opcode, config,
+ config_size, mbox, mboxlen, NULL) < 0) {
error = errno;
free(config);
errno = error;
@@ -366,6 +369,13 @@
info->drives = NULL;
return (EINVAL);
}
+
+ if (pinfo->state.ddf.v.pd_type.is_foreign) {
+ warnx("Drive %u is foreign", device_id);
+ free(info->drives);
+ info->drives = NULL;
+ return (EINVAL);
+ }
}
return (0);
@@ -804,7 +814,7 @@
#ifdef DEBUG
if (dump)
- dump_config(fd, config);
+ dump_config(fd, config, NULL);
#endif
/* Send the new config to the controller. */
@@ -1093,10 +1103,9 @@
}
MFI_COMMAND(top, remove, remove_spare);
-#ifdef DEBUG
/* Display raw data about a config. */
-static void
-dump_config(int fd, struct mfi_config_data *config)
+void
+dump_config(int fd, struct mfi_config_data *config, const char *msg_prefix)
{
struct mfi_array *ar;
struct mfi_ld_config *ld;
@@ -1106,9 +1115,12 @@
char *p;
int i, j;
+ if (NULL == msg_prefix)
+ msg_prefix = "Configuration (Debug)";
+
printf(
- "mfi%d Configuration (Debug): %d arrays, %d volumes, %d spares\n",
- mfi_unit, config->array_count, config->log_drv_count,
+ "mfi%d %s: %d arrays, %d volumes, %d spares\n", mfi_unit,
+ msg_prefix, config->array_count, config->log_drv_count,
config->spares_count);
printf(" array size: %u\n", config->array_size);
printf(" volume size: %u\n", config->log_drv_size);
@@ -1186,6 +1198,7 @@
}
}
+#ifdef DEBUG
static int
debug_config(int ac, char **av)
{
@@ -1213,7 +1226,7 @@
}
/* Dump out the configuration. */
- dump_config(fd, config);
+ dump_config(fd, config, NULL);
free(config);
close(fd);
@@ -1265,7 +1278,7 @@
close(fd);
return (error);
}
- dump_config(fd, config);
+ dump_config(fd, config, NULL);
free(config);
close(fd);
Modified: trunk/usr.sbin/mfiutil/mfi_drive.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_drive.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_drive.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_drive.c 254906 2013-08-26 12:05:38Z sbruno $
*/
#include <sys/types.h>
@@ -474,6 +475,20 @@
MFI_COMMAND(top, rebuild, rebuild_drive);
static int
+syspd_drive(int ac, char **av)
+{
+
+ if (ac != 2) {
+ warnx("syspd: %s", ac > 2 ? "extra arguments" :
+ "drive required");
+ return (EINVAL);
+ }
+
+ return (drive_set_state(av[1], MFI_PD_STATE_SYSTEM));
+}
+MFI_COMMAND(top, syspd, syspd_drive);
+
+static int
start_rebuild(int ac, char **av)
{
struct mfi_pd_info info;
Modified: trunk/usr.sbin/mfiutil/mfi_evt.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_evt.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_evt.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_evt.c 266400 2014-05-18 15:28:25Z jhb $
*/
#include <sys/types.h>
@@ -33,6 +34,7 @@
#include <sys/errno.h>
#include <err.h>
#include <fcntl.h>
+#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
@@ -534,6 +536,7 @@
struct mfi_evt_log_state info;
struct mfi_evt_list *list;
union mfi_evt filter;
+ bool first;
long val;
char *cp;
ssize_t size;
@@ -640,7 +643,9 @@
close(fd);
return (ENOMEM);
}
- for (seq = start;;) {
+ first = true;
+ seq = start;
+ for (;;) {
if (mfi_get_events(fd, list, num_events, filter, seq,
&status) < 0) {
error = errno;
@@ -650,8 +655,6 @@
return (error);
}
if (status == MFI_STAT_NOT_FOUND) {
- if (seq == start)
- warnx("No matching events found");
break;
}
if (status != MFI_STAT_OK) {
@@ -669,13 +672,14 @@
* the case that our stop point is earlier in
* the buffer than our start point.
*/
- if (list->event[i].seq >= stop) {
+ if (list->event[i].seq > stop) {
if (start <= stop)
- break;
+ goto finish;
else if (list->event[i].seq < start)
- break;
+ goto finish;
}
mfi_decode_evt(fd, &list->event[i], verbose);
+ first = false;
}
/*
@@ -686,6 +690,9 @@
seq = list->event[list->count - 1].seq + 1;
}
+finish:
+ if (first)
+ warnx("No matching events found");
free(list);
close(fd);
Modified: trunk/usr.sbin/mfiutil/mfi_flash.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_flash.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_flash.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_flash.c 241776 2012-10-20 10:20:06Z ed $
*/
#include <sys/param.h>
@@ -42,36 +43,6 @@
#define FLASH_BUF_SIZE (64 * 1024)
-int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
-
-static void
-scan_firmware(struct mfi_info_component *comp)
-{
- int len;
-
- len = strlen(comp->name);
- if (fw_name_width < len)
- fw_name_width = len;
- len = strlen(comp->version);
- if (fw_version_width < len)
- fw_version_width = len;
- len = strlen(comp->build_date);
- if (fw_date_width < len)
- fw_date_width = len;
- len = strlen(comp->build_time);
- if (fw_time_width < len)
- fw_time_width = len;
-}
-
-static void
-display_firmware(struct mfi_info_component *comp)
-{
-
- printf("%-*s %-*s %-*s %-*s\n", fw_name_width, comp->name,
- fw_version_width, comp->version, fw_date_width, comp->build_date,
- fw_time_width, comp->build_time);
-}
-
static int
display_pending_firmware(int fd)
{
@@ -96,9 +67,9 @@
info.pending_image_component_count = 8;
for (i = 0; i < info.pending_image_component_count; i++)
scan_firmware(&info.pending_image_component[i]);
- display_firmware(&header);
+ display_firmware(&header, "");
for (i = 0; i < info.pending_image_component_count; i++)
- display_firmware(&info.pending_image_component[i]);
+ display_firmware(&info.pending_image_component[i], "");
return (0);
}
Added: trunk/usr.sbin/mfiutil/mfi_foreign.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_foreign.c (rev 0)
+++ trunk/usr.sbin/mfiutil/mfi_foreign.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -0,0 +1,365 @@
+/* $MidnightBSD$ */
+/*
+ * Copyright (c) 2013 smh at freebsd.org
+ * 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.
+ *
+ *
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_foreign.c 285950 2015-07-28 12:40:41Z emaste $
+ */
+
+#include <sys/param.h>
+#include <err.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <libutil.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "mfiutil.h"
+
+MFI_TABLE(top, foreign);
+
+static int
+foreign_clear(__unused int ac, __unused char **av)
+{
+ int ch, error, fd;
+
+ fd = mfi_open(mfi_unit, O_RDWR);
+ if (fd < 0) {
+ error = errno;
+ warn("mfi_open");
+ return (error);
+ }
+
+ printf(
+ "Are you sure you wish to clear ALL foreign configurations"
+ " on mfi%u? [y/N] ", mfi_unit);
+
+ ch = getchar();
+ if (ch != 'y' && ch != 'Y') {
+ printf("\nAborting\n");
+ close(fd);
+ return (0);
+ }
+
+ if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_CLEAR, NULL, 0, NULL,
+ 0, NULL) < 0) {
+ error = errno;
+ warn("Failed to clear foreign configuration");
+ close(fd);
+ return (error);
+ }
+
+ printf("mfi%d: Foreign configuration cleared\n", mfi_unit);
+ close(fd);
+ return (0);
+}
+MFI_COMMAND(foreign, clear, foreign_clear);
+
+static int
+foreign_scan(__unused int ac, __unused char **av)
+{
+ struct mfi_foreign_scan_info info;
+ int error, fd;
+
+ fd = mfi_open(mfi_unit, O_RDONLY);
+ if (fd < 0) {
+ error = errno;
+ warn("mfi_open");
+ return (error);
+ }
+
+ if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_SCAN, &info,
+ sizeof(info), NULL, 0, NULL) < 0) {
+ error = errno;
+ warn("Failed to scan foreign configuration");
+ close(fd);
+ return (error);
+ }
+
+ printf("mfi%d: Found %d foreign configurations\n", mfi_unit,
+ info.count);
+ close(fd);
+ return (0);
+}
+MFI_COMMAND(foreign, scan, foreign_scan);
+
+static int
+foreign_show_cfg(int fd, uint32_t opcode, uint8_t cfgidx, int diagnostic)
+{
+ struct mfi_config_data *config;
+ char prefix[64];
+ int error;
+ uint8_t mbox[4];
+
+ bzero(mbox, sizeof(mbox));
+ mbox[0] = cfgidx;
+ if (mfi_config_read_opcode(fd, opcode, &config, mbox, sizeof(mbox)) < 0) {
+ error = errno;
+ warn("Failed to get foreign config %d", error);
+ close(fd);
+ return (error);
+ }
+
+ if (opcode == MFI_DCMD_CFG_FOREIGN_PREVIEW)
+ sprintf(prefix, "Foreign configuration preview %d", cfgidx);
+ else
+ sprintf(prefix, "Foreign configuration %d", cfgidx);
+ /*
+ * MegaCli uses DCMD opcodes: 0x03100200 (which fails) followed by
+ * 0x1a721880 which returns what looks to be drive / volume info
+ * but we have no real information on what these are or what they do
+ * so we're currently relying solely on the config returned above
+ */
+ if (diagnostic)
+ dump_config(fd, config, prefix);
+ else {
+ char *ld_list;
+ int i;
+
+ ld_list = (char *)(config->array);
+
+ printf("%s: %d arrays, %d volumes, %d spares\n", prefix,
+ config->array_count, config->log_drv_count,
+ config->spares_count);
+
+
+ for (i = 0; i < config->array_count; i++)
+ ld_list += config->array_size;
+
+ for (i = 0; i < config->log_drv_count; i++) {
+ const char *level;
+ char size[6], stripe[5];
+ struct mfi_ld_config *ld;
+
+ ld = (struct mfi_ld_config *)ld_list;
+
+ format_stripe(stripe, sizeof(stripe),
+ ld->params.stripe_size);
+ /*
+ * foreign configs don't seem to have a secondary raid level
+ * but, we can use span depth here as if a LD spans multiple
+ * arrays of disks (2 raid 1 sets for example), we will have an
+ * indication based on the spam depth. swb
+ */
+ level = mfi_raid_level(ld->params.primary_raid_level,
+ (ld->params.span_depth - 1));
+
+ humanize_number(size, sizeof(size), ld->span[0].num_blocks * 512,
+ "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+
+ printf(" ID%d ", i);
+ printf("(%6s) %-8s |",
+ size, level);
+ printf("volume spans %d %s\n", ld->params.span_depth,
+ (ld->params.span_depth > 1) ? "arrays" : "array");
+ for (int j = 0; j < ld->params.span_depth; j++) {
+ char *ar_list;
+ struct mfi_array *ar;
+ uint16_t device_id;
+
+ printf(" array %u @ ", ld->span[j].array_ref);
+ humanize_number(size, sizeof(size), ld->span[j].num_blocks * 512,
+ "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL);
+
+ printf("(%6s)\n",size);
+ ar_list = (char *)config->array + (ld->span[j].array_ref * config->array_size);
+
+ ar = (struct mfi_array *)ar_list;
+ for (int k = 0; k < ar->num_drives; k++) {
+ device_id = ar->pd[k].ref.v.device_id;
+ if (device_id == 0xffff)
+ printf(" drive MISSING\n");
+ else {
+ printf(" drive %u %s\n", device_id,
+ mfi_pdstate(ar->pd[k].fw_state));
+ }
+ }
+
+ }
+ ld_list += config->log_drv_size;
+ }
+ }
+
+ free(config);
+
+ return (0);
+}
+
+int
+display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd)
+{
+ struct mfi_foreign_scan_info info;
+ uint8_t i;
+ int error, fd;
+
+ if (ac > 2) {
+ warnx("foreign display: extra arguments");
+ return (EINVAL);
+ }
+
+ fd = mfi_open(mfi_unit, O_RDONLY);
+ if (fd < 0) {
+ error = errno;
+ warn("mfi_open");
+ return (error);
+ }
+
+ if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_SCAN, &info,
+ sizeof(info), NULL, 0, NULL) < 0) {
+ error = errno;
+ warn("Failed to scan foreign configuration");
+ close(fd);
+ return (error);
+ }
+
+ if (info.count == 0) {
+ warnx("foreign display: no foreign configs found");
+ close(fd);
+ return (EINVAL);
+ }
+
+ if (ac == 1) {
+ for (i = 0; i < info.count; i++) {
+ error = foreign_show_cfg(fd,
+ display_cmd, i, diagnostic);
+ if(error != 0) {
+ close(fd);
+ return (error);
+ }
+ if (i < info.count - 1)
+ printf("\n");
+ }
+ } else if (ac == 2) {
+ error = foreign_show_cfg(fd,
+ display_cmd, atoi(av[1]), diagnostic);
+ if (error != 0) {
+ close(fd);
+ return (error);
+ }
+ }
+
+ close(fd);
+ return (0);
+}
+
+static int
+foreign_display(int ac, char **av)
+{
+ return(display_format(ac, av, 1/*diagnostic output*/, MFI_DCMD_CFG_FOREIGN_DISPLAY));
+}
+MFI_COMMAND(foreign, diag, foreign_display);
+
+static int
+foreign_preview(int ac, char **av)
+{
+ return(display_format(ac, av, 1/*diagnostic output*/, MFI_DCMD_CFG_FOREIGN_PREVIEW));
+}
+MFI_COMMAND(foreign, preview, foreign_preview);
+
+static int
+foreign_import(int ac, char **av)
+{
+ struct mfi_foreign_scan_info info;
+ int ch, error, fd;
+ uint8_t cfgidx;
+ uint8_t mbox[4];
+
+ if (ac > 2) {
+ warnx("foreign preview: extra arguments");
+ return (EINVAL);
+ }
+
+ fd = mfi_open(mfi_unit, O_RDWR);
+ if (fd < 0) {
+ error = errno;
+ warn("mfi_open");
+ return (error);
+ }
+
+ if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_SCAN, &info,
+ sizeof(info), NULL, 0, NULL) < 0) {
+ error = errno;
+ warn("Failed to scan foreign configuration");
+ close(fd);
+ return (error);
+ }
+
+ if (info.count == 0) {
+ warnx("foreign import: no foreign configs found");
+ close(fd);
+ return (EINVAL);
+ }
+
+ if (ac == 1) {
+ cfgidx = 0xff;
+ printf("Are you sure you wish to import ALL foreign "
+ "configurations on mfi%u? [y/N] ", mfi_unit);
+ } else {
+ /*
+ * While this is docmmented for MegaCli this failed with
+ * exit code 0x03 on the test controller which was a Supermicro
+ * SMC2108 with firmware 12.12.0-0095 which is a LSI 2108 based
+ * controller.
+ */
+ cfgidx = atoi(av[1]);
+ if (cfgidx >= info.count) {
+ warnx("Invalid foreign config %d specified max is %d",
+ cfgidx, info.count - 1);
+ close(fd);
+ return (EINVAL);
+ }
+ printf("Are you sure you wish to import the foreign "
+ "configuration %d on mfi%u? [y/N] ", cfgidx, mfi_unit);
+ }
+
+ ch = getchar();
+ if (ch != 'y' && ch != 'Y') {
+ printf("\nAborting\n");
+ close(fd);
+ return (0);
+ }
+
+ bzero(mbox, sizeof(mbox));
+ mbox[0] = cfgidx;
+ if (mfi_dcmd_command(fd, MFI_DCMD_CFG_FOREIGN_IMPORT, NULL, 0, mbox,
+ sizeof(mbox), NULL) < 0) {
+ error = errno;
+ warn("Failed to import foreign configuration");
+ close(fd);
+ return (error);
+ }
+
+ if (ac == 1)
+ printf("mfi%d: All foreign configurations imported\n",
+ mfi_unit);
+ else
+ printf("mfi%d: Foreign configuration %d imported\n", mfi_unit,
+ cfgidx);
+ close(fd);
+ return (0);
+}
+MFI_COMMAND(foreign, import, foreign_import);
Property changes on: trunk/usr.sbin/mfiutil/mfi_foreign.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.sbin/mfiutil/mfi_patrol.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_patrol.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_patrol.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_patrol.c 237260 2012-06-19 06:18:42Z eadler $
*/
#include <sys/types.h>
Added: trunk/usr.sbin/mfiutil/mfi_properties.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_properties.c (rev 0)
+++ trunk/usr.sbin/mfiutil/mfi_properties.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -0,0 +1,172 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2013 Yahoo!, 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 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.
+ *
+ *
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_properties.c 272041 2014-09-23 21:38:05Z smh $
+ */
+
+#include <sys/errno.h>
+#include <sys/ioctl.h>
+#include <sys/param.h>
+#include <sys/sysctl.h>
+#include <sys/uio.h>
+
+#include <err.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "mfiutil.h"
+#include <dev/mfi/mfi_ioctl.h>
+
+MFI_TABLE(top, ctrlprop);
+
+static int
+mfi_ctrl_get_properties(int fd, struct mfi_ctrl_props *info)
+{
+
+ return (mfi_dcmd_command(fd, MFI_DCMD_CTRL_GET_PROPS, info,
+ sizeof(struct mfi_ctrl_props), NULL, 0, NULL));
+}
+
+static int
+mfi_ctrl_set_properties(int fd, struct mfi_ctrl_props *info)
+{
+
+ return (mfi_dcmd_command(fd, MFI_DCMD_CTRL_SET_PROPS, info,
+ sizeof(struct mfi_ctrl_props), NULL, 0, NULL));
+}
+
+/*
+ * aquite the controller properties data structure modify the
+ * rebuild rate if requested and then retun
+ */
+static int
+mfi_ctrl_rebuild_rate(int ac, char **av)
+{
+ int error, fd;
+ struct mfi_ctrl_props ctrl_props;
+
+ if (ac > 2) {
+ warn("mfi_ctrl_set_rebuild_rate");
+ return(-1);
+ }
+
+ fd = mfi_open(mfi_unit, O_RDWR);
+ if (fd < 0) {
+ error = errno;
+ warn("mfi_open");
+ return (error);
+ }
+
+ error = mfi_ctrl_get_properties(fd, &ctrl_props);
+ if ( error < 0) {
+ error = errno;
+ warn("Failed to get controller properties");
+ close(fd);
+ return (error);
+ }
+ /*
+ * User requested a change to the rebuild rate
+ */
+ if (ac > 1) {
+ ctrl_props.rebuild_rate = atoi(av[ac - 1]);
+ error = mfi_ctrl_set_properties(fd, &ctrl_props);
+ if ( error < 0) {
+ error = errno;
+ warn("Failed to set controller properties");
+ close(fd);
+ return (error);
+ }
+
+ error = mfi_ctrl_get_properties(fd, &ctrl_props);
+ if ( error < 0) {
+ error = errno;
+ warn("Failed to get controller properties");
+ close(fd);
+ return (error);
+ }
+ }
+ printf ("controller rebuild rate: %%%u \n",
+ ctrl_props.rebuild_rate);
+ return (0);
+}
+MFI_COMMAND(ctrlprop, rebuild, mfi_ctrl_rebuild_rate);
+
+static int
+mfi_ctrl_alarm_enable(int ac, char **av)
+{
+ int error, fd;
+ struct mfi_ctrl_props ctrl_props;
+
+ if (ac > 2) {
+ warn("mfi_ctrl_alarm_enable");
+ return(-1);
+ }
+
+ fd = mfi_open(mfi_unit, O_RDWR);
+ if (fd < 0) {
+ error = errno;
+ warn("mfi_open");
+ return (error);
+ }
+
+ error = mfi_ctrl_get_properties(fd, &ctrl_props);
+ if ( error < 0) {
+ error = errno;
+ warn("Failed to get controller properties");
+ close(fd);
+ return (error);
+ }
+ printf ("controller alarm was : %s\n",
+ (ctrl_props.alarm_enable ? "enabled" : "disabled"));
+
+ if (ac > 1) {
+ ctrl_props.alarm_enable = atoi(av[ac - 1]);
+ error = mfi_ctrl_set_properties(fd, &ctrl_props);
+ if ( error < 0) {
+ error = errno;
+ warn("Failed to set controller properties");
+ close(fd);
+ return (error);
+ }
+
+ error = mfi_ctrl_get_properties(fd, &ctrl_props);
+ if ( error < 0) {
+ error = errno;
+ warn("Failed to get controller properties");
+ close(fd);
+ return (error);
+ }
+ }
+ printf ("controller alarm was : %s\n",
+ (ctrl_props.alarm_enable ? "enabled" : "disabled"));
+ return (0);
+}
+
+MFI_COMMAND(ctrlprop, alarm, mfi_ctrl_alarm_enable);
Property changes on: trunk/usr.sbin/mfiutil/mfi_properties.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/usr.sbin/mfiutil/mfi_show.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_show.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_show.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_show.c 266400 2014-05-18 15:28:25Z jhb $
*/
#include <sys/types.h>
@@ -40,9 +41,11 @@
#include <unistd.h>
#include "mfiutil.h"
+static const char* foreign_state = " (FOREIGN)";
+
MFI_TABLE(top, show);
-static void
+void
format_stripe(char *buf, size_t buflen, uint8_t stripe)
{
@@ -291,7 +294,7 @@
}
MFI_COMMAND(show, battery, show_battery);
-static void
+void
print_ld(struct mfi_ld_info *info, int state_len)
{
struct mfi_ld_params *params = &info->ld_config.params;
@@ -312,19 +315,24 @@
mfi_ldstate(params->state));
}
-static void
+void
print_pd(struct mfi_pd_info *info, int state_len)
{
const char *s;
- char buf[6];
+ char buf[256];
- humanize_number(buf, sizeof(buf), info->raw_size * 512, "",
+ humanize_number(buf, 6, info->raw_size * 512, "",
HN_AUTOSCALE, HN_B | HN_NOSPACE |HN_DECIMAL);
printf("(%6s) ", buf);
+ if (info->state.ddf.v.pd_type.is_foreign) {
+ sprintf(buf, "%s%s", mfi_pdstate(info->fw_state), foreign_state);
+ s = buf;
+ } else
+ s = mfi_pdstate(info->fw_state);
if (state_len > 0)
- printf("%-*s", state_len, mfi_pdstate(info->fw_state));
+ printf("%-*s", state_len, s);
else
- printf("%s", mfi_pdstate(info->fw_state));
+ printf("%s",s);
s = mfi_pd_inq_string(info);
if (s != NULL)
printf(" %s", s);
@@ -560,6 +568,8 @@
goto error;
}
len = strlen(mfi_pdstate(info.fw_state));
+ if (info.state.ddf.v.pd_type.is_foreign)
+ len += strlen(foreign_state);
if (len > state_len)
state_len = len;
}
@@ -597,36 +607,6 @@
}
MFI_COMMAND(show, drives, show_drives);
-int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
-
-static void
-scan_firmware(struct mfi_info_component *comp)
-{
- int len;
-
- len = strlen(comp->name);
- if (fw_name_width < len)
- fw_name_width = len;
- len = strlen(comp->version);
- if (fw_version_width < len)
- fw_version_width = len;
- len = strlen(comp->build_date);
- if (fw_date_width < len)
- fw_date_width = len;
- len = strlen(comp->build_time);
- if (fw_time_width < len)
- fw_time_width = len;
-}
-
-static void
-display_firmware(struct mfi_info_component *comp, const char *tag)
-{
-
- printf("%-*s %-*s %-*s %-*s %s\n", fw_name_width, comp->name,
- fw_version_width, comp->version, fw_date_width, comp->build_date,
- fw_time_width, comp->build_time, tag);
-}
-
static int
show_firmware(int ac, char **av __unused)
{
@@ -800,3 +780,10 @@
return (0);
}
MFI_COMMAND(show, progress, show_progress);
+
+static int
+show_foreign(int ac, char **av)
+{
+ return(display_format(ac, av, 0/*normal display*/, MFI_DCMD_CFG_FOREIGN_DISPLAY));
+}
+MFI_COMMAND(show, foreign, show_foreign);
Modified: trunk/usr.sbin/mfiutil/mfi_volume.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfi_volume.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfi_volume.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfi_volume.c 249257 2013-04-08 17:46:45Z markj $
*/
#include <sys/types.h>
Modified: trunk/usr.sbin/mfiutil/mfiutil.8
===================================================================
--- trunk/usr.sbin/mfiutil/mfiutil.8 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfiutil.8 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\" Copyright (c) 2008, 2009 Yahoo!, Inc.
.\" All rights reserved.
.\"
@@ -25,7 +26,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.sbin/mfiutil/mfiutil.8 293290 2016-01-07 00:40:51Z bdrewery $
.\"
.Dd September 2, 2011
.Dt MFIUTIL 8
@@ -63,6 +64,9 @@
.Cm show firmware
.Nm
.Op Fl u Ar unit
+.Cm show foreign Op Ar volume
+.Nm
+.Op Fl u Ar unit
.Cm show logstate
.Nm
.Op Fl d
@@ -88,6 +92,9 @@
.Cm rebuild Ar drive
.Nm
.Op Fl u Ar unit
+.Cm syspd Ar drive
+.Nm
+.Op Fl u Ar unit
.Cm drive progress Ar drive
.Nm
.Op Fl u Ar unit
@@ -140,6 +147,21 @@
.Cm patrol Ar command Op Ar interval Op Ar start
.Nm
.Op Fl u Ar unit
+.Cm foreign scan
+.Nm
+.Op Fl u Ar unit
+.Cm foreign clear Op Ar config
+.Nm
+.Op Fl u Ar unit
+.Cm foreign diag Op Ar config
+.Nm
+.Op Fl u Ar unit
+.Cm foreign preview Op Ar config
+.Nm
+.Op Fl u Ar unit
+.Cm foreign import Op Ar config
+.Nm
+.Op Fl u Ar unit
.Cm flash Ar file
.Nm
.Op Fl u Ar unit
@@ -147,6 +169,12 @@
.Nm
.Op Fl u Ar unit
.Cm bbu Ar setting Ar value
+.Nm
+.Op Fl u Ar unit
+.Cm ctrlprop Ar rebuild Op Ar rate
+.Nm
+.Op Fl u Ar unit
+.Cm ctrlprop Ar alarm Op Ar 0/1
.Sh DESCRIPTION
The
.Nm
@@ -256,7 +284,7 @@
The default class is
.Dq warn .
The available classes from lowest priority to highest are:
-.Bl -tag -width -indent
+.Bl -tag -width indent
.It Cm debug
Debug messages.
.It Cm progress
@@ -306,7 +334,7 @@
parameters.
Each of these parameters can either be specified as a log entry number or as
one of the following aliases:
-.Bl -tag -width -indent
+.Bl -tag -width indent
.It Cm newest
The newest entry in the event log.
.It Cm oldest
@@ -321,6 +349,8 @@
.El
.It Cm show firmware
Lists all of the firmware images present on the controller.
+.It Cm show foreign
+Displays detected foreign configurations on disks for importation or removal.
.It Cm show logstate
Display the various sequence numbers associated with the event log.
.It Cm show patrol
@@ -352,6 +382,11 @@
that is still part of an array as a good drive suitable for a rebuild.
The firmware should kick off an array rebuild on its own if a failed drive
is marked as a rebuild drive.
+.It Cm syspd Ar drive
+Present the drive to the host operating system as a disk SYSPD block device in
+the format /dev/mfisyspdX. Clear this flag with
+.Cm good
+.Ar drive
.It Cm drive progress Ar drive
Report the current progress and estimated completion time of drive operations
such as rebuilds or patrol reads.
@@ -567,6 +602,35 @@
Start a patrol read operation.
.It Cm stop patrol
Stop a currently running patrol read operation.
+.It Cm foreign scan
+Scan for foreign configurations and display the number found. The
+.Ar config
+argument for the commands below takes the form of a number from 0 to the total
+configurations found.
+.It Cm foreign clear Op config
+Clear the specified foreign
+.Ar config
+or all if no
+.Ar config
+argument is provided.
+.It Cm foreign diag Op config
+Display a diagnostic display of the specified foreign
+.Ar config
+or all if no
+.Ar config
+argument is provided.
+.It Cm foreign preview Op config
+Preview the specified foreign
+.Ar config
+after import or all if no
+.Ar config
+argument is provided.
+.It Cm foreign import Op config
+Import the specified foreign
+.Ar config
+or all if no
+.Ar config
+argument is provided.
.It Cm flash Ar file
Updates the flash on the controller with the firmware stored in
.Ar file .
@@ -573,6 +637,10 @@
A reboot is required for the new firmware to take effect.
.It Cm start learn
Start a battery relearn.
+Note that this seems to always result in the battery being completely drained,
+regardless of the BBU mode.
+In particular, the controller write cache will be disabled during the relearn
+even if transparent learning mode is enabled.
.It Cm bbu Ar setting Ar value
Update battery backup unit (BBU) properties related to battery relearning.
The following settings are configurable:
@@ -598,6 +666,12 @@
Modes 1, 2 and 3 enable a transparent learn cycle, whereas modes 4 and 5 do not.
The BBU's data retention time is greater when transparent learning is not used.
.El
+.It Cm ctrlprop Ar rebuild Op Ar rate
+With no arguments display the rate of rebuild (percentage)a for volumes.
+With an integer argument (0-100), set that value as the new rebuild rate for volumes.
+.It Cm ctrlprop Ar alarm Op Ar 0/1
+With no arguments display the current alarm enable/disable status.
+With a 0, disable alarms. With a 1, enable alarms.
.El
.Sh EXAMPLES
Configure the cache for volume mfid0 to cache only writes:
@@ -626,11 +700,22 @@
.Pp
.Dl Nm Cm add s2 mfid0
.Pp
+Reconfigure a disk as a SYSPD block device with no RAID
+.Pp
+.Dl Nm Cm syspd 0
+.Pp
Configure the adapter to run periodic patrol reads once a week with the first
patrol read starting in 5 minutes:
.Pp
.Dl Nm Cm patrol auto 604800 300
.Pp
+Display the second detected foreign configuration:
+.Pp
+.Dl Nm Cm show foreign 1
+.Pp
+Set the current rebuild rate for volumes to 40%:
+.Dl Nm Cm ctrlprop rebuild 40
+.Pp
.Sh SEE ALSO
.Xr mfi 4
.Sh HISTORY
Property changes on: trunk/usr.sbin/mfiutil/mfiutil.8
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.sbin/mfiutil/mfiutil.c
===================================================================
--- trunk/usr.sbin/mfiutil/mfiutil.c 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfiutil.c 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfiutil.c 272041 2014-09-23 21:38:05Z smh $
*/
#include <sys/errno.h>
@@ -44,8 +45,8 @@
MFI_TABLE(top, abort);
int mfi_unit;
-
u_int mfi_opts;
+static int fw_name_width, fw_version_width, fw_date_width, fw_time_width;
static void
usage(void)
@@ -60,13 +61,15 @@
fprintf(stderr, " show drives - list physical drives\n");
fprintf(stderr, " show events - display event log\n");
fprintf(stderr, " show firmware - list firmware images\n");
+ fprintf(stderr, " show foreign - display detected foreign volumes\n");
fprintf(stderr, " show logstate - display event log sequence numbers\n");
fprintf(stderr, " show volumes - list logical volumes\n");
fprintf(stderr, " show patrol - display patrol read status\n");
fprintf(stderr, " show progress - display status of active operations\n");
fprintf(stderr, " fail <drive> - fail a physical drive\n");
- fprintf(stderr, " good <drive> - mark a bad physical drive as good\n");
+ fprintf(stderr, " good <drive> - set a failed/SYSPD drive as UNCONFIGURED\n");
fprintf(stderr, " rebuild <drive> - mark failed drive ready for rebuild\n");
+ fprintf(stderr, " syspd <drive> - set drive into use as SYSPD JBOD\n");
fprintf(stderr, " drive progress <drive> - display status of active operations\n");
fprintf(stderr, " drive clear <drive> <start|stop> - clear a drive with all 0x00\n");
fprintf(stderr, " start rebuild <drive>\n");
@@ -83,9 +86,16 @@
fprintf(stderr, " patrol <disable|auto|manual> [interval [start]]\n");
fprintf(stderr, " start patrol - start a patrol read\n");
fprintf(stderr, " stop patrol - stop a patrol read\n");
+ fprintf(stderr, " foreign scan - scan for foreign configurations\n");
+ fprintf(stderr, " foreign clear [volume] - clear foreign configurations (default all)\n");
+ fprintf(stderr, " foreign diag [volume] - diagnostic display foreign configurations (default all)\n");
+ fprintf(stderr, " foreign preview [volume] - preview foreign configurations (default all)\n");
+ fprintf(stderr, " foreign import [volume] - import foreign configurations (default all)\n");
fprintf(stderr, " flash <firmware>\n");
fprintf(stderr, " start learn - start a BBU relearn\n");
fprintf(stderr, " bbu <setting> <value> - set BBU properties\n");
+ fprintf(stderr, " ctrlprop rebuild [rate] - get/set the volume rebuild rate\n");
+ fprintf(stderr, " ctrlprop alarm [0/1] - enable/disable controller alarms\n");
#ifdef DEBUG
fprintf(stderr, " debug - debug 'show config'\n");
fprintf(stderr, " dump - display 'saved' config\n");
@@ -97,7 +107,7 @@
version(int ac __unused, char **av __unused)
{
- printf("mfiutil version 1.0.14");
+ printf("mfiutil version 1.0.15");
#ifdef DEBUG
printf(" (DEBUG)");
#endif
@@ -146,3 +156,31 @@
warnx("Unknown command %s.", av[0]);
return (1);
}
+
+void
+scan_firmware(struct mfi_info_component *comp)
+{
+ int len;
+
+ len = strlen(comp->name);
+ if (fw_name_width < len)
+ fw_name_width = len;
+ len = strlen(comp->version);
+ if (fw_version_width < len)
+ fw_version_width = len;
+ len = strlen(comp->build_date);
+ if (fw_date_width < len)
+ fw_date_width = len;
+ len = strlen(comp->build_time);
+ if (fw_time_width < len)
+ fw_time_width = len;
+}
+
+void
+display_firmware(struct mfi_info_component *comp, const char *tag)
+{
+
+ printf("%-*s %-*s %-*s %-*s %s\n", fw_name_width, comp->name,
+ fw_version_width, comp->version, fw_date_width, comp->build_date,
+ fw_time_width, comp->build_time, tag);
+}
Modified: trunk/usr.sbin/mfiutil/mfiutil.h
===================================================================
--- trunk/usr.sbin/mfiutil/mfiutil.h 2018-06-06 23:58:34 UTC (rev 10463)
+++ trunk/usr.sbin/mfiutil/mfiutil.h 2018-06-06 23:59:21 UTC (rev 10464)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2008, 2009 Yahoo!, Inc.
* All rights reserved.
@@ -26,7 +27,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/usr.sbin/mfiutil/mfiutil.h 251516 2013-06-08 02:54:59Z sbruno $
*/
#ifndef __MFIUTIL_H__
@@ -121,8 +122,19 @@
#define MFI_DNAME_HONOR_OPTS 0x8000 /* Allow cmd line to override default */
extern int mfi_unit;
+
extern u_int mfi_opts;
+/* We currently don't know the full details of the following struct */
+struct mfi_foreign_scan_cfg {
+ char data[24];
+};
+
+struct mfi_foreign_scan_info {
+ uint32_t count; /* Number of foreign configs found */
+ struct mfi_foreign_scan_cfg cfgs[8];
+};
+
void mbox_store_ldref(uint8_t *mbox, union mfi_ld_ref *ref);
void mbox_store_pdref(uint8_t *mbox, union mfi_pd_ref *ref);
void mfi_display_progress(const char *label, struct mfi_progress *prog);
@@ -135,6 +147,8 @@
const char *mfi_volume_name(int fd, uint8_t target_id);
int mfi_volume_busy(int fd, uint8_t target_id);
int mfi_config_read(int fd, struct mfi_config_data **configp);
+int mfi_config_read_opcode(int fd, uint32_t opcode,
+ struct mfi_config_data **configp, uint8_t *mbox, size_t mboxlen);
int mfi_lookup_drive(int fd, char *drive, uint16_t *device_id);
int mfi_lookup_volume(int fd, const char *name, uint8_t *target_id);
int mfi_dcmd_command(int fd, uint32_t opcode, void *buf, size_t bufsize,
@@ -151,6 +165,10 @@
const char *mfi_status(u_int status_code);
const char *mfi_drive_name(struct mfi_pd_info *pinfo, uint16_t device_id,
uint32_t def);
+void format_stripe(char *buf, size_t buflen, uint8_t stripe);
+void print_ld(struct mfi_ld_info *info, int state_len);
+void print_pd(struct mfi_pd_info *info, int state_len);
+void dump_config(int fd, struct mfi_config_data *config, const char *msg_prefix);
int mfi_bbu_get_props(int fd, struct mfi_bbu_properties *props,
uint8_t *statusp);
int mfi_bbu_set_props(int fd, struct mfi_bbu_properties *props,
@@ -159,4 +177,8 @@
void mfi_next_learn_time(uint32_t, char *, size_t);
void mfi_autolearn_mode(uint8_t, char *, size_t);
+void scan_firmware(struct mfi_info_component *comp);
+void display_firmware(struct mfi_info_component *comp, const char *tag);
+
+int display_format(int ac, char **av, int diagnostic, mfi_dcmd_t display_cmd);
#endif /* !__MFIUTIL_H__ */
More information about the Midnightbsd-cvs
mailing list