Source-Changes-HG archive

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

[src/trunk]: src nvmectl(8): Sync with FreeBSD nvmecontrol(8) r328763.



details:   https://anonhg.NetBSD.org/src/rev/c53d1d9ba23e
branches:  trunk
changeset: 831857:c53d1d9ba23e
user:      nonaka <nonaka%NetBSD.org@localhost>
date:      Tue Apr 17 08:54:35 2018 +0000

description:
nvmectl(8): Sync with FreeBSD nvmecontrol(8) r328763.

diffstat:

 sbin/nvmectl/Makefile   |    3 +-
 sbin/nvmectl/devlist.c  |    8 +-
 sbin/nvmectl/firmware.c |    8 +-
 sbin/nvmectl/identify.c |   22 ++++-
 sbin/nvmectl/logpage.c  |  115 ++++++++++---------------
 sbin/nvmectl/nvmectl.c  |   47 +---------
 sbin/nvmectl/nvmectl.h  |   16 ++-
 sbin/nvmectl/perftest.c |    8 +-
 sbin/nvmectl/reset.c    |    8 +-
 sbin/nvmectl/util.c     |  131 +++++++++++++++++++++++++++++
 sbin/nvmectl/wdc.c      |  213 +++++++----------------------------------------
 sys/dev/ic/nvmereg.h    |   93 ++++++++++++++++++++-
 12 files changed, 356 insertions(+), 316 deletions(-)

diffs (truncated from 1209 to 300 lines):

diff -r dfe46c0c005f -r c53d1d9ba23e sbin/nvmectl/Makefile
--- a/sbin/nvmectl/Makefile     Tue Apr 17 08:47:43 2018 +0000
+++ b/sbin/nvmectl/Makefile     Tue Apr 17 08:54:35 2018 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.3 2017/04/29 00:06:40 nonaka Exp $
+#      $NetBSD: Makefile,v 1.4 2018/04/17 08:54:35 nonaka Exp $
 
 .include <bsd.own.mk>
 
@@ -11,6 +11,7 @@
 SRCS+= perftest.c
 SRCS+= power.c
 SRCS+= reset.c
+SRCS+= util.c
 SRCS+= wdc.c
 SRCS+= bignum.c
 SRCS+= humanize_bignum.c
diff -r dfe46c0c005f -r c53d1d9ba23e sbin/nvmectl/devlist.c
--- a/sbin/nvmectl/devlist.c    Tue Apr 17 08:47:43 2018 +0000
+++ b/sbin/nvmectl/devlist.c    Tue Apr 17 08:54:35 2018 +0000
@@ -1,6 +1,8 @@
-/*     $NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $     */
+/*     $NetBSD: devlist.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $       */
 
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
@@ -28,9 +30,9 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: devlist.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
+__RCSID("$NetBSD: devlist.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $");
 #if 0
-__FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 260381 2014-01-06 23:48:47Z jimharris $");
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/devlist.c 326276 2017-11-27 15:37:16Z pfg $");
 #endif
 #endif
 
diff -r dfe46c0c005f -r c53d1d9ba23e sbin/nvmectl/firmware.c
--- a/sbin/nvmectl/firmware.c   Tue Apr 17 08:47:43 2018 +0000
+++ b/sbin/nvmectl/firmware.c   Tue Apr 17 08:54:35 2018 +0000
@@ -1,6 +1,8 @@
-/*     $NetBSD: firmware.c,v 1.2 2017/04/29 00:06:40 nonaka Exp $      */
+/*     $NetBSD: firmware.c,v 1.3 2018/04/17 08:54:35 nonaka Exp $      */
 
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (c) 2013 EMC Corp.
  * All rights reserved.
  *
@@ -31,9 +33,9 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: firmware.c,v 1.2 2017/04/29 00:06:40 nonaka Exp $");
+__RCSID("$NetBSD: firmware.c,v 1.3 2018/04/17 08:54:35 nonaka Exp $");
 #if 0
-__FBSDID("$FreeBSD: head/sbin/nvmecontrol/firmware.c 313188 2017-02-04 05:52:50Z imp $");
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/firmware.c 326276 2017-11-27 15:37:16Z pfg $");
 #endif
 #endif
 
diff -r dfe46c0c005f -r c53d1d9ba23e sbin/nvmectl/identify.c
--- a/sbin/nvmectl/identify.c   Tue Apr 17 08:47:43 2018 +0000
+++ b/sbin/nvmectl/identify.c   Tue Apr 17 08:54:35 2018 +0000
@@ -1,6 +1,8 @@
-/*     $NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $    */
+/*     $NetBSD: identify.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $      */
 
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (C) 2012-2013 Intel Corporation
  * All rights reserved.
  *
