From owner-svn-src-stable-9@FreeBSD.ORG Thu Jul 4 00:16:45 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 24FF2596; Thu, 4 Jul 2013 00:16:45 +0000 (UTC) (envelope-from jimharris@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 14BE1101E; Thu, 4 Jul 2013 00:16:45 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r640Gi0b076418; Thu, 4 Jul 2013 00:16:44 GMT (envelope-from jimharris@svn.freebsd.org) Received: (from jimharris@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r640GhvI076412; Thu, 4 Jul 2013 00:16:43 GMT (envelope-from jimharris@svn.freebsd.org) Message-Id: <201307040016.r640GhvI076412@svn.freebsd.org> From: Jim Harris Date: Thu, 4 Jul 2013 00:16:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r252671 - in stable/9: sbin/nvmecontrol sys/dev/nvme X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jul 2013 00:16:45 -0000 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 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 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] \n" \ +#define FIRMWARE_USAGE \ +" nvmecontrol firmware [-s slot] [-f path_to_firmware] [-a] \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 */