svn commit: r252671 - in stable/9: sbin/nvmecontrol sys/dev/nvme

Jim Harris jimharris at FreeBSD.org
Thu Jul 4 00:16:45 UTC 2013


Author: jimharris
Date: Thu Jul  4 00:16:43 2013
New Revision: 252671
URL: http://svnweb.freebsd.org/changeset/base/252671

Log:
  MFC r252278:
  
    Add firmware replacement and activation support to nvmecontrol(8) through
    a new firmware command.
  
    NVMe controllers may support up to 7 firmware slots for storing of
    different firmware revisions.  This new firmware command supports
    firmware replacement (i.e. firmware download) with or without immediate
    activation, or activation of a previously stored firmware image.  It
    also supports selection of the firmware slot during replacement
    operations, using IDENTIFY information from the controller to
    check that the specified slot is valid.
  
    Newly activated firmware does not take effect until the new controller
    reset, either via a reboot or separate 'nvmecontrol reset' command to the
    same controller.
  
  Submitted by:	Joe Golio <joseph.golio at emc.com>
  Obtained from:	EMC / Isilon Storage Division

Added:
  stable/9/sbin/nvmecontrol/firmware.c
     - copied, changed from r252278, head/sbin/nvmecontrol/firmware.c
Modified:
  stable/9/sbin/nvmecontrol/Makefile
  stable/9/sbin/nvmecontrol/nvmecontrol.8
  stable/9/sbin/nvmecontrol/nvmecontrol.c
  stable/9/sbin/nvmecontrol/nvmecontrol.h
  stable/9/sys/dev/nvme/nvme.h
Directory Properties:
  stable/9/sbin/nvmecontrol/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/dev/   (props changed)

Modified: stable/9/sbin/nvmecontrol/Makefile
==============================================================================
--- stable/9/sbin/nvmecontrol/Makefile	Thu Jul  4 00:06:11 2013	(r252670)
+++ stable/9/sbin/nvmecontrol/Makefile	Thu Jul  4 00:16:43 2013	(r252671)
@@ -1,7 +1,8 @@
 # $FreeBSD$
 
 PROG=	nvmecontrol
-SRCS=	nvmecontrol.c devlist.c identify.c logpage.c perftest.c reset.c
+SRCS=	nvmecontrol.c devlist.c firmware.c identify.c logpage.c	\
+	perftest.c reset.c
 MAN=	nvmecontrol.8
 
 .include <bsd.prog.mk>

