summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Johnston <rob.johnston@joyent.com>2018-09-19 00:25:19 +0000
committerRob Johnston <rob.johnston@joyent.com>2019-01-05 05:55:56 +0000
commit41bc442bff138d753ed92ade67e4de7adc2a2bad (patch)
tree12e84598ceb271ba6006cc12e968ae36009063fb
parent231b176446edaf7a7172cbab9c9e8142abcac68e (diff)
downloadillumos-joyent-41bc442bff138d753ed92ade67e4de7adc2a2bad.tar.gz
OS-7253 need fwflash ses verify plugin for HGST (not fully working, yet)
-rw-r--r--manifest1
-rw-r--r--usr/src/cmd/fwflash/common/fwflash.h11
-rw-r--r--usr/src/cmd/fwflash/plugins/Makefile.targ8
-rw-r--r--usr/src/cmd/fwflash/plugins/transport/common/ses.c33
-rw-r--r--usr/src/cmd/fwflash/plugins/vendor/ses-HGST.c35
-rw-r--r--usr/src/lib/scsi/libses/common/ses_snap.c3
6 files changed, 75 insertions, 16 deletions
diff --git a/manifest b/manifest
index 6c1936f1ce..f3e306a1dc 100644
--- a/manifest
+++ b/manifest
@@ -5799,6 +5799,7 @@ f usr/lib/fwflash/identify/tavor.so 0755 root bin
d usr/lib/fwflash/verify 0755 root bin
f usr/lib/fwflash/verify/hermon-MELLANOX.so 0755 root bin
f usr/lib/fwflash/verify/sd-GENERIC.so 0755 root bin
+f usr/lib/fwflash/verify/ses-HGST.so 0755 root bin
s usr/lib/fwflash/verify/ses-LSILOGIC.so=ses-SUN.so
f usr/lib/fwflash/verify/ses-SUN.so 0755 root bin
s usr/lib/fwflash/verify/sgen-LSILOGIC.so=ses-SUN.so
diff --git a/usr/src/cmd/fwflash/common/fwflash.h b/usr/src/cmd/fwflash/common/fwflash.h
index 46bffe3372..97027c5460 100644
--- a/usr/src/cmd/fwflash/common/fwflash.h
+++ b/usr/src/cmd/fwflash/common/fwflash.h
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2018 Joyent, Inc.
+ */
#ifndef _FWFLASH_H
#define _FWFLASH_H
@@ -316,6 +319,14 @@ struct vrfyplugin {
char *imgfile;
/*
+ * A verify plugin can optionally set this value to override the
+ * maximun size of data that will be sent to the device in a single
+ * command. The firmware plugin will interpret a value of zero
+ * as being not-set.
+ */
+ unsigned int chunksz;
+
+ /*
* The verification function entry point. The code
* in fwflash.c calls this function to verify that
* the nominated firmware image file is valid for
diff --git a/usr/src/cmd/fwflash/plugins/Makefile.targ b/usr/src/cmd/fwflash/plugins/Makefile.targ
index 8edeaccd66..be027838bc 100644
--- a/usr/src/cmd/fwflash/plugins/Makefile.targ
+++ b/usr/src/cmd/fwflash/plugins/Makefile.targ
@@ -21,6 +21,8 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2018 Joyent, Inc.
+#
# cmd/fwflash/plugins
#
include $(SRC)/lib/Makefile.lib
@@ -28,8 +30,10 @@ include $(SRC)/lib/Makefile.lib
HERMON-MELLANOX_LIB= hermon-MELLANOX.so
TAVOR-MELLANOX_LIB= tavor-MELLANOX.so
SD-GENERIC_LIB= sd-GENERIC.so
+SES-HGST_LIB= ses-HGST.so
-PLUGINS= $(HERMON-MELLANOX_LIB) $(TAVOR-MELLANOX_LIB) $(SD-GENERIC_LIB)
+PLUGINS= $(HERMON-MELLANOX_LIB) $(TAVOR-MELLANOX_LIB) $(SD-GENERIC_LIB) \
+ $(SES-HGST_LIB)
OBJECTS= $(PLUGINS:%.so=%.o)
DYNLIB= $(PLUGINS:%=%)
@@ -53,10 +57,12 @@ FILEMODE = 0755
$(HERMON-MELLANOX_LIB):= PICS= pics/$(HERMON-MELLANOX_LIB:%.so=%.o)
$(TAVOR-MELLANOX_LIB):= PICS = pics/$(TAVOR-MELLANOX_LIB:%.so=%.o)
$(SD-GENERIC_LIB):= PICS= pics/$(SD-GENERIC_LIB:%.so=%.o)
+$(SES-HGST_LIB):= PICS= pics/$(SES-HGST_LIB:%.so=%.o)
$(HERMON-MELLANOX_LIB):= SONAME = $(HERMON-MELLANOX_LIB)
$(TAVOR-MELLANOX_LIB):= SONAME = $(TAVOR-MELLANOX_LIB)
$(SD-GENERIC_LIB):= SONAME = $(SD-GENERIC_LIB)
+$(SES-HGST_LIB):= SONAME = $(SES-HGST_LIB)
$(HERMON-MELLANOX_LIB):= DYNFLAGS += -R/usr/lib/fwflash/identify
$(HERMON-MELLANOX_LIB):= LDLIBS += -L. $(ROOT)/usr/lib/fwflash/identify/hermon.so
diff --git a/usr/src/cmd/fwflash/plugins/transport/common/ses.c b/usr/src/cmd/fwflash/plugins/transport/common/ses.c
index f8aeb042a0..1b7891153b 100644
--- a/usr/src/cmd/fwflash/plugins/transport/common/ses.c
+++ b/usr/src/cmd/fwflash/plugins/transport/common/ses.c
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2018 Joyent, Inc.
+ */
/*
* ses (SCSI Generic Device) specific functions.
@@ -233,6 +236,13 @@ fw_writefw(struct devicelist *flashdev)
flashdev->drvname);
goto cancel;
}
+ if (verifier->chunksz != 0 && nvlist_add_uint64(nvl,
+ SES_CTL_PROP_UCODE_DATA_LEN, verifier->chunksz) != 0) {
+ logmsg(MSG_ERROR,
+ gettext("%s: unable to add chunksz property, hence unable "
+ "to flash device\n"), flashdev->drvname);
+ goto cancel;
+ }
if ((ses_target =
ses_open(LIBSES_VERSION, flashdev->access_devname)) == NULL) {
@@ -663,7 +673,7 @@ sendimg(ses_node_t *np, void *data)
char *vendor, *product, *revision, *csn;
char buf[128];
ses_snap_t *newsnap;
- int ret;
+ int ret, resp;
ucode_status_t statdesc;
ucode_wait_t wait;
uint8_t *imagedata;
@@ -699,21 +709,18 @@ sendimg(ses_node_t *np, void *data)
(void) snprintf(buf, sizeof (buf), "downloading %u bytes", len);
(void) printf("\n%30s: ", buf);
- /*
- * If the bufferid isn't 2, then the verifier has already
- * OK'd the image that the user has provided.
- *
- * At present the non-"standard" images need to be flashed
- * using the scsi WRITE BUFFER command
- */
- if (verifier->flashbuf != 2)
- return (scsi_writebuf());
-
-
if (ses_node_ctl(np, SES_CTL_OP_DL_UCODE, arg) != FWFLASH_SUCCESS) {
(void) printf("failed!\n");
(void) printf("%s\n", ses_errmsg());
- return (FWFLASH_FAILURE);
+ (void) printf("Failed to upgrade using SES commands. This "
+ "may be because the device is not fully SES-compliant.\n");
+ (void) printf("Retry upgrade using SCSI commands? (Y/N): ");
+ resp = getchar();
+ if (resp == 'Y' || resp == 'y') {
+ return (scsi_writebuf());
+ } else {
+ return(FWFLASH_FAILURE);
+ }
} else {
(void) printf("ok\n");
}
diff --git a/usr/src/cmd/fwflash/plugins/vendor/ses-HGST.c b/usr/src/cmd/fwflash/plugins/vendor/ses-HGST.c
new file mode 100644
index 0000000000..3ff9a70c04
--- /dev/null
+++ b/usr/src/cmd/fwflash/plugins/vendor/ses-HGST.c
@@ -0,0 +1,35 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright 2018 Joyent, Inc.
+ */
+
+#include <libintl.h>
+#include <fwflash/fwflash.h>
+
+extern struct vrfyplugin *verifier;
+
+char vendor[] = "HGST";
+
+/*
+ * Ultimately, we rely on the firmware verification logic that is baked into
+ * libses (see enc_do_ucode()). Thus, the only thing we do here is override
+ * the default chunk size to what the vendor has indicated is the max.
+ */
+/*ARGSUSED*/
+int
+vendorvrfy(struct devicelist *dvp)
+{
+ verifier->chunksz = 4096;
+
+ return (FWFLASH_SUCCESS);
+}
diff --git a/usr/src/lib/scsi/libses/common/ses_snap.c b/usr/src/lib/scsi/libses/common/ses_snap.c
index 94c72ff964..3f417b76a5 100644
--- a/usr/src/lib/scsi/libses/common/ses_snap.c
+++ b/usr/src/lib/scsi/libses/common/ses_snap.c
@@ -282,8 +282,7 @@ send_control_page(ses_snap_t *sp, ses_snap_page_t *pp)
tp = sp->ss_target;
- flags = LIBSCSI_AF_WRITE | LIBSCSI_AF_SILENT | LIBSCSI_AF_DIAGNOSE |
- LIBSCSI_AF_RQSENSE;
+ flags = LIBSCSI_AF_WRITE | LIBSCSI_AF_RQSENSE | LIBSCSI_AF_ISOLATE;
ap = libscsi_action_alloc(tp->st_scsi_hdl, SPC3_CMD_SEND_DIAGNOSTIC,
flags, pp->ssp_page, pp->ssp_len);