@@ -28,9 +30,9 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: identify.c,v 1.3 2018/03/17 11:07:26 jdolecek Exp $");
+__RCSID("$NetBSD: identify.c,v 1.4 2018/04/17 08:54:35 nonaka Exp $");
 #if 0
-__FBSDID("$FreeBSD: head/sbin/nvmecontrol/identify.c 253476 2013-07-19 21:40:57Z jimharris $");
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/identify.c 326276 2017-11-27 15:37:16Z pfg $");
 #endif
 #endif
 
@@ -72,6 +74,7 @@
                printf("Unlimited\n");
        else
                printf("%ld\n", sysconf(_SC_PAGESIZE) * (1 << cdata->mdts));
+       printf("Controller ID:              0x%02x\n", cdata->cntlid);
        printf("\n");
 
        printf("Admin Command Set Attributes\n");
@@ -85,6 +88,9 @@
        printf("Firmware Activate/Download:  %s\n",
                (cdata->oacs & NVME_ID_CTRLR_OACS_FW) ?
                "Supported" : "Not Supported");
+       printf("Namespace Managment:         %s\n",
+               (cdata->oacs & NVME_ID_CTRLR_OACS_NS) ?
+               "Supported" : "Not Supported");
        printf("Abort Command Limit:         %d\n", cdata->acl+1);
        printf("Async Event Request Limit:   %d\n", cdata->aerl+1);
        printf("Number of Firmware Slots:    ");
@@ -139,6 +145,16 @@
        printf("Volatile Write Cache:        %s\n",
                (cdata->vwc & NVME_ID_CTRLR_VWC_PRESENT) ?
                "Present" : "Not Present");
+
+       if (cdata->oacs & NVME_ID_CTRLR_OACS_NS) {
+               printf("\n");
+               printf("Namespace Drive Attributes\n");
+               printf("==========================\n");
+               print_bignum("NVM total cap:               ",
+                   cdata->untncap.tnvmcap, "");
+               print_bignum("NVM unallocated cap:         ",
+                   cdata->untncap.unvmcap, "");
+       }
 }
 
 static void
diff -r dfe46c0c005f -r c53d1d9ba23e sbin/nvmectl/logpage.c
--- a/sbin/nvmectl/logpage.c    Tue Apr 17 08:47:43 2018 +0000
+++ b/sbin/nvmectl/logpage.c    Tue Apr 17 08:54:35 2018 +0000
@@ -1,6 +1,8 @@
-/*     $NetBSD: logpage.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $     */
+/*     $NetBSD: logpage.c,v 1.6 2018/04/17 08:54:35 nonaka Exp $       */
 
 /*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
  * Copyright (c) 2013 EMC Corp.
  * All rights reserved.
  *
@@ -31,9 +33,9 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: logpage.c,v 1.5 2018/03/17 11:07:26 jdolecek Exp $");
+__RCSID("$NetBSD: logpage.c,v 1.6 2018/04/17 08:54:35 nonaka Exp $");
 #if 0
-__FBSDID("$FreeBSD: head/sbin/nvmecontrol/logpage.c 314230 2017-02-25 00:09:16Z imp $");
+__FBSDID("$FreeBSD: head/sbin/nvmecontrol/logpage.c 326276 2017-11-27 15:37:16Z pfg $");
 #endif
 #endif
 
@@ -52,12 +54,12 @@
 #include <unistd.h>
 
 #include "nvmectl.h"
-#include "bn.h"
 
 #define DEFAULT_SIZE   (4096)
 #define MAX_FW_SLOTS   (7)
 
-typedef void (*print_fn_t)(void *buf, uint32_t size);
+typedef void (*print_fn_t)(const struct nvm_identify_controller *cdata, void *buf,
+    uint32_t size);
 
 struct kv_name {
        uint32_t key;
@@ -78,18 +80,17 @@
 }
 
 static void
-print_bin(void *data, uint32_t length)
+print_log_hex(const struct nvm_identify_controller *cdata __unused, void *data,
+    uint32_t length)
 {
-       write(STDOUT_FILENO, data, length);
+       print_hex(data, length);
 }
 
-/* "Missing" from endian.h */
-static __inline uint64_t
-le48dec(const void *pp)
+static void
+print_bin(const struct nvm_identify_controller *cdata __unused, void *data,
+    uint32_t length)
 {
-       uint8_t const *p = (uint8_t const *)pp;
-
-       return (((uint64_t)le16dec(p + 4) << 32) | le32dec(p));
+       write(STDOUT_FILENO, data, length);
 }
 
 static void *