Copied and modified: stable/9/sbin/nvmecontrol/firmware.c (from r252278, head/sbin/nvmecontrol/firmware.c)
==============================================================================
--- head/sbin/nvmecontrol/firmware.c	Thu Jun 27 00:08:25 2013	(r252278, copy source)
+++ stable/9/sbin/nvmecontrol/firmware.c	Thu Jul  4 00:16:43 2013	(r252671)
@@ -82,7 +82,7 @@ read_image_file(char *path, void **buf, 
 		exit(EX_IOERR);
 	}
 	if ((*buf = malloc(sb.st_size)) == NULL) {
-		fprintf(stderr, "Unable to malloc %zd bytes.\n",
+		fprintf(stderr, "Unable to malloc %jd bytes.\n",
 		    sb.st_size);
 		close(fd);
 		exit(EX_IOERR);
@@ -95,7 +95,7 @@ read_image_file(char *path, void **buf, 
 	}
 	if (*size != sb.st_size) {
 		fprintf(stderr, "Error reading '%s', "
-		    "read %zd bytes, requested %zd bytes\n",
+		    "read %zd bytes, requested %jd bytes\n",
 		    path, *size, sb.st_size);
 		close(fd);
 		exit(EX_IOERR);

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.8
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.8	Thu Jul  4 00:06:11 2013	(r252670)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.8	Thu Jul  4 00:16:43 2013	(r252671)
@@ -64,6 +64,12 @@
 .Op Fl x
 .Aq device id
 .Aq namespace id
+.Nm
+.Ic firmware
+.Op Fl s Ar slot
+.Op Fl f Ar path_to_firmware
+.Op Fl a
+.Aq device id
 .Sh DESCRIPTION
 NVM Express (NVMe) is a storage protocol standard, for SSDs and other
 high-speed storage devices over PCI Express.
@@ -100,6 +106,20 @@ SMART/Health Information Log (ID=2), and
 .Dl nvmecontrol logpage -p 1 -x nvme0
 .Pp
 Display a hexidecimal dump of the nvme0 controller's Error Information Log.
+.Pp
+.Dl nvmecontrol firmware -s 2 -f /tmp/nvme_firmware nvme0
+.Pp
+Download the firmware image contained in "/tmp/nvme_firmware" to slot 2 of the
+nvme0 controller, but do not activate the image.
+.Pp
+.Dl nvmecontrol firmware -s 4 -a nvme0
+.Pp
+Activate the firmware in slot 4 of the nvme0 controller on the next reset.
+.Pp
+.Dl nvmecontrol firmware -s 7 -f /tmp/nvme_firmware -a nvme0
+.Pp
+Download the firmware image contained in "/tmp/nvme_firmware" to slot 7 of the
+nvme0 controller and activate it on the next reset.
 .Sh AUTHORS
 .An -nosplit
 .Nm

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.c
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.c	Thu Jul  4 00:06:11 2013	(r252670)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.c	Thu Jul  4 00:16:43 2013	(r252671)
@@ -56,6 +56,7 @@ static struct nvme_function {
 	{"perftest",	perftest,	PERFTEST_USAGE},
 	{"reset",	reset,		RESET_USAGE},
 	{"logpage",	logpage,	LOGPAGE_USAGE},
+	{"firmware",	firmware,	FIRMWARE_USAGE},
 	{NULL,		NULL,		NULL},
 };
 

Modified: stable/9/sbin/nvmecontrol/nvmecontrol.h
==============================================================================
--- stable/9/sbin/nvmecontrol/nvmecontrol.h	Thu Jul  4 00:06:11 2013	(r252670)
+++ stable/9/sbin/nvmecontrol/nvmecontrol.h	Thu Jul  4 00:16:43 2013	(r252671)
@@ -52,11 +52,15 @@
 #define LOGPAGE_USAGE							       \
 "       nvmecontrol logpage <-p page_id> [-x] <controller id|namespace id>\n"  \
 
+#define FIRMWARE_USAGE							       \
+"       nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] <controller id>\n"
+
 void devlist(int argc, char *argv[]);
 void identify(int argc, char *argv[]);
 void perftest(int argc, char *argv[]);
 void reset(int argc, char *argv[]);
 void logpage(int argc, char *argv[]);
+void firmware(int argc, char *argv[]);
 
 int open_dev(const char *str, int *fd, int show_error, int exit_on_error);
 void read_controller_data(int fd, struct nvme_controller_data *cdata);

Modified: stable/9/sys/dev/nvme/nvme.h
==============================================================================
--- stable/9/sys/dev/nvme/nvme.h	Thu Jul  4 00:06:11 2013	(r252670)
+++ stable/9/sys/dev/nvme/nvme.h	Thu Jul  4 00:16:43 2013	(r252671)
@@ -383,6 +383,12 @@ enum nvme_dsm_attribute {
 	NVME_DSM_ATTR_DEALLOCATE		= 0x4,
 };
 
+enum nvme_activate_action {
+	NVME_AA_REPLACE_NO_ACTIVATE		= 0x0,
+	NVME_AA_REPLACE_ACTIVATE		= 0x1,
+	NVME_AA_ACTIVATE			= 0x2,
+};
+
 struct nvme_controller_data {
 
 	/* bytes 0-255: controller capabilities and features */


More information about the svn-src-stable mailing list