* [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 0:53 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 0:53 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel
Provide simulated SMART data to enable the ndctl implementation of SMART
data retrieval and parsing.
The payload is defined here, "Section 4.1 SMART and Health Info
(Function Index 1)":
http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/bus.c | 2 ++
include/uapi/linux/ndctl.h | 31 ++++++++++++++++++++++++++++++-
tools/testing/nvdimm/test/nfit.c | 25 +++++++++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 19f822d7f652..ea805ac641e2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -783,6 +783,8 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
+
rc = bus_register(&nvdimm_bus_type);
if (rc)
return rc;
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..f6747b90db90 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, Intel Corporation.
+ * Copyright (c) 2014-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -20,6 +20,35 @@ struct nd_cmd_smart {
__u8 data[128];
} __packed;
+enum {
+ ND_SMART_HEALTH_VALID = 1 << 0,
+ ND_SMART_TEMP_VALID = 1 << 1,
+ ND_SMART_SPARES_VALID = 1 << 2,
+ ND_SMART_ALARM_VALID = 1 << 3,
+ ND_SMART_USED_VALID = 1 << 4,
+ ND_SMART_SHUTDOWN_VALID = 1 << 5,
+ ND_SMART_VENDOR_VALID = 1 << 6,
+ ND_SMART_TEMP_TRIP = 1 << 0,
+ ND_SMART_SPARE_TRIP = 1 << 1,
+ ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
+ ND_SMART_CRITICAL_HEALTH = 1 << 1,
+ ND_SMART_FATAL_HEALTH = 1 << 2,
+};
+
+struct nd_smart_payload {
+ __u32 flags;
+ __u8 reserved0[4];
+ __u8 health;
+ __u16 temperature;
+ __u8 spares;
+ __u8 alarm_flags;
+ __u8 life_used;
+ __u8 shutdown_state;
+ __u8 reserved1;
+ __u32 vendor_size;
+ __u8 vendor_data[108];
+} __packed;
+
struct nd_cmd_smart_threshold {
__u32 status;
__u8 data[8];
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 3187322eeed7..54c9f3cc3d34 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -330,6 +330,27 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
+{
+ static const struct nd_smart_payload smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
+ | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
+ | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .temperature = 23 * 16,
+ .spares = 75,
+ .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ };
+
+ if (buf_len < sizeof(*smart))
+ return -EINVAL;
+ memcpy(smart->data, &smart_data, sizeof(*smart));
+ return 0;
+}
+
static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
unsigned int buf_len, int *cmd_rc)
@@ -368,6 +389,9 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
rc = nfit_test_cmd_set_config_data(buf, buf_len,
t->label[i]);
break;
+ case ND_CMD_SMART:
+ rc = nfit_test_cmd_smart(buf, buf_len);
+ break;
default:
return -ENOTTY;
}
@@ -1254,6 +1278,7 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
+ set_bit(ND_CMD_SMART, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_dsm_force_en);
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 0:53 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 0:53 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel
Provide simulated SMART data to enable the ndctl implementation of SMART
data retrieval and parsing.
The payload is defined here, "Section 4.1 SMART and Health Info
(Function Index 1)":
http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/bus.c | 2 ++
include/uapi/linux/ndctl.h | 31 ++++++++++++++++++++++++++++++-
tools/testing/nvdimm/test/nfit.c | 25 +++++++++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 19f822d7f652..ea805ac641e2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -783,6 +783,8 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
+
rc = bus_register(&nvdimm_bus_type);
if (rc)
return rc;
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..f6747b90db90 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, Intel Corporation.
+ * Copyright (c) 2014-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -20,6 +20,35 @@ struct nd_cmd_smart {
__u8 data[128];
} __packed;
+enum {
+ ND_SMART_HEALTH_VALID = 1 << 0,
+ ND_SMART_TEMP_VALID = 1 << 1,
+ ND_SMART_SPARES_VALID = 1 << 2,
+ ND_SMART_ALARM_VALID = 1 << 3,
+ ND_SMART_USED_VALID = 1 << 4,
+ ND_SMART_SHUTDOWN_VALID = 1 << 5,
+ ND_SMART_VENDOR_VALID = 1 << 6,
+ ND_SMART_TEMP_TRIP = 1 << 0,
+ ND_SMART_SPARE_TRIP = 1 << 1,
+ ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
+ ND_SMART_CRITICAL_HEALTH = 1 << 1,
+ ND_SMART_FATAL_HEALTH = 1 << 2,
+};
+
+struct nd_smart_payload {
+ __u32 flags;
+ __u8 reserved0[4];
+ __u8 health;
+ __u16 temperature;
+ __u8 spares;
+ __u8 alarm_flags;
+ __u8 life_used;
+ __u8 shutdown_state;
+ __u8 reserved1;
+ __u32 vendor_size;
+ __u8 vendor_data[108];
+} __packed;
+
struct nd_cmd_smart_threshold {
__u32 status;
__u8 data[8];
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 3187322eeed7..54c9f3cc3d34 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -330,6 +330,27 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
+{
+ static const struct nd_smart_payload smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
+ | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
+ | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .temperature = 23 * 16,
+ .spares = 75,
+ .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ };
+
+ if (buf_len < sizeof(*smart))
+ return -EINVAL;
+ memcpy(smart->data, &smart_data, sizeof(*smart));
+ return 0;
+}
+
static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
unsigned int buf_len, int *cmd_rc)
@@ -368,6 +389,9 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
rc = nfit_test_cmd_set_config_data(buf, buf_len,
t->label[i]);
break;
+ case ND_CMD_SMART:
+ rc = nfit_test_cmd_smart(buf, buf_len);
+ break;
default:
return -ENOTTY;
}
@@ -1254,6 +1278,7 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
+ set_bit(ND_CMD_SMART, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_dsm_force_en);
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 0:53 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 0:53 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel
Provide simulated SMART data to enable the ndctl implementation of SMART
data retrieval and parsing.
The payload is defined here, "Section 4.1 SMART and Health Info
(Function Index 1)":
http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/nvdimm/bus.c | 2 ++
include/uapi/linux/ndctl.h | 31 ++++++++++++++++++++++++++++++-
tools/testing/nvdimm/test/nfit.c | 25 +++++++++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 19f822d7f652..ea805ac641e2 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -783,6 +783,8 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
+
rc = bus_register(&nvdimm_bus_type);
if (rc)
return rc;
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..f6747b90db90 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, Intel Corporation.
+ * Copyright (c) 2014-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -20,6 +20,35 @@ struct nd_cmd_smart {
__u8 data[128];
} __packed;
+enum {
+ ND_SMART_HEALTH_VALID = 1 << 0,
+ ND_SMART_TEMP_VALID = 1 << 1,
+ ND_SMART_SPARES_VALID = 1 << 2,
+ ND_SMART_ALARM_VALID = 1 << 3,
+ ND_SMART_USED_VALID = 1 << 4,
+ ND_SMART_SHUTDOWN_VALID = 1 << 5,
+ ND_SMART_VENDOR_VALID = 1 << 6,
+ ND_SMART_TEMP_TRIP = 1 << 0,
+ ND_SMART_SPARE_TRIP = 1 << 1,
+ ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
+ ND_SMART_CRITICAL_HEALTH = 1 << 1,
+ ND_SMART_FATAL_HEALTH = 1 << 2,
+};
+
+struct nd_smart_payload {
+ __u32 flags;
+ __u8 reserved0[4];
+ __u8 health;
+ __u16 temperature;
+ __u8 spares;
+ __u8 alarm_flags;
+ __u8 life_used;
+ __u8 shutdown_state;
+ __u8 reserved1;
+ __u32 vendor_size;
+ __u8 vendor_data[108];
+} __packed;
+
struct nd_cmd_smart_threshold {
__u32 status;
__u8 data[8];
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 3187322eeed7..54c9f3cc3d34 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -330,6 +330,27 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
+{
+ static const struct nd_smart_payload smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
+ | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
+ | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .temperature = 23 * 16,
+ .spares = 75,
+ .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ };
+
+ if (buf_len < sizeof(*smart))
+ return -EINVAL;
+ memcpy(smart->data, &smart_data, sizeof(*smart));
+ return 0;
+}
+
static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
unsigned int buf_len, int *cmd_rc)
@@ -368,6 +389,9 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
rc = nfit_test_cmd_set_config_data(buf, buf_len,
t->label[i]);
break;
+ case ND_CMD_SMART:
+ rc = nfit_test_cmd_smart(buf, buf_len);
+ break;
default:
return -ENOTTY;
}
@@ -1254,6 +1278,7 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
+ set_bit(ND_CMD_SMART, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_dsm_force_en);
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm, test: add mock SMART data payload
2016-04-07 0:53 ` Dan Williams
(?)
@ 2016-04-07 8:27 ` Johannes Thumshirn
-1 siblings, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2016-04-07 8:27 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel
On Mittwoch, 6. April 2016 17:53:49 CEST Dan Williams wrote:
> Provide simulated SMART data to enable the ndctl implementation of SMART
> data retrieval and parsing.
>
> The payload is defined here, "Section 4.1 SMART and Health Info
> (Function Index 1)":
>
> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
[...]
> @@ -20,6 +20,35 @@ struct nd_cmd_smart {
> __u8 data[128];
> } __packed;
>
> +enum {
> + ND_SMART_HEALTH_VALID = 1 << 0,
> + ND_SMART_TEMP_VALID = 1 << 1,
> + ND_SMART_SPARES_VALID = 1 << 2,
> + ND_SMART_ALARM_VALID = 1 << 3,
> + ND_SMART_USED_VALID = 1 << 4,
> + ND_SMART_SHUTDOWN_VALID = 1 << 5,
> + ND_SMART_VENDOR_VALID = 1 << 6,
> + ND_SMART_TEMP_TRIP = 1 << 0,
> + ND_SMART_SPARE_TRIP = 1 << 1,
> + ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
> + ND_SMART_CRITICAL_HEALTH = 1 << 1,
> + ND_SMART_FATAL_HEALTH = 1 << 2,
> +};
Why not use BIT() instead of that 1 << x stuff and #define instead of the
abstract enum?
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 8:27 ` Johannes Thumshirn
0 siblings, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2016-04-07 8:27 UTC (permalink / raw)
To: linux-nvdimm; +Cc: Dan Williams, linux-acpi, linux-kernel
On Mittwoch, 6. April 2016 17:53:49 CEST Dan Williams wrote:
> Provide simulated SMART data to enable the ndctl implementation of SMART
> data retrieval and parsing.
>
> The payload is defined here, "Section 4.1 SMART and Health Info
> (Function Index 1)":
>
> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
[...]
> @@ -20,6 +20,35 @@ struct nd_cmd_smart {
> __u8 data[128];
> } __packed;
>
> +enum {
> + ND_SMART_HEALTH_VALID = 1 << 0,
> + ND_SMART_TEMP_VALID = 1 << 1,
> + ND_SMART_SPARES_VALID = 1 << 2,
> + ND_SMART_ALARM_VALID = 1 << 3,
> + ND_SMART_USED_VALID = 1 << 4,
> + ND_SMART_SHUTDOWN_VALID = 1 << 5,
> + ND_SMART_VENDOR_VALID = 1 << 6,
> + ND_SMART_TEMP_TRIP = 1 << 0,
> + ND_SMART_SPARE_TRIP = 1 << 1,
> + ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
> + ND_SMART_CRITICAL_HEALTH = 1 << 1,
> + ND_SMART_FATAL_HEALTH = 1 << 2,
> +};
Why not use BIT() instead of that 1 << x stuff and #define instead of the
abstract enum?
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 8:27 ` Johannes Thumshirn
0 siblings, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2016-04-07 8:27 UTC (permalink / raw)
To: linux-nvdimm; +Cc: Dan Williams, linux-acpi, linux-kernel
On Mittwoch, 6. April 2016 17:53:49 CEST Dan Williams wrote:
> Provide simulated SMART data to enable the ndctl implementation of SMART
> data retrieval and parsing.
>
> The payload is defined here, "Section 4.1 SMART and Health Info
> (Function Index 1)":
>
> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
[...]
> @@ -20,6 +20,35 @@ struct nd_cmd_smart {
> __u8 data[128];
> } __packed;
>
> +enum {
> + ND_SMART_HEALTH_VALID = 1 << 0,
> + ND_SMART_TEMP_VALID = 1 << 1,
> + ND_SMART_SPARES_VALID = 1 << 2,
> + ND_SMART_ALARM_VALID = 1 << 3,
> + ND_SMART_USED_VALID = 1 << 4,
> + ND_SMART_SHUTDOWN_VALID = 1 << 5,
> + ND_SMART_VENDOR_VALID = 1 << 6,
> + ND_SMART_TEMP_TRIP = 1 << 0,
> + ND_SMART_SPARE_TRIP = 1 << 1,
> + ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
> + ND_SMART_CRITICAL_HEALTH = 1 << 1,
> + ND_SMART_FATAL_HEALTH = 1 << 2,
> +};
Why not use BIT() instead of that 1 << x stuff and #define instead of the
abstract enum?
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm, test: add mock SMART data payload
2016-04-07 8:27 ` Johannes Thumshirn
(?)
@ 2016-04-07 16:41 ` Dan Williams
-1 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 16:41 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: Linux ACPI, linux-kernel, linux-nvdimm
On Thu, Apr 7, 2016 at 1:27 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> On Mittwoch, 6. April 2016 17:53:49 CEST Dan Williams wrote:
>> Provide simulated SMART data to enable the ndctl implementation of SMART
>> data retrieval and parsing.
>>
>> The payload is defined here, "Section 4.1 SMART and Health Info
>> (Function Index 1)":
>>
>> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> ---
>
> [...]
>
>> @@ -20,6 +20,35 @@ struct nd_cmd_smart {
>> __u8 data[128];
>> } __packed;
>>
>> +enum {
>> + ND_SMART_HEALTH_VALID = 1 << 0,
>> + ND_SMART_TEMP_VALID = 1 << 1,
>> + ND_SMART_SPARES_VALID = 1 << 2,
>> + ND_SMART_ALARM_VALID = 1 << 3,
>> + ND_SMART_USED_VALID = 1 << 4,
>> + ND_SMART_SHUTDOWN_VALID = 1 << 5,
>> + ND_SMART_VENDOR_VALID = 1 << 6,
>> + ND_SMART_TEMP_TRIP = 1 << 0,
>> + ND_SMART_SPARE_TRIP = 1 << 1,
>> + ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
>> + ND_SMART_CRITICAL_HEALTH = 1 << 1,
>> + ND_SMART_FATAL_HEALTH = 1 << 2,
>> +};
>
> Why not use BIT() instead of that 1 << x stuff and #define instead of the
> abstract enum?
Can't use BIT() since that definition isn't exported in a user header.
I don't have a strong opinion of #define vs anonymous enum, I'll go
ahead and switch it over.
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 16:41 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 16:41 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-nvdimm, Linux ACPI, linux-kernel
On Thu, Apr 7, 2016 at 1:27 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> On Mittwoch, 6. April 2016 17:53:49 CEST Dan Williams wrote:
>> Provide simulated SMART data to enable the ndctl implementation of SMART
>> data retrieval and parsing.
>>
>> The payload is defined here, "Section 4.1 SMART and Health Info
>> (Function Index 1)":
>>
>> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> ---
>
> [...]
>
>> @@ -20,6 +20,35 @@ struct nd_cmd_smart {
>> __u8 data[128];
>> } __packed;
>>
>> +enum {
>> + ND_SMART_HEALTH_VALID = 1 << 0,
>> + ND_SMART_TEMP_VALID = 1 << 1,
>> + ND_SMART_SPARES_VALID = 1 << 2,
>> + ND_SMART_ALARM_VALID = 1 << 3,
>> + ND_SMART_USED_VALID = 1 << 4,
>> + ND_SMART_SHUTDOWN_VALID = 1 << 5,
>> + ND_SMART_VENDOR_VALID = 1 << 6,
>> + ND_SMART_TEMP_TRIP = 1 << 0,
>> + ND_SMART_SPARE_TRIP = 1 << 1,
>> + ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
>> + ND_SMART_CRITICAL_HEALTH = 1 << 1,
>> + ND_SMART_FATAL_HEALTH = 1 << 2,
>> +};
>
> Why not use BIT() instead of that 1 << x stuff and #define instead of the
> abstract enum?
Can't use BIT() since that definition isn't exported in a user header.
I don't have a strong opinion of #define vs anonymous enum, I'll go
ahead and switch it over.
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 16:41 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 16:41 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: linux-nvdimm@lists.01.org, Linux ACPI, linux-kernel
On Thu, Apr 7, 2016 at 1:27 AM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> On Mittwoch, 6. April 2016 17:53:49 CEST Dan Williams wrote:
>> Provide simulated SMART data to enable the ndctl implementation of SMART
>> data retrieval and parsing.
>>
>> The payload is defined here, "Section 4.1 SMART and Health Info
>> (Function Index 1)":
>>
>> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>>
>> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
>> ---
>
> [...]
>
>> @@ -20,6 +20,35 @@ struct nd_cmd_smart {
>> __u8 data[128];
>> } __packed;
>>
>> +enum {
>> + ND_SMART_HEALTH_VALID = 1 << 0,
>> + ND_SMART_TEMP_VALID = 1 << 1,
>> + ND_SMART_SPARES_VALID = 1 << 2,
>> + ND_SMART_ALARM_VALID = 1 << 3,
>> + ND_SMART_USED_VALID = 1 << 4,
>> + ND_SMART_SHUTDOWN_VALID = 1 << 5,
>> + ND_SMART_VENDOR_VALID = 1 << 6,
>> + ND_SMART_TEMP_TRIP = 1 << 0,
>> + ND_SMART_SPARE_TRIP = 1 << 1,
>> + ND_SMART_NON_CRITICAL_HEALTH = 1 << 0,
>> + ND_SMART_CRITICAL_HEALTH = 1 << 1,
>> + ND_SMART_FATAL_HEALTH = 1 << 2,
>> +};
>
> Why not use BIT() instead of that 1 << x stuff and #define instead of the
> abstract enum?
Can't use BIT() since that definition isn't exported in a user header.
I don't have a strong opinion of #define vs anonymous enum, I'll go
ahead and switch it over.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v2] libnvdimm, test: add mock SMART data payload
2016-04-07 0:53 ` Dan Williams
(?)
@ 2016-04-07 22:32 ` Dan Williams
-1 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 22:32 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel
Provide simulated SMART data to enable the ndctl implementation of SMART
data retrieval and parsing.
The payload is defined here, "Section 4.1 SMART and Health Info
(Function Index 1)":
http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Changes in v2:
* #define the ND_SMART_ flags definitions (jth)
* add a struct nd_smart_threshold_payload definition
* add a mock implementation of smart threshold data
drivers/nvdimm/bus.c | 3 +++
include/uapi/linux/ndctl.h | 36 ++++++++++++++++++++++++++++++-
tools/testing/nvdimm/test/nfit.c | 44 ++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 19f822d7f652..8111b1299515 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -783,6 +783,9 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
+ BUILD_BUG_ON(sizeof(struct nd_smart_threshold_payload) != 8);
+
rc = bus_register(&nvdimm_bus_type);
if (rc)
return rc;
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..59c61e018a86 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, Intel Corporation.
+ * Copyright (c) 2014-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -20,11 +20,45 @@ struct nd_cmd_smart {
__u8 data[128];
} __packed;
+#define ND_SMART_HEALTH_VALID (1 << 0)
+#define ND_SMART_TEMP_VALID (1 << 1)
+#define ND_SMART_SPARES_VALID (1 << 2)
+#define ND_SMART_ALARM_VALID (1 << 3)
+#define ND_SMART_USED_VALID (1 << 4)
+#define ND_SMART_SHUTDOWN_VALID (1 << 5)
+#define ND_SMART_VENDOR_VALID (1 << 6)
+#define ND_SMART_TEMP_TRIP (1 << 0)
+#define ND_SMART_SPARE_TRIP (1 << 1)
+#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
+#define ND_SMART_CRITICAL_HEALTH (1 << 1)
+#define ND_SMART_FATAL_HEALTH (1 << 2)
+
+struct nd_smart_payload {
+ __u32 flags;
+ __u8 reserved0[4];
+ __u8 health;
+ __u16 temperature;
+ __u8 spares;
+ __u8 alarm_flags;
+ __u8 life_used;
+ __u8 shutdown_state;
+ __u8 reserved1;
+ __u32 vendor_size;
+ __u8 vendor_data[108];
+} __packed;
+
struct nd_cmd_smart_threshold {
__u32 status;
__u8 data[8];
} __packed;
+struct nd_smart_threshold_payload {
+ __u16 alarm_control;
+ __u16 temperature;
+ __u8 spares;
+ __u8 reserved[3];
+} __packed;
+
struct nd_cmd_dimm_flags {
__u32 status;
__u32 flags;
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 3187322eeed7..d1c98d4386d4 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -330,6 +330,42 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
+{
+ static const struct nd_smart_payload smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
+ | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
+ | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .temperature = 23 * 16,
+ .spares = 75,
+ .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ };
+
+ if (buf_len < sizeof(*smart))
+ return -EINVAL;
+ memcpy(smart->data, &smart_data, sizeof(smart_data));
+ return 0;
+}
+
+static int nfit_test_cmd_smart_threshold(struct nd_cmd_smart_threshold *smart_t,
+ unsigned int buf_len)
+{
+ static const struct nd_smart_threshold_payload smart_t_data = {
+ .alarm_control = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .temperature = 40 * 16,
+ .spares = 5,
+ };
+
+ if (buf_len < sizeof(*smart_t))
+ return -EINVAL;
+ memcpy(smart_t->data, &smart_t_data, sizeof(smart_t_data));
+ return 0;
+}
+
static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
unsigned int buf_len, int *cmd_rc)
@@ -368,6 +404,12 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
rc = nfit_test_cmd_set_config_data(buf, buf_len,
t->label[i]);
break;
+ case ND_CMD_SMART:
+ rc = nfit_test_cmd_smart(buf, buf_len);
+ break;
+ case ND_CMD_SMART_THRESHOLD:
+ rc = nfit_test_cmd_smart_threshold(buf, buf_len);
+ break;
default:
return -ENOTTY;
}
@@ -1254,10 +1296,12 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
+ set_bit(ND_CMD_SMART, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_dsm_force_en);
+ set_bit(ND_CMD_SMART_THRESHOLD, &acpi_desc->dimm_dsm_force_en);
}
static void nfit_test1_setup(struct nfit_test *t)
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 22:32 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 22:32 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel, jthumshirn
Provide simulated SMART data to enable the ndctl implementation of SMART
data retrieval and parsing.
The payload is defined here, "Section 4.1 SMART and Health Info
(Function Index 1)":
http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Changes in v2:
* #define the ND_SMART_ flags definitions (jth)
* add a struct nd_smart_threshold_payload definition
* add a mock implementation of smart threshold data
drivers/nvdimm/bus.c | 3 +++
include/uapi/linux/ndctl.h | 36 ++++++++++++++++++++++++++++++-
tools/testing/nvdimm/test/nfit.c | 44 ++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 19f822d7f652..8111b1299515 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -783,6 +783,9 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
+ BUILD_BUG_ON(sizeof(struct nd_smart_threshold_payload) != 8);
+
rc = bus_register(&nvdimm_bus_type);
if (rc)
return rc;
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..59c61e018a86 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, Intel Corporation.
+ * Copyright (c) 2014-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -20,11 +20,45 @@ struct nd_cmd_smart {
__u8 data[128];
} __packed;
+#define ND_SMART_HEALTH_VALID (1 << 0)
+#define ND_SMART_TEMP_VALID (1 << 1)
+#define ND_SMART_SPARES_VALID (1 << 2)
+#define ND_SMART_ALARM_VALID (1 << 3)
+#define ND_SMART_USED_VALID (1 << 4)
+#define ND_SMART_SHUTDOWN_VALID (1 << 5)
+#define ND_SMART_VENDOR_VALID (1 << 6)
+#define ND_SMART_TEMP_TRIP (1 << 0)
+#define ND_SMART_SPARE_TRIP (1 << 1)
+#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
+#define ND_SMART_CRITICAL_HEALTH (1 << 1)
+#define ND_SMART_FATAL_HEALTH (1 << 2)
+
+struct nd_smart_payload {
+ __u32 flags;
+ __u8 reserved0[4];
+ __u8 health;
+ __u16 temperature;
+ __u8 spares;
+ __u8 alarm_flags;
+ __u8 life_used;
+ __u8 shutdown_state;
+ __u8 reserved1;
+ __u32 vendor_size;
+ __u8 vendor_data[108];
+} __packed;
+
struct nd_cmd_smart_threshold {
__u32 status;
__u8 data[8];
} __packed;
+struct nd_smart_threshold_payload {
+ __u16 alarm_control;
+ __u16 temperature;
+ __u8 spares;
+ __u8 reserved[3];
+} __packed;
+
struct nd_cmd_dimm_flags {
__u32 status;
__u32 flags;
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 3187322eeed7..d1c98d4386d4 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -330,6 +330,42 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
+{
+ static const struct nd_smart_payload smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
+ | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
+ | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .temperature = 23 * 16,
+ .spares = 75,
+ .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ };
+
+ if (buf_len < sizeof(*smart))
+ return -EINVAL;
+ memcpy(smart->data, &smart_data, sizeof(smart_data));
+ return 0;
+}
+
+static int nfit_test_cmd_smart_threshold(struct nd_cmd_smart_threshold *smart_t,
+ unsigned int buf_len)
+{
+ static const struct nd_smart_threshold_payload smart_t_data = {
+ .alarm_control = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .temperature = 40 * 16,
+ .spares = 5,
+ };
+
+ if (buf_len < sizeof(*smart_t))
+ return -EINVAL;
+ memcpy(smart_t->data, &smart_t_data, sizeof(smart_t_data));
+ return 0;
+}
+
static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
unsigned int buf_len, int *cmd_rc)
@@ -368,6 +404,12 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
rc = nfit_test_cmd_set_config_data(buf, buf_len,
t->label[i]);
break;
+ case ND_CMD_SMART:
+ rc = nfit_test_cmd_smart(buf, buf_len);
+ break;
+ case ND_CMD_SMART_THRESHOLD:
+ rc = nfit_test_cmd_smart_threshold(buf, buf_len);
+ break;
default:
return -ENOTTY;
}
@@ -1254,10 +1296,12 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
+ set_bit(ND_CMD_SMART, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_dsm_force_en);
+ set_bit(ND_CMD_SMART_THRESHOLD, &acpi_desc->dimm_dsm_force_en);
}
static void nfit_test1_setup(struct nfit_test *t)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v2] libnvdimm, test: add mock SMART data payload
@ 2016-04-07 22:32 ` Dan Williams
0 siblings, 0 replies; 15+ messages in thread
From: Dan Williams @ 2016-04-07 22:32 UTC (permalink / raw)
To: linux-nvdimm; +Cc: linux-acpi, linux-kernel, jthumshirn
Provide simulated SMART data to enable the ndctl implementation of SMART
data retrieval and parsing.
The payload is defined here, "Section 4.1 SMART and Health Info
(Function Index 1)":
http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
Changes in v2:
* #define the ND_SMART_ flags definitions (jth)
* add a struct nd_smart_threshold_payload definition
* add a mock implementation of smart threshold data
drivers/nvdimm/bus.c | 3 +++
include/uapi/linux/ndctl.h | 36 ++++++++++++++++++++++++++++++-
tools/testing/nvdimm/test/nfit.c | 44 ++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 1 deletion(-)
diff --git a/drivers/nvdimm/bus.c b/drivers/nvdimm/bus.c
index 19f822d7f652..8111b1299515 100644
--- a/drivers/nvdimm/bus.c
+++ b/drivers/nvdimm/bus.c
@@ -783,6 +783,9 @@ int __init nvdimm_bus_init(void)
{
int rc;
+ BUILD_BUG_ON(sizeof(struct nd_smart_payload) != 128);
+ BUILD_BUG_ON(sizeof(struct nd_smart_threshold_payload) != 8);
+
rc = bus_register(&nvdimm_bus_type);
if (rc)
return rc;
diff --git a/include/uapi/linux/ndctl.h b/include/uapi/linux/ndctl.h
index 7cc28ab05b87..59c61e018a86 100644
--- a/include/uapi/linux/ndctl.h
+++ b/include/uapi/linux/ndctl.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015, Intel Corporation.
+ * Copyright (c) 2014-2016, Intel Corporation.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU Lesser General Public License,
@@ -20,11 +20,45 @@ struct nd_cmd_smart {
__u8 data[128];
} __packed;
+#define ND_SMART_HEALTH_VALID (1 << 0)
+#define ND_SMART_TEMP_VALID (1 << 1)
+#define ND_SMART_SPARES_VALID (1 << 2)
+#define ND_SMART_ALARM_VALID (1 << 3)
+#define ND_SMART_USED_VALID (1 << 4)
+#define ND_SMART_SHUTDOWN_VALID (1 << 5)
+#define ND_SMART_VENDOR_VALID (1 << 6)
+#define ND_SMART_TEMP_TRIP (1 << 0)
+#define ND_SMART_SPARE_TRIP (1 << 1)
+#define ND_SMART_NON_CRITICAL_HEALTH (1 << 0)
+#define ND_SMART_CRITICAL_HEALTH (1 << 1)
+#define ND_SMART_FATAL_HEALTH (1 << 2)
+
+struct nd_smart_payload {
+ __u32 flags;
+ __u8 reserved0[4];
+ __u8 health;
+ __u16 temperature;
+ __u8 spares;
+ __u8 alarm_flags;
+ __u8 life_used;
+ __u8 shutdown_state;
+ __u8 reserved1;
+ __u32 vendor_size;
+ __u8 vendor_data[108];
+} __packed;
+
struct nd_cmd_smart_threshold {
__u32 status;
__u8 data[8];
} __packed;
+struct nd_smart_threshold_payload {
+ __u16 alarm_control;
+ __u16 temperature;
+ __u8 spares;
+ __u8 reserved[3];
+} __packed;
+
struct nd_cmd_dimm_flags {
__u32 status;
__u32 flags;
diff --git a/tools/testing/nvdimm/test/nfit.c b/tools/testing/nvdimm/test/nfit.c
index 3187322eeed7..d1c98d4386d4 100644
--- a/tools/testing/nvdimm/test/nfit.c
+++ b/tools/testing/nvdimm/test/nfit.c
@@ -330,6 +330,42 @@ static int nfit_test_cmd_clear_error(struct nd_cmd_clear_error *clear_err,
return 0;
}
+static int nfit_test_cmd_smart(struct nd_cmd_smart *smart, unsigned int buf_len)
+{
+ static const struct nd_smart_payload smart_data = {
+ .flags = ND_SMART_HEALTH_VALID | ND_SMART_TEMP_VALID
+ | ND_SMART_SPARES_VALID | ND_SMART_ALARM_VALID
+ | ND_SMART_USED_VALID | ND_SMART_SHUTDOWN_VALID,
+ .health = ND_SMART_NON_CRITICAL_HEALTH,
+ .temperature = 23 * 16,
+ .spares = 75,
+ .alarm_flags = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .life_used = 5,
+ .shutdown_state = 0,
+ .vendor_size = 0,
+ };
+
+ if (buf_len < sizeof(*smart))
+ return -EINVAL;
+ memcpy(smart->data, &smart_data, sizeof(smart_data));
+ return 0;
+}
+
+static int nfit_test_cmd_smart_threshold(struct nd_cmd_smart_threshold *smart_t,
+ unsigned int buf_len)
+{
+ static const struct nd_smart_threshold_payload smart_t_data = {
+ .alarm_control = ND_SMART_SPARE_TRIP | ND_SMART_TEMP_TRIP,
+ .temperature = 40 * 16,
+ .spares = 5,
+ };
+
+ if (buf_len < sizeof(*smart_t))
+ return -EINVAL;
+ memcpy(smart_t->data, &smart_t_data, sizeof(smart_t_data));
+ return 0;
+}
+
static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
unsigned int buf_len, int *cmd_rc)
@@ -368,6 +404,12 @@ static int nfit_test_ctl(struct nvdimm_bus_descriptor *nd_desc,
rc = nfit_test_cmd_set_config_data(buf, buf_len,
t->label[i]);
break;
+ case ND_CMD_SMART:
+ rc = nfit_test_cmd_smart(buf, buf_len);
+ break;
+ case ND_CMD_SMART_THRESHOLD:
+ rc = nfit_test_cmd_smart_threshold(buf, buf_len);
+ break;
default:
return -ENOTTY;
}
@@ -1254,10 +1296,12 @@ static void nfit_test0_setup(struct nfit_test *t)
set_bit(ND_CMD_GET_CONFIG_SIZE, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_GET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_SET_CONFIG_DATA, &acpi_desc->dimm_dsm_force_en);
+ set_bit(ND_CMD_SMART, &acpi_desc->dimm_dsm_force_en);
set_bit(ND_CMD_ARS_CAP, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_START, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_ARS_STATUS, &acpi_desc->bus_dsm_force_en);
set_bit(ND_CMD_CLEAR_ERROR, &acpi_desc->bus_dsm_force_en);
+ set_bit(ND_CMD_SMART_THRESHOLD, &acpi_desc->dimm_dsm_force_en);
}
static void nfit_test1_setup(struct nfit_test *t)
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v2] libnvdimm, test: add mock SMART data payload
2016-04-07 22:32 ` Dan Williams
(?)
@ 2016-04-08 7:27 ` Johannes Thumshirn
-1 siblings, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2016-04-08 7:27 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-acpi, linux-kernel, linux-nvdimm
On Thursday, 7. April 2016 15:32:04 CEST Dan Williams wrote:
> Provide simulated SMART data to enable the ndctl implementation of SMART
> data retrieval and parsing.
>
> The payload is defined here, "Section 4.1 SMART and Health Info
> (Function Index 1)":
>
> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Changes in v2:
> * #define the ND_SMART_ flags definitions (jth)
> * add a struct nd_smart_threshold_payload definition
> * add a mock implementation of smart threshold data
Thanks,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2] libnvdimm, test: add mock SMART data payload
@ 2016-04-08 7:27 ` Johannes Thumshirn
0 siblings, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2016-04-08 7:27 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-nvdimm, linux-acpi, linux-kernel
On Thursday, 7. April 2016 15:32:04 CEST Dan Williams wrote:
> Provide simulated SMART data to enable the ndctl implementation of SMART
> data retrieval and parsing.
>
> The payload is defined here, "Section 4.1 SMART and Health Info
> (Function Index 1)":
>
> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Changes in v2:
> * #define the ND_SMART_ flags definitions (jth)
> * add a struct nd_smart_threshold_payload definition
> * add a mock implementation of smart threshold data
Thanks,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v2] libnvdimm, test: add mock SMART data payload
@ 2016-04-08 7:27 ` Johannes Thumshirn
0 siblings, 0 replies; 15+ messages in thread
From: Johannes Thumshirn @ 2016-04-08 7:27 UTC (permalink / raw)
To: Dan Williams; +Cc: linux-nvdimm, linux-acpi, linux-kernel
On Thursday, 7. April 2016 15:32:04 CEST Dan Williams wrote:
> Provide simulated SMART data to enable the ndctl implementation of SMART
> data retrieval and parsing.
>
> The payload is defined here, "Section 4.1 SMART and Health Info
> (Function Index 1)":
>
> http://pmem.io/documents/NVDIMM_DSM_Interface_Example.pdf
>
> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
> ---
> Changes in v2:
> * #define the ND_SMART_ flags definitions (jth)
> * add a struct nd_smart_threshold_payload definition
> * add a mock implementation of smart threshold data
Thanks,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
--
Johannes Thumshirn Storage
jthumshirn@suse.de +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2016-04-08 7:27 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-07 0:53 [PATCH] libnvdimm, test: add mock SMART data payload Dan Williams
2016-04-07 0:53 ` Dan Williams
2016-04-07 0:53 ` Dan Williams
2016-04-07 8:27 ` Johannes Thumshirn
2016-04-07 8:27 ` Johannes Thumshirn
2016-04-07 8:27 ` Johannes Thumshirn
2016-04-07 16:41 ` Dan Williams
2016-04-07 16:41 ` Dan Williams
2016-04-07 16:41 ` Dan Williams
2016-04-07 22:32 ` [PATCH v2] " Dan Williams
2016-04-07 22:32 ` Dan Williams
2016-04-07 22:32 ` Dan Williams
2016-04-08 7:27 ` Johannes Thumshirn
2016-04-08 7:27 ` Johannes Thumshirn
2016-04-08 7:27 ` Johannes Thumshirn
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.