@@ -127,7 +128,8 @@
 }
 
 static void
-print_log_error(void *buf, uint32_t size)
+print_log_error(const struct nvm_identify_controller *cdata __unused, void *buf,
+    uint32_t size)
 {
        int                                     i, nentries;
        struct nvme_error_information_entry     *entry = buf;
@@ -171,46 +173,6 @@
        }
 }
 
-#define        METRIX_PREFIX_BUFSIZ    17
-#define        NO_METRIX_PREFIX_BUFSIZ 42
-
-static void
-print_bignum(const char *title, uint64_t v[2], const char *suffix)
-{
-       char buf[64];
-       uint8_t tmp[16];
-       uint64_t l = le64toh(v[0]);
-       uint64_t h = le64toh(v[1]);
-
-       tmp[ 0] = (h >> 56) & 0xff;
-       tmp[ 1] = (h >> 48) & 0xff;
-       tmp[ 2] = (h >> 40) & 0xff;
-       tmp[ 3] = (h >> 32) & 0xff;
-       tmp[ 4] = (h >> 24) & 0xff;
-       tmp[ 5] = (h >> 16) & 0xff;
-       tmp[ 6] = (h >> 8) & 0xff;
-       tmp[ 7] = h & 0xff;
-       tmp[ 8] = (l >> 56) & 0xff;
-       tmp[ 9] = (l >> 48) & 0xff;
-       tmp[10] = (l >> 40) & 0xff;
-       tmp[11] = (l >> 32) & 0xff;
-       tmp[12] = (l >> 24) & 0xff;
-       tmp[13] = (l >> 16) & 0xff;
-       tmp[14] = (l >> 8) & 0xff;
-       tmp[15] = l & 0xff;
-
-       buf[0] = '\0';
-       BIGNUM *bn = BN_bin2bn(tmp, __arraycount(tmp), NULL);
-       if (bn != NULL) {
-               humanize_bignum(buf, METRIX_PREFIX_BUFSIZ + strlen(suffix),
-                   bn, suffix, HN_AUTOSCALE, HN_DECIMAL);
-               BN_free(bn);
-       }
-       if (buf[0] == '\0')
-               snprintf(buf, sizeof(buf), "0x%016jx%016jx", h, l);
-       printf("%-31s %s\n", title, buf);
-}
-
 static void
 print_temp(uint16_t t)
 {
@@ -219,7 +181,8 @@
 }
 
 static void
-print_log_health(void *buf, uint32_t size __unused)
+print_log_health(const struct nvm_identify_controller *cdata __unused, void *buf,
+    uint32_t size __unused)
 {
        struct nvme_health_information_page *health = buf;
        int i;
@@ -278,16 +241,23 @@
 }
 
 static void
-print_log_firmware(void *buf, uint32_t size __unused)
+print_log_firmware(const struct nvm_identify_controller *cdata, void *buf,
+    uint32_t size __unused)
 {
-       u_int                           i;
+       u_int                           i, slots;
        const char                      *status;
        struct nvme_firmware_page       *fw = buf;
 
        printf("Firmware Slot Log\n");
        printf("=================\n");
 
-       for (i = 0; i < MAX_FW_SLOTS; i++) {
+       if (!(cdata->oacs & NVME_ID_CTRLR_OACS_FW))
+               slots = 1;
+       else
+               slots = MIN(__SHIFTOUT(cdata->frmw, NVME_ID_CTRLR_FRMW_NSLOT),
+                   MAX_FW_SLOTS);
+
+       for (i = 0; i < slots; i++) {
                printf("Slot %d: ", i + 1);
                if (__SHIFTOUT(fw->afi, NVME_FW_PAGE_AFI_SLOT) == i + 1)
                        status = "  Active";
@@ -314,7 +284,8 @@
  * offset 147: it is only 1 byte, not 6.
  */
 static void
-print_intel_temp_stats(void *buf, uint32_t size __unused)
+print_intel_temp_stats(const struct nvm_identify_controller *cdata __unused,
+    void *buf, uint32_t size __unused)
 {
        struct intel_log_temp_stats     *temp = buf;
 
@@ -344,7 +315,8 @@
  * Read and write stats pages have identical encoding.
  */



Home | Main Index | Thread Index | Old Index