Skip to contentSkip to conversation

ndctl: add support for HPE type N SMART health data

PATCH Superseded Brian Boylston 2 participants 9 messages Sep 13, 2016 – Sep 15, 2016 libnvdimm: non-volatile memory device

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover ndctl: add support for HPE type N SMART health data

This set of patches adds support for the HPE SMART DSM functions and enables ndctl to report DIMM health data for HPE type N NVDIMMs. The relevant firmware interfaces are described in [1].

The first patch virtualizes the ndctl_cmd_smart*() family of libndctl interfaces into a set of ndctl_smart_ops, allowing runtime implementation differentiation depending on the firmware support provided by a DIMM.

The second and third patches add miscellaneous pieces needed for the final patch:

The fourth patch adds a set of ndctl_smart_ops for the HPE1 DSM family, based on the firmware interfaces defined in [1]. These ndctl_smart_ops translate the HPE1 DSM output to match the interface of the existing Intel DSM-inspired smart_ops. This delivers health reporting parity for HPE type N NVDIMMs, however:

When evaluating this ndctl_smart_ops approach, please consider our goal of adding JSON exports for some of the additional health data defined in [1]. I expect this would entail adding additional accessor functions to ndctl_smart_ops, but it's not clear whether or how to extend the existing get_flags()/check flags/get_data() model used by util_dimm_health_to_json().

If you'd like to test these changes, note the following:

. Some of the DSM functions for HPE type N NVDIMMs, including the ones used
by this patch, require the acpi_ipmi kernel module to be loaded, and you may need to manually modprobe it.

. Without [2], you'll need to include '--idle' in your ndctl invocation as
ndctl will consider type Ns to be disabled and will otherwise omit them.

. Without [3], "alarm_temperature" and "alarm_spares" will be inaccurate.

[1] https://github.com/HewlettPackard/hpe-nvm/raw/master/Documentation/NFIT_DSM_DDR4_NVDIMM-N_v84s.pdf
[2] https://lists.01.org/pipermail/linux-nvdimm/2016-August/006619.html
[3] https://lists.01.org/pipermail/linux-nvdimm/2016-September/006810.html

Changes in v2:
New approach: taught libndctl how to translate between the HPE1 DSM family and the existing ndctl_cmd_smart*() libndctl interfaces (as suggested by Dan).

Brian Boylston (4):
libndctl: introduce ndctl_smart_ops
libndctl: record dsm family in add_dimm()
libndctl: enable ND_CMD_CALL
libndctl: add support for the HPE1 family of DSM SMART functions

 ndctl/Makefile.am            |   1 +
 ndctl/lib/libndctl-hpe1.c    | 303 ++++++++++++++++++++++++++++++++++++++
 ndctl/lib/libndctl-private.h |  22 +++
 ndctl/lib/libndctl-smart.c   | 111 +++++++++++---
 ndctl/lib/libndctl.c         |  20 ++-
 ndctl/lib/ndctl-hpe1.h       | 335 +++++++++++++++++++++++++++++++++++++++++++
 ndctl/libndctl.h.in          |   1 +
 7 files changed, 769 insertions(+), 24 deletions(-)
 create mode 100644 ndctl/lib/libndctl-hpe1.c
 create mode 100644 ndctl/lib/ndctl-hpe1.h
Signature · 6 lines
2.8.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#1 lore raw

PATCH v2 1/4 libndctl: introduce ndctl_smart_ops

Add a layer of indirection for the ndctl_cmd_smart*() family of interfaces. This will allow the underlying implementation to be switched based on the DSM family supported by the DIMM.

---
 ndctl/lib/libndctl-private.h |  21 ++++++++
 ndctl/lib/libndctl-smart.c   | 111 ++++++++++++++++++++++++++++++++++---------
 ndctl/lib/libndctl.c         |   8 ++++
 ndctl/libndctl.h.in          |   1 +
 4 files changed, 118 insertions(+), 23 deletions(-)
ndctl/lib/libndctl-private.h +21 -0
index 65ef86d..8d2ebfc 100644
@@ -201,6 +201,27 @@ struct ndctl_cmd {
 	};
 };
 
