* [PATCH v2] tools/testing/cxl: add mock output for the GET_HEALTH_INFO command
@ 2021-10-11 22:28 Vishal Verma
2021-10-15 16:09 ` Jonathan Cameron
0 siblings, 1 reply; 2+ messages in thread
From: Vishal Verma @ 2021-10-11 22:28 UTC (permalink / raw)
To: linux-cxl; +Cc: Dan Williams, Vishal Verma
Add mocked health information for cxl_test memdevs. This allows
cxl-cli's 'list' command to display the canned health_info fields.
Cc: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
---
tools/testing/cxl/test/mem.c | 48 ++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
v2:
- Move the health_info struct definition into tools/testing since the
mock driver is currently the only user (Dan)
- Add comments for the various status fields describing the flags being
set (Dan)
- Add a size check before copying the cmd buffer (Dan)
diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
index 12a8437a9ca0..60264a18d3ca 100644
--- a/tools/testing/cxl/test/mem.c
+++ b/tools/testing/cxl/test/mem.c
@@ -28,8 +28,24 @@ static struct cxl_cel_entry mock_cel[] = {
.opcode = cpu_to_le16(CXL_MBOX_OP_SET_LSA),
.effect = cpu_to_le16(EFFECT(1) | EFFECT(2)),
},
+ {
+ .opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO),
+ .effect = cpu_to_le16(0),
+ },
};
+/* See CXL 2.0 Table 181 Get Health Info Output Payload */
+struct cxl_mbox_health_info {
+ u8 health_status;
+ u8 media_status;
+ u8 ext_status;
+ u8 life_used;
+ __le16 temperature;
+ __le32 dirty_shutdowns;
+ __le32 volatile_errors;
+ __le32 pmem_errors;
+} __packed;
+
static struct {
struct cxl_mbox_get_supported_logs gsl;
struct cxl_gsl_entry entry;
@@ -156,6 +172,35 @@ static int mock_set_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
return 0;
}
+static int mock_health_info(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
+{
+ struct cxl_mbox_health_info health_info = {
+ /* set flags for maint needed, perf degraded, hw replacement */
+ .health_status = 0x7,
+ /* set media status to "All Data Lost" */
+ .media_status = 0x3,
+ /*
+ * set ext_status flags for:
+ * ext_life_used: normal,
+ * ext_temperature: critical,
+ * ext_corrected_volatile: warning,
+ * ext_corrected_persistent: normal,
+ */
+ .ext_status = 0x18,
+ .life_used = 15,
+ .temperature = cpu_to_le16(25),
+ .dirty_shutdowns = cpu_to_le16(10),
+ .volatile_errors = cpu_to_le16(20),
+ .pmem_errors = cpu_to_le16(30),
+ };
+
+ if (cmd->size_out < sizeof(health_info))
+ return -EINVAL;
+
+ memcpy(cmd->payload_out, &health_info, sizeof(health_info));
+ return 0;
+}
+
static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
{
struct device *dev = cxlm->dev;
@@ -177,6 +222,9 @@ static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
case CXL_MBOX_OP_SET_LSA:
rc = mock_set_lsa(cxlm, cmd);
break;
+ case CXL_MBOX_OP_GET_HEALTH_INFO:
+ rc = mock_health_info(cxlm, cmd);
+ break;
default:
break;
}
base-commit: ed97afb53365cd03dde266c9644334a558fe5a16
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] tools/testing/cxl: add mock output for the GET_HEALTH_INFO command
2021-10-11 22:28 [PATCH v2] tools/testing/cxl: add mock output for the GET_HEALTH_INFO command Vishal Verma
@ 2021-10-15 16:09 ` Jonathan Cameron
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2021-10-15 16:09 UTC (permalink / raw)
To: Vishal Verma; +Cc: linux-cxl, Dan Williams
On Mon, 11 Oct 2021 16:28:26 -0600
Vishal Verma <vishal.l.verma@intel.com> wrote:
> Add mocked health information for cxl_test memdevs. This allows
> cxl-cli's 'list' command to display the canned health_info fields.
>
> Cc: Dan Williams <dan.j.williams@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
Hi Vishal,
Small issue with cpu_to_le16() for 32 bit le fields.
With that fixed.
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> tools/testing/cxl/test/mem.c | 48 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 48 insertions(+)
>
> v2:
> - Move the health_info struct definition into tools/testing since the
> mock driver is currently the only user (Dan)
> - Add comments for the various status fields describing the flags being
> set (Dan)
> - Add a size check before copying the cmd buffer (Dan)
>
> diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c
> index 12a8437a9ca0..60264a18d3ca 100644
> --- a/tools/testing/cxl/test/mem.c
> +++ b/tools/testing/cxl/test/mem.c
> @@ -28,8 +28,24 @@ static struct cxl_cel_entry mock_cel[] = {
> .opcode = cpu_to_le16(CXL_MBOX_OP_SET_LSA),
> .effect = cpu_to_le16(EFFECT(1) | EFFECT(2)),
> },
> + {
> + .opcode = cpu_to_le16(CXL_MBOX_OP_GET_HEALTH_INFO),
> + .effect = cpu_to_le16(0),
> + },
> };
>
> +/* See CXL 2.0 Table 181 Get Health Info Output Payload */
> +struct cxl_mbox_health_info {
> + u8 health_status;
> + u8 media_status;
> + u8 ext_status;
> + u8 life_used;
> + __le16 temperature;
> + __le32 dirty_shutdowns;
> + __le32 volatile_errors;
> + __le32 pmem_errors;
> +} __packed;
> +
> static struct {
> struct cxl_mbox_get_supported_logs gsl;
> struct cxl_gsl_entry entry;
> @@ -156,6 +172,35 @@ static int mock_set_lsa(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
> return 0;
> }
>
> +static int mock_health_info(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
> +{
> + struct cxl_mbox_health_info health_info = {
> + /* set flags for maint needed, perf degraded, hw replacement */
> + .health_status = 0x7,
> + /* set media status to "All Data Lost" */
> + .media_status = 0x3,
> + /*
> + * set ext_status flags for:
> + * ext_life_used: normal,
> + * ext_temperature: critical,
> + * ext_corrected_volatile: warning,
> + * ext_corrected_persistent: normal,
> + */
> + .ext_status = 0x18,
> + .life_used = 15,
> + .temperature = cpu_to_le16(25),
> + .dirty_shutdowns = cpu_to_le16(10),
32 bit field as are the next two so I would assume
cpu_to_le32() is the more appropriate call.
> + .volatile_errors = cpu_to_le16(20),
> + .pmem_errors = cpu_to_le16(30),
> + };
> +
> + if (cmd->size_out < sizeof(health_info))
> + return -EINVAL;
> +
> + memcpy(cmd->payload_out, &health_info, sizeof(health_info));
> + return 0;
> +}
> +
> static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
> {
> struct device *dev = cxlm->dev;
> @@ -177,6 +222,9 @@ static int cxl_mock_mbox_send(struct cxl_mem *cxlm, struct cxl_mbox_cmd *cmd)
> case CXL_MBOX_OP_SET_LSA:
> rc = mock_set_lsa(cxlm, cmd);
> break;
> + case CXL_MBOX_OP_GET_HEALTH_INFO:
> + rc = mock_health_info(cxlm, cmd);
> + break;
> default:
> break;
> }
>
> base-commit: ed97afb53365cd03dde266c9644334a558fe5a16
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-15 16:09 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 22:28 [PATCH v2] tools/testing/cxl: add mock output for the GET_HEALTH_INFO command Vishal Verma
2021-10-15 16:09 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).