Skip to contentSkip to conversation

ndctl: add support for HPE type N SMART health data

PATCH In review Brian Boylston 2 participants 6 messages Sep 16, 2016 – Sep 19, 2016 libnvdimm: non-volatile memory device

lore
Share & tools
lore
#0 lore raw

v3 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 v3:
- Dropped the smart_dimm_op() macro and open coded ndctl_dimm_cmd_new_smart() and ndctl_dimm_cmd_new_smart_threshold(). (suggested by Dan)
- Do not fail add_dimm() if the read of nfit/commands fails, just set dimm->dsm_family to -1 instead (suggested by Dan). As part of this, I also moved the read to after the has_nfit() check.
- Added missing bibliography to the commit message for the last patch.
- I realized that v2 wouldn't compile if HAS_SMART was not 1, so I changed intel_smart_ops and hpe1_smart_ops into pointers and set them to NULL if HAS_SMART != 1. They are const because that seems to avoid compiler warnings about unused variables in cases where libndctl-private.h is included by something other than libndctl.c.

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 |  25 ++++
 ndctl/lib/libndctl-smart.c   | 116 ++++++++++++---
 ndctl/lib/libndctl.c         |  18 ++-
 ndctl/lib/ndctl-hpe1.h       | 335 +++++++++++++++++++++++++++++++++++++++++++
 ndctl/libndctl.h.in          |   1 +
 7 files changed, 775 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 v3 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.

---
Changes in v3:
- Dropped the smart_dimm_op() macro and open coded ndctl_dimm_cmd_new_smart() and ndctl_dimm_cmd_new_smart_threshold(). (suggested by Dan)
- I realized that v2 wouldn't compile if HAS_SMART was not 1, so I changed intel_smart_ops and hpe1_smart_ops into pointers and set them to NULL if HAS_SMART != 1. They are const because that seems to avoid compiler warnings about unused variables in cases where libndctl-private.h is included by something other than libndctl.c.

 ndctl/lib/libndctl-private.h |  23 +++++++++
 ndctl/lib/libndctl-smart.c   | 116 ++++++++++++++++++++++++++++++++++---------
 ndctl/lib/libndctl.c         |   7 +++
 ndctl/libndctl.h.in          |   1 +
 4 files changed, 124 insertions(+), 23 deletions(-)
ndctl/lib/libndctl-private.h +23 -0
index 65ef86d..5ff4fec 100644
@@ -201,6 +201,29 @@ 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 * const intel_smart_ops;
+#else
+static struct ndctl_smart_ops * const intel_smart_ops = NULL;
+#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 +93 -23

169 lines not on this page · raw message

ndctl/lib/libndctl.c +7 -0
index 93f79f7..3c9a506 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;
@@ -1163,6 +1164,7 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 		goto err_read;
 	dimm->module = to_module(ctx, buf);
 
+	dimm->smart_ops = intel_smart_ops;
 	dimm->handle = -1;
 	dimm->phys_id = -1;
 	dimm->serial = -1;
@@ -1459,6 +1461,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

PATCH v3 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.

---
Changes in v3:
- Do not fail add_dimm() if the read of nfit/commands fails, just set dimm->dsm_family to -1 instead (suggested by Dan). As part of this, I also moved the read to after the has_nfit() check.

 ndctl/lib/libndctl.c | 6 ++++++
 1 file changed, 6 insertions(+)
ndctl/lib/libndctl.c +6 -0
index 3c9a506..99938be 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;
@@ -1176,6 +1177,7 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 	dimm->subsystem_revision_id = -1;
 	dimm->manufacturing_date = -1;
 	dimm->manufacturing_location = -1;
+	dimm->dsm_family = -1;
 	for (i = 0; i < formats; i++)
 		dimm->format[i] = -1;
 
@@ -1239,6 +1241,10 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 	if (sysfs_read_attr(ctx, path, buf) == 0)
 		dimm->subsystem_revision_id = strtoul(buf, NULL, 0);
 
+	sprintf(path, "%s/nfit/family", dimm_base);
+	if (sysfs_read_attr(ctx, path, buf) == 0)
+		dimm->dsm_family = strtoul(buf, NULL, 0);
+
 	dimm->formats = formats;
 	sprintf(path, "%s/nfit/format", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) == 0)
Signature · 6 lines
2.8.3

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

PATCH v3 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 99938be..7a847fa 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;
@@ -2183,6 +2183,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
#4 lore raw

PATCH v3 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].

[1] https://github.com/HewlettPackard/hpe-nvm/raw/master/Documentation/NFIT_DSM_DDR4_NVDIMM-N_v84s.pdf

---
Changes in v3:
- Added missing bibliography to the commit message.
- I realized that v2 wouldn't compile if HAS_SMART was not 1, so I changed intel_smart_ops and hpe1_smart_ops into pointers and set them to NULL if HAS_SMART != 1. They are const because that seems to avoid compiler warnings about unused variables in cases where libndctl-private.h is included by something other than libndctl.c.

 ndctl/Makefile.am            |   1 +
 ndctl/lib/libndctl-hpe1.c    | 303 ++++++++++++++++++++++++++++++++++++++
 ndctl/lib/libndctl-private.h |   2 +
 ndctl/lib/libndctl.c         |   2 +
 ndctl/lib/ndctl-hpe1.h       | 335 +++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 643 insertions(+)
 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 +2 -0
index 5ff4fec..4363f23 100644
@@ -220,8 +220,10 @@ struct ndctl_smart_ops {
 
 #if HAS_SMART == 1
 struct ndctl_smart_ops * const intel_smart_ops;
+struct ndctl_smart_ops * const hpe1_smart_ops;
 #else
 static struct ndctl_smart_ops * const intel_smart_ops = NULL;
+static struct ndctl_smart_ops * const hpe1_smart_ops = NULL;
 #endif
 
 /* internal library helpers for conditionally defined command numbers */
ndctl/lib/libndctl.c +2 -0
index 7a847fa..a935747 100644
@@ -1244,6 +1244,8 @@ static int add_dimm(void *parent, int id, const char *dimm_base)
 	sprintf(path, "%s/nfit/family", dimm_base);
 	if (sysfs_read_attr(ctx, path, buf) == 0)
 		dimm->dsm_family = strtoul(buf, NULL, 0);
+	if (dimm->dsm_family == NVDIMM_FAMILY_HPE1)
+		dimm->smart_ops = hpe1_smart_ops;
 
 	dimm->formats = formats;
 	sprintf(path, "%s/nfit/format", dimm_base);
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
#5 lore raw
In reply to Brian Boylston
Quoted 57 lines · Brian Boylston

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 v3:
- Dropped the smart_dimm_op() macro and open coded ndctl_dimm_cmd_new_smart() and ndctl_dimm_cmd_new_smart_threshold(). (suggested by Dan)
- Do not fail add_dimm() if the read of nfit/commands fails, just set dimm->dsm_family to -1 instead (suggested by Dan). As part of this, I also moved the read to after the has_nfit() check.
- Added missing bibliography to the commit message for the last patch.
- I realized that v2 wouldn't compile if HAS_SMART was not 1, so I changed intel_smart_ops and hpe1_smart_ops into pointers and set them to NULL if HAS_SMART != 1. They are const because that seems to avoid compiler warnings about unused variables in cases where libndctl-private.h is included by something other than libndctl.c.

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).

Quoted 5 lines

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

Thanks, applied and pushed out to the 'pending' branch for ndctl-55.
_______________________________________________
Linux-nvdimm mailing list
[email protected]
https://lists.01.org/mailman/listinfo/linux-nvdimm