+struct ndctl_smart_ops {
+	struct ndctl_cmd *(*new_smart)(struct ndctl_dimm *);
+	unsigned int (*smart_get_flags)(struct ndctl_cmd *);
+	unsigned int (*smart_get_health)(struct ndctl_cmd *);
+	unsigned int (*smart_get_temperature)(struct ndctl_cmd *);
+	unsigned int (*smart_get_spares)(struct ndctl_cmd *);
+	unsigned int (*smart_get_alarm_flags)(struct ndctl_cmd *);
+	unsigned int (*smart_get_life_used)(struct ndctl_cmd *);
+	unsigned int (*smart_get_shutdown_state)(struct ndctl_cmd *);
+	unsigned int (*smart_get_vendor_size)(struct ndctl_cmd *);
+	unsigned char *(*smart_get_vendor_data)(struct ndctl_cmd *);
+	struct ndctl_cmd *(*new_smart_threshold)(struct ndctl_dimm *);
+	unsigned int (*smart_threshold_get_alarm_control)(struct ndctl_cmd *);
+	unsigned int (*smart_threshold_get_temperature)(struct ndctl_cmd *);
+	unsigned int (*smart_threshold_get_spares)(struct ndctl_cmd *);
+};
+
+#if HAS_SMART == 1
+struct ndctl_smart_ops intel_smart_ops;
+#endif
+
 /* internal library helpers for conditionally defined command numbers */
 #ifdef HAVE_NDCTL_ARS
 static const int nd_cmd_ars_status = ND_CMD_ARS_STATUS;
ndctl/lib/libndctl-smart.c +88 -23

164 lines not on this page · raw message

