Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F109843249
D33866.id101360.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D33866.id101360.diff
View Options
Index: sbin/nvmecontrol/modules/Makefile
===================================================================
--- sbin/nvmecontrol/modules/Makefile
+++ sbin/nvmecontrol/modules/Makefile
@@ -1,5 +1,5 @@
# $FreeBSD$
-SUBDIR= intel wdc
+SUBDIR= intel wdc micron
.include <bsd.subdir.mk>
Index: sbin/nvmecontrol/modules/micron/Makefile
===================================================================
--- /dev/null
+++ sbin/nvmecontrol/modules/micron/Makefile
@@ -0,0 +1,6 @@
+# $FreeBSD$
+
+LIB= micron
+SRCS= micron.c
+
+.include <bsd.lib.mk>
Index: sbin/nvmecontrol/modules/micron/micron.c
===================================================================
--- /dev/null
+++ sbin/nvmecontrol/modules/micron/micron.c
@@ -0,0 +1,125 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
+ *
+ * Copyright (c) 2022 Wanpeng Qian <wanpengqian@gmail.com>
+ *
+ * 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.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/ioccom.h>
+
+#include <ctype.h>
+#include <err.h>
+#include <fcntl.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/endian.h>
+
+#include "nvmecontrol.h"
+
+/*
+ * Table 19. 5.4 SMART Attributes. Others also implement this and some extra data not documented.
+ */
+static void
+print_micron_add_smart(const struct nvme_controller_data *cdata __unused, void *buf, uint32_t size __unused)
+{
+ uint8_t *walker = buf;
+ uint8_t *end = walker + 150;
+ const char *name;
+ uint64_t raw;
+ uint8_t normalized;
+
+ static struct kv_name kv[] =
+ {
+ { 0xf9, "NAND Writes 1GiB" },
+ { 0xfa, "NAND Reads 1GiB" },
+ { 0xea, "Thermal Throttle Status" },
+ { 0xe7, "Temperature" },
+ { 0xe8, "Power Consumption" },
+ { 0xaf, "Power Loss Protection" },
+ };
+
+ printf("Additional SMART Data Log\n");
+ printf("=========================\n");
+ /*
+ * walker[0] = Key
+ * walker[1,2] = reserved
+ * walker[3] = Normalized Value
+ * walker[4] = reserved
+ * walker[5..10] = Little Endian Raw value
+ * (or other represenations)
+ * walker[11] = reserved
+ */
+ while (walker < end) {
+ name = kv_lookup(kv, nitems(kv), *walker);
+ normalized = walker[3];
+ raw = le48dec(walker + 5);
+ switch (*walker){
+ case 0:
+ break;
+ case 0xf9:
+ /* FALLTHOUGH */
+ case 0xfa:
+ printf("%2X %-24s: %ju GiB\n", *walker, name, (uintmax_t)raw);
+ break;
+ case 0xea:
+ printf("%2X %-24s:", *walker, name);
+ if (*(walker + 5) == 0) printf(" inactive\n");
+ if (*(walker + 5) == 1) printf(" active, total throttling time %u mins\n", le32dec(walker + 6));
+ break;
+ case 0xe7:
+ printf("%2X %-24s: max ", *walker, name); print_temp(le16dec(walker + 5));
+ printf(" : min "); print_temp(le16dec(walker + 7));
+ printf(" : cur "); print_temp(le16dec(walker + 9));
+ break;
+ case 0xe8:
+ printf("%2X %-24s: max %u W, min %u W, ave %u W\n",
+ *walker, name, le16dec(walker + 5), le16dec(walker + 7), le16dec(walker + 9));
+ break;
+ case 0xaf:
+ printf("%2X %-24s:", *walker, name);
+ if (normalized == 100) printf(" success");
+ if (normalized == 0) printf(" failed");
+ printf(" %3d\n", normalized);
+ break;
+ default:
+ printf("%2X %-24s: %3d %ju\n",
+ *walker, name, normalized, (uintmax_t)raw);
+ break;
+ }
+ walker += 12;
+ }
+}
+
+#define MICRON_LOG_ADD_SMART 0xca
+
+NVME_LOGPAGE(micron_smart,
+ MICRON_LOG_ADD_SMART, "micron", "Vendor Unique SMART Data",
+ print_micron_add_smart, DEFAULT_SIZE);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Feb 11, 6:21 AM (1 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16589868
Default Alt Text
D33866.id101360.diff (4 KB)
Attached To
Mode
D33866: nvmecontrol: Add Micron Vendor Unique SMART logpage support
Attached
Detach File
Event Timeline
Log In to Comment