ndctl/lib/libndctl.c +8 -0
index 93f79f7..9a9dc74 100644
@@ -125,6 +125,7 @@ struct ndctl_bus {
 struct ndctl_dimm {
 	struct kmod_module *module;
 	struct ndctl_bus *bus;
+	struct ndctl_smart_ops *smart_ops;
 	unsigned int handle, major, minor, serial;
 	unsigned short phys_id;
 	unsigned short vendor_id;
@@ -1149,6 +1150,8 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 		goto err_read;
 	dimm->dsm_mask = parse_commands(buf, 1);
 
+	dimm->smart_ops = &intel_smart_ops;
+
 	dimm->dimm_buf = calloc(1, strlen(dimm_base) + 50);
 	if (!dimm->dimm_buf)
 		goto err_read;
@@ -1459,6 +1462,11 @@ NDCTL_EXPORT struct ndctl_bus *ndctl_dimm_get_bus(struct ndctl_dimm *dimm)
 	return dimm->bus;
 }
 
+NDCTL_EXPORT struct ndctl_smart_ops *ndctl_dimm_get_smart_ops(struct ndctl_dimm *dimm)
+{
+	return dimm->smart_ops;
+}
+
 NDCTL_EXPORT struct ndctl_ctx *ndctl_dimm_get_ctx(struct ndctl_dimm *dimm)
 {
 	return dimm->bus->ctx;
ndctl/libndctl.h.in +1 -0
index 451466a..679225c 100644
@@ -150,6 +150,7 @@ unsigned int ndctl_dimm_handle_get_channel(struct ndctl_dimm *dimm);
 unsigned int ndctl_dimm_handle_get_dimm(struct ndctl_dimm *dimm);
 const char *ndctl_dimm_get_devname(struct ndctl_dimm *dimm);
 struct ndctl_bus *ndctl_dimm_get_bus(struct ndctl_dimm *dimm);
+struct ndctl_smart_ops *ndctl_dimm_get_smart_ops(struct ndctl_dimm *dimm);
 struct ndctl_ctx *ndctl_dimm_get_ctx(struct ndctl_dimm *dimm);
 struct ndctl_dimm *ndctl_dimm_get_by_handle(struct ndctl_bus *bus,
 		unsigned int handle);
Signature · 6 lines
2.8.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#2 lore raw

Re: [ndctl PATCH v2 1/4] libndctl: introduce ndctl_smart_ops

Quoted 4 lines · Brian Boylston

Add a layer of indirection for the ndctl_cmd_smart*() family of interfaces. This will allow the underlying implementation to be switched based on the DSM family supported by the DIMM.

Quoted 8 lines
---
 ndctl/lib/libndctl-private.h |  21 ++++++++
 ndctl/lib/libndctl-smart.c   | 111 ++++++++++++++++++++++++++++++++++---------
 ndctl/lib/libndctl.c         |   8 ++++
 ndctl/libndctl.h.in          |   1 +
 4 files changed, 118 insertions(+), 23 deletions(-)

Looks good to me and passes my regression tests.

Just one minor comment below:

Quoted 50 lines
ndctl/lib/libndctl-private.h +21 -0
index 65ef86d..8d2ebfc 100644
@@ -201,6 +201,27 @@ struct ndctl_cmd {
        };
 };
 
+struct ndctl_smart_ops {
+       struct ndctl_cmd *(*new_smart)(struct ndctl_dimm *);
+       unsigned int (*smart_get_flags)(struct ndctl_cmd *);
+       unsigned int (*smart_get_health)(struct ndctl_cmd *);
+       unsigned int (*smart_get_temperature)(struct ndctl_cmd *);
+       unsigned int (*smart_get_spares)(struct ndctl_cmd *);
+       unsigned int (*smart_get_alarm_flags)(struct ndctl_cmd *);
+       unsigned int (*smart_get_life_used)(struct ndctl_cmd *);
+       unsigned int (*smart_get_shutdown_state)(struct ndctl_cmd *);
+       unsigned int (*smart_get_vendor_size)(struct ndctl_cmd *);
+       unsigned char *(*smart_get_vendor_data)(struct ndctl_cmd *);
+       struct ndctl_cmd *(*new_smart_threshold)(struct ndctl_dimm *);
+       unsigned int (*smart_threshold_get_alarm_control)(struct ndctl_cmd *);
+       unsigned int (*smart_threshold_get_temperature)(struct ndctl_cmd *);
+       unsigned int (*smart_threshold_get_spares)(struct ndctl_cmd *);
+};
+
+#if HAS_SMART == 1
+struct ndctl_smart_ops intel_smart_ops;
+#endif
+
 /* internal library helpers for conditionally defined command numbers */
 #ifdef HAVE_NDCTL_ARS
 static const int nd_cmd_ars_status = ND_CMD_ARS_STATUS;
ndctl/lib/libndctl-smart.c +8 -1
index cba1e9d..a172541 100644
@@ -16,7 +16,55 @@
 #include <ndctl/libndctl.h>
 #include "libndctl-private.h"
 
-NDCTL_EXPORT struct ndctl_cmd *ndctl_dimm_cmd_new_smart(struct ndctl_dimm *dimm)
+/*
+ * The smart_dimm_op() and smart_cmd_op() macros are used here to
+ * define the wrappers around the ndctl_smart_ops:
+ */
+
+#define smart_dimm_op(name, op) \
+NDCTL_EXPORT struct ndctl_cmd *name( \
+               struct ndctl_dimm *dimm) \

ndctl/lib/libndctl-smart.c line 36

Quoted 10 lines
ndctl/lib/libndctl-smart.c +10 -0
+{ \
+       struct ndctl_smart_ops *ops = ndctl_dimm_get_smart_ops(dimm); \
+       if (ops && ops->op) \
+               return ops->op(dimm); \
+       else \
+               return NULL; \
+}
+
+smart_dimm_op(ndctl_dimm_cmd_new_smart, new_smart)
+smart_dimm_op(ndctl_dimm_cmd_new_smart_threshold, new_smart_threshold)

There's only two of these routines and I don't suppose there will need to have many more variants in the future. Let's just open code them and not use a macro. The rest looks good.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#3 lore raw

PATCH v2 2/4 libndctl: record dsm family in add_dimm()

In reply to Brian Boylston

The recorded DSM family can be used to provide family-specific functionality.

---
 ndctl/lib/libndctl.c | 6 ++++++
 1 file changed, 6 insertions(+)
ndctl/lib/libndctl.c +6 -0
index 9a9dc74..c824d83 100644
@@ -136,6 +136,7 @@ struct ndctl_dimm {
 	unsigned short subsystem_revision_id;
 	unsigned short manufacturing_date;
 	unsigned char manufacturing_location;
+	unsigned long dsm_family;
 	unsigned long dsm_mask;
 	char *unique_id;
 	char *dimm_path;
@@ -1145,6 +1146,11 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 	if (sscanf(buf, "%d:%d", &dimm->major, &dimm->minor) != 2)
 		goto err_read;
 
+	sprintf(path, "%s/nfit/family", dimm_base);
+	if (sysfs_read_attr(ctx, path, buf) < 0)
+		goto err_read;
+	dimm->dsm_family = strtoul(buf, NULL, 0);
+
 	sprintf(path, "%s/commands", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) < 0)
 		goto err_read;
Signature · 6 lines
2.8.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#4 lore raw

Re: [ndctl PATCH v2 2/4] libndctl: record dsm family in add_dimm()

Quoted 22 lines · Brian Boylston

The recorded DSM family can be used to provide family-specific functionality.

---
 ndctl/lib/libndctl.c | 6 ++++++
 1 file changed, 6 insertions(+)
ndctl/lib/libndctl.c +1 -0
index 9a9dc74..c824d83 100644
@@ -136,6 +136,7 @@ struct ndctl_dimm {
        unsigned short subsystem_revision_id;
        unsigned short manufacturing_date;
        unsigned char manufacturing_location;
+       unsigned long dsm_family;
        unsigned long dsm_mask;
        char *unique_id;
        char *dimm_path;

ndctl/lib/libndctl.c static int add_dimm(void *parent, int id, const char *dimm_base) · line 1152

Quoted 7 lines
ndctl/lib/libndctl.c +4 -0
@@ -1145,6 +1146,11 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
        if (sscanf(buf, "%d:%d", &dimm->major, &dimm->minor) != 2)
                goto err_read;
 
+       sprintf(path, "%s/nfit/family", dimm_base);
+       if (sysfs_read_attr(ctx, path, buf) < 0)
+               goto err_read;
+       dimm->dsm_family = strtoul(buf, NULL, 0);

Hmm I don't think it should it be fatal to add_dimm() for a failure to have a family. It's reasonable for a DIMM to exist in the NFIT, but have no DSMs or a DSM implementation that is new to the kernel. Can we make this continue on and teach consumers of ->dsm_family that it might be an error value?
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#5 lore raw

RE: [ndctl PATCH v2 2/4] libndctl: record dsm family in add_dimm()

Dan Williams wrote on 2016-09-14:

Quoted 26 lines · Brian Boylston
Quoted 25 lines

The recorded DSM family can be used to provide family-specific functionality.

---
 ndctl/lib/libndctl.c | 6 ++++++
 1 file changed, 6 insertions(+)
ndctl/lib/libndctl.c +1 -0
index 9a9dc74..c824d83 100644
@@ -136,6 +136,7 @@ struct ndctl_dimm {
        unsigned short subsystem_revision_id;
        unsigned short manufacturing_date;
        unsigned char manufacturing_location;
+       unsigned long dsm_family;
        unsigned long dsm_mask;
        char *unique_id;
        char *dimm_path;
@@ -1145,6 +1146,11 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
        if (sscanf(buf, "%d:%d", &dimm->major, &dimm->minor) != 2)
                goto err_read;
 
Quoted 11 lines

ndctl/lib/libndctl.c static int add_dimm(void *parent, int id, const char *dimm_base) · line 1152

Quoted 4 lines
ndctl/lib/libndctl.c +4 -0
+       sprintf(path, "%s/nfit/family", dimm_base);
+       if (sysfs_read_attr(ctx, path, buf) < 0)
+               goto err_read;
+       dimm->dsm_family = strtoul(buf, NULL, 0);

Hmm I don't think it should it be fatal to add_dimm() for a failure to have a family. It's reasonable for a DIMM to exist in the NFIT, but have no DSMs or a DSM implementation that is new to the kernel. Can we make this continue on and teach consumers of ->dsm_family that it might be an error value?

Sure. Some of the other values collected in add_dimm() use -1 as an error or not available value; ok to use that for dsm_family?

Also, should I add a public accessor function such as ndctl_dimm_get_dsm_family()? (although there wouldn't be a consumer yet)

Thanks!
Brian
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#6 lore raw

Re: [ndctl PATCH v2 2/4] libndctl: record dsm family in add_dimm()

Quoted 39 lines · Brian

Dan Williams wrote on 2016-09-14:

Quoted 26 lines · Brian Boylston
Quoted 25 lines

The recorded DSM family can be used to provide family-specific functionality.

---
 ndctl/lib/libndctl.c | 6 ++++++
 1 file changed, 6 insertions(+)
ndctl/lib/libndctl.c +1 -0
index 9a9dc74..c824d83 100644
@@ -136,6 +136,7 @@ struct ndctl_dimm {
        unsigned short subsystem_revision_id;
        unsigned short manufacturing_date;
        unsigned char manufacturing_location;
+       unsigned long dsm_family;
        unsigned long dsm_mask;
        char *unique_id;
        char *dimm_path;
@@ -1145,6 +1146,11 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
        if (sscanf(buf, "%d:%d", &dimm->major, &dimm->minor) != 2)
                goto err_read;
 
Quoted 11 lines

ndctl/lib/libndctl.c static int add_dimm(void *parent, int id, const char *dimm_base) · line 1152

Quoted 4 lines
ndctl/lib/libndctl.c +4 -0
+       sprintf(path, "%s/nfit/family", dimm_base);
+       if (sysfs_read_attr(ctx, path, buf) < 0)
+               goto err_read;
+       dimm->dsm_family = strtoul(buf, NULL, 0);

Hmm I don't think it should it be fatal to add_dimm() for a failure to have a family. It's reasonable for a DIMM to exist in the NFIT, but have no DSMs or a DSM implementation that is new to the kernel. Can we make this continue on and teach consumers of ->dsm_family that it might be an error value?

Quoted 2 lines

Sure. Some of the other values collected in add_dimm() use -1 as an error or not available value; ok to use that for dsm_family?

Sounds good.

Quoted 2 lines

Also, should I add a public accessor function such as ndctl_dimm_get_dsm_family()? (although there wouldn't be a consumer yet)

I'm not opposed to it for informational purposes, but I like the current direction where it doesn't really matter and the other ndctl routines are taught how to multiplex for different families.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm

#7 lore raw

PATCH v2 3/4 libndctl: enable ND_CMD_CALL

In reply to Brian Boylston

. Enable parsing /sys/bus/nd/devices/nmemX/commands for ND_CMD_CALL . Enable translation of ND_CMD_CALL to ND_IOCTL_CALL

---
 ndctl/lib/libndctl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
ndctl/lib/libndctl.c +2 -1
index c824d83..1e07520 100644
@@ -719,7 +719,7 @@ static int to_dsm_index(const char *name, int dimm)
 	int i, end_cmd;
 
 	if (dimm) {
-		end_cmd = ND_CMD_VENDOR;
+		end_cmd = ND_CMD_CALL;
 		cmd_name_fn = nvdimm_cmd_name;
 	} else {
 		end_cmd = nd_cmd_clear_error;
@@ -2184,6 +2184,7 @@ static int to_ioctl_cmd(int cmd, int dimm)
 	case ND_CMD_GET_CONFIG_DATA:        return ND_IOCTL_GET_CONFIG_DATA;
 	case ND_CMD_SET_CONFIG_DATA:        return ND_IOCTL_SET_CONFIG_DATA;
 	case ND_CMD_VENDOR:                 return ND_IOCTL_VENDOR;
+	case ND_CMD_CALL:                   return ND_IOCTL_CALL;
 	case ND_CMD_VENDOR_EFFECT_LOG_SIZE:
 	case ND_CMD_VENDOR_EFFECT_LOG:
 	default:
Signature · 6 lines
2.8.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm
#8 lore raw

PATCH v2 4/4 libndctl: add support for the HPE1 family of DSM SMART functions

In reply to Brian Boylston

This patch introduces a set of ndctl_smart_ops for the HPE1 DSM family. The implementation calls the HPE1 DSM functions defined in [1] and translates the results to match the existing Intel DSM-inspired smart_ops. This delivers health reporting parity for HPE type N NVDIMMs, but we are planning a future patch to add reporting for some of the additional health data defined in [1].

---
 ndctl/Makefile.am            |   1 +
 ndctl/lib/libndctl-hpe1.c    | 303 ++++++++++++++++++++++++++++++++++++++
 ndctl/lib/libndctl-private.h |   1 +
 ndctl/lib/libndctl.c         |   5 +-
 ndctl/lib/ndctl-hpe1.h       | 335 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 644 insertions(+), 1 deletion(-)
 create mode 100644 ndctl/lib/libndctl-hpe1.c
 create mode 100644 ndctl/lib/ndctl-hpe1.h
ndctl/Makefile.am +1 -0
index 04f3a63..fdec355 100644
@@ -31,6 +31,7 @@ endif
 
 if ENABLE_SMART
 lib_libndctl_la_SOURCES += lib/libndctl-smart.c
+lib_libndctl_la_SOURCES += lib/libndctl-hpe1.c
 endif
 
 bin_PROGRAMS = ndctl
ndctl/lib/libndctl-hpe1.c new file +303 -0

303 lines not on this page · raw message

ndctl/lib/libndctl-private.h +1 -0
index 8d2ebfc..52a3c71 100644
@@ -220,6 +220,7 @@ struct ndctl_smart_ops {
 
 #if HAS_SMART == 1
 struct ndctl_smart_ops intel_smart_ops;
+struct ndctl_smart_ops hpe1_smart_ops;
 #endif
 
 /* internal library helpers for conditionally defined command numbers */
ndctl/lib/libndctl.c +4 -1
index 1e07520..c4c8cae 100644
@@ -1156,7 +1156,10 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 		goto err_read;
 	dimm->dsm_mask = parse_commands(buf, 1);
 
-	dimm->smart_ops = &intel_smart_ops;
+	if (dimm->dsm_family == NVDIMM_FAMILY_HPE1)
+		dimm->smart_ops = &hpe1_smart_ops;
+	else
+		dimm->smart_ops = &intel_smart_ops;
 
 	dimm->dimm_buf = calloc(1, strlen(dimm_base) + 50);
 	if (!dimm->dimm_buf)
ndctl/lib/ndctl-hpe1.h new file +335 -0

335 lines not on this page · raw message

Signature · 6 lines
2.8.3

_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm