Skip to contentSkip to conversation

cxl: add 'set-alert-config' command to cxl tool

PATCH In review Jehoon Park 2 participants 4 messages Sep 18, 2023 – Oct 10, 2023 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20230918045208epcas2p36f0c80940e86e5165a3036414a32d7f6@epcas2p3.samsung.com

#1 lore raw

v3 cover add support for Set Alert Configuration mailbox command

CXL 3.0 Spec 8.2.9.8.3.3 defines Set Alert Configuration mailbox command, which configures device's warning alerts.
This patchset adds support for the command.

The implementation is based on the 'ndctl-inject-smart'. Variable and function names are aligned with the implementation of 'Get Alert Configuration'.

Changes in v3
- Reorganize cover letter and commit message (Davidlohr)
- Update details of the example in man page
- Move 'verbose' option to the end in man page (Davidlohr)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2
- Rebase on the latest pending branch
- Remove full usage text in the commit message (Vishal)
- Correct texts in document and log_info() (Vishal)
- Change strncmp() to strcmp() for parsing params (Vishal)
- Link to v1: https://lore.kernel.org/r/[email protected]

*** BLURB HERE ***

Jehoon Park (2):
libcxl: add support for Set Alert Configuration mailbox command
cxl: add 'set-alert-config' command to cxl tool

 Documentation/cxl/cxl-set-alert-config.txt | 152 ++++++++++++++
 Documentation/cxl/lib/libcxl.txt           |   1 +
 Documentation/cxl/meson.build              |   1 +
 cxl/builtin.h                              |   1 +
 cxl/cxl.c                                  |   1 +
 cxl/lib/libcxl.c                           |  21 ++
 cxl/lib/libcxl.sym                         |  12 ++
 cxl/lib/private.h                          |  12 ++
 cxl/libcxl.h                               |  16 ++
 cxl/memdev.c                               | 220 ++++++++++++++++++++-
 10 files changed, 436 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/cxl/cxl-set-alert-config.txt

base-commit: 1db7dfb0bd1b14baffc7c6ac44ace9046d98a00d

Signature · 1 line
2.17.1
#2 lore raw

PATCH v3 1/2 libcxl: add support for Set Alert Configuration mailbox command

CXL 3.0 Spec 8.2.9.8.3.3 defines Set Alert Configuration mailbox command which allows a CXL host to configure programmable warning thresholds optionally.

Add methods to issue the command and set fields.

---
 Documentation/cxl/lib/libcxl.txt |  1 +
 cxl/lib/libcxl.c                 | 21 +++++++++++++++++++++
 cxl/lib/libcxl.sym               | 12 ++++++++++++
 cxl/lib/private.h                | 12 ++++++++++++
 cxl/libcxl.h                     | 16 ++++++++++++++++
 5 files changed, 62 insertions(+)
Documentation/cxl/lib/libcxl.txt +1 -0
index 31bc855..bcb8928 100644
@@ -122,6 +122,7 @@ struct cxl_cmd *cxl_cmd_new_raw(struct cxl_memdev *memdev, int opcode);
 struct cxl_cmd *cxl_cmd_new_identify(struct cxl_memdev *memdev);
 struct cxl_cmd *cxl_cmd_new_get_health_info(struct cxl_memdev *memdev);
 struct cxl_cmd *cxl_cmd_new_get_alert_config(struct cxl_memdev *memdev);
+struct cxl_cmd *cxl_cmd_new_set_alert_config(struct cxl_memdev *memdev);
 struct cxl_cmd *cxl_cmd_new_read_label(struct cxl_memdev *memdev,
 					unsigned int offset, unsigned int length);
 struct cxl_cmd *cxl_cmd_new_write_label(struct cxl_memdev *memdev, void *buf,
cxl/lib/libcxl.c +21 -0
index af4ca44..c781566 100644
@@ -4465,3 +4465,24 @@ CXL_EXPORT int cxl_memdev_read_label(struct cxl_memdev *memdev, void *buf,
 {
 	return lsa_op(memdev, LSA_OP_GET, buf, length, offset);
 }
+
+#define cxl_alert_config_set_field(field)                                     \
+CXL_EXPORT int cxl_cmd_alert_config_set_##field(struct cxl_cmd *cmd, int val) \
+{                                                                             \
+	struct cxl_cmd_set_alert_config *setalert = cmd->input_payload;       \
+	setalert->field = val;                                                \
+	return 0;                                                             \
+}
+
+cxl_alert_config_set_field(life_used_prog_warn_threshold)
+cxl_alert_config_set_field(dev_over_temperature_prog_warn_threshold)
+cxl_alert_config_set_field(dev_under_temperature_prog_warn_threshold)
+cxl_alert_config_set_field(corrected_volatile_mem_err_prog_warn_threshold)
+cxl_alert_config_set_field(corrected_pmem_err_prog_warn_threshold)
+cxl_alert_config_set_field(valid_alert_actions)
+cxl_alert_config_set_field(enable_alert_actions)
+
+CXL_EXPORT struct cxl_cmd *cxl_cmd_new_set_alert_config(struct cxl_memdev *memdev)
+{
+	return cxl_cmd_new_generic(memdev, CXL_MEM_COMMAND_ID_SET_ALERT_CONFIG);
+}
cxl/lib/libcxl.sym +12 -0
index 8fa1cca..6beca52 100644
@@ -264,3 +264,15 @@ global:
 	cxl_memdev_update_fw;
 	cxl_memdev_cancel_fw_update;
 } LIBCXL_5;
+
+LIBCXL_7 {
+global:
+	cxl_cmd_alert_config_set_life_used_prog_warn_threshold;
+	cxl_cmd_alert_config_set_dev_over_temperature_prog_warn_threshold;
+	cxl_cmd_alert_config_set_dev_under_temperature_prog_warn_threshold;
+	cxl_cmd_alert_config_set_corrected_volatile_mem_err_prog_warn_threshold;
+	cxl_cmd_alert_config_set_corrected_pmem_err_prog_warn_threshold;
+	cxl_cmd_alert_config_set_valid_alert_actions;
+	cxl_cmd_alert_config_set_enable_alert_actions;
+	cxl_cmd_new_set_alert_config;
+} LIBCXL_6;
cxl/lib/private.h +12 -0
index a641727..b26a862 100644
@@ -309,6 +309,18 @@ struct cxl_cmd_get_alert_config {
 #define CXL_CMD_ALERT_CONFIG_PROG_ALERTS_CORRECTED_PMEM_ERR_PROG_WARN_THRESHOLD_MASK \
 	BIT(4)
 
+/* CXL 3.0 8.2.9.8.3.3 Set Alert Configuration */
+struct cxl_cmd_set_alert_config {
+	u8 valid_alert_actions;
+	u8 enable_alert_actions;
+	u8 life_used_prog_warn_threshold;
+	u8 rsvd;
+	le16 dev_over_temperature_prog_warn_threshold;
+	le16 dev_under_temperature_prog_warn_threshold;
+	le16 corrected_volatile_mem_err_prog_warn_threshold;
+	le16 corrected_pmem_err_prog_warn_threshold;
+} __attribute__((packed));
+
 struct cxl_cmd_get_partition {
 	le64 active_volatile;
 	le64 active_persistent;
cxl/libcxl.h +16 -0
index 0f4f4b2..b0ec369 100644
@@ -461,6 +461,22 @@ enum cxl_setpartition_mode {
 int cxl_cmd_partition_set_mode(struct cxl_cmd *cmd,
 		enum cxl_setpartition_mode mode);
 
+int cxl_cmd_alert_config_set_life_used_prog_warn_threshold(struct cxl_cmd *cmd,
+							   int threshold);
+int cxl_cmd_alert_config_set_dev_over_temperature_prog_warn_threshold(
+	struct cxl_cmd *cmd, int threshold);
+int cxl_cmd_alert_config_set_dev_under_temperature_prog_warn_threshold(
+	struct cxl_cmd *cmd, int threshold);
+int cxl_cmd_alert_config_set_corrected_volatile_mem_err_prog_warn_threshold(
+	struct cxl_cmd *cmd, int threshold);
+int cxl_cmd_alert_config_set_corrected_pmem_err_prog_warn_threshold(
+	struct cxl_cmd *cmd, int threshold);
+int cxl_cmd_alert_config_set_valid_alert_actions(struct cxl_cmd *cmd,
+						 int action);
+int cxl_cmd_alert_config_set_enable_alert_actions(struct cxl_cmd *cmd,
+						  int enable);
+struct cxl_cmd *cxl_cmd_new_set_alert_config(struct cxl_memdev *memdev);
+
 #ifdef __cplusplus
 } /* extern "C" */
 #endif
Signature · 1 line
2.17.1
#3 lore raw

PATCH v3 2/2 cxl: add 'set-alert-config' command to cxl tool

In reply to Jehoon Park

Add a new command: 'cxl-set-alert-config', which configures device's warning alerts. Device's warning alert programmability and current state can be optained via 'cxl-list' command with '-A' option.

Example:
{
"memdev":"mem0",
"ram_size":"1024.00 MiB (1073.74 MB)",

  "alert_config":{
    "life_used_prog_warn_threshold_valid":true,
     ...
    "life_used_crit_alert_threshold":75,
    "life_used_prog_warn_threshold":30,
    ...

},
"serial":"0",
"host":"0000:0d:00.0"
}
cxl memdev: cmd_set_alert_config: set alert configuration 1 mem

---
 Documentation/cxl/cxl-set-alert-config.txt | 152 ++++++++++++++
 Documentation/cxl/meson.build              |   1 +
 cxl/builtin.h                              |   1 +
 cxl/cxl.c                                  |   1 +
 cxl/memdev.c                               | 220 ++++++++++++++++++++-
 5 files changed, 374 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/cxl/cxl-set-alert-config.txt
Documentation/cxl/cxl-set-alert-config.txt new file +152 -0
new file mode 100644
index 0000000..2ccb024
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-2.0
+
+cxl-set-alert-config(1)
+=======================
+
+NAME
+----
+cxl-set-alert-config - set the warning alert threshold on a CXL memdev
+
+SYNOPSIS
+--------
+[verse]
+'cxl set-alert-config <mem0> [<mem1>..<memN>] [<options>]'
+
+DESCRIPTION
+-----------
+CXL device raises an alert when its health status is changed. Critical alert
+shall automatically be configured by the device after a device reset.
+If supported, programmable warning thresholds also be initialized to vendor
+recommended defaults, then could be configured by the user.
+
+Use this command to configure warning alert thresholds of a device.
+Having issued this command, the newly requested warning thresholds would
+override the previously programmed warning thresholds.
+
+To enable warning alert, set both 'threshold=value' and 'alert=on'. To disable
+warning alert, set only 'alert=off'. Other cases would cause errors.
+
+Use "cxl list -m <memdev> -A" to examine the programming warning threshold
+capabilities of a device.
+
+EXAMPLES
+--------
+Set warning threshold to 30 and enable alert for life used.
+----
+# cxl set-alert-config mem0 --life-used-threshold=30 --life-used-alert=on
+{
+  "memdev":"mem0",
+  "ram_size":"1024.00 MiB (1073.74 MB)",
+  "alert_config":{
+    "life_used_prog_warn_threshold_valid":true,
+    "dev_over_temperature_prog_warn_threshold_valid":false,
+    "dev_under_temperature_prog_warn_threshold_valid":false,
+    "corrected_volatile_mem_err_prog_warn_threshold_valid":false,
+    "corrected_pmem_err_prog_warn_threshold_valid":false,
+    "life_used_prog_warn_threshold_writable":true,
+    "dev_over_temperature_prog_warn_threshold_writable":true,
+    "dev_under_temperature_prog_warn_threshold_writable":true,
+    "corrected_volatile_mem_err_prog_warn_threshold_writable":true,
+    "corrected_pmem_err_prog_warn_threshold_writable":true,
+    "life_used_crit_alert_threshold":75,
+    "life_used_prog_warn_threshold":30,
+    "dev_over_temperature_crit_alert_threshold":0,
+    "dev_under_temperature_crit_alert_threshold":0,
+    "dev_over_temperature_prog_warn_threshold":0,
+    "dev_under_temperature_prog_warn_threshold":0,
+    "corrected_volatile_mem_err_prog_warn_threshold":0,
+    "corrected_pmem_err_prog_warn_threshold":0
+  },
+  "serial":"0",
+  "host":"0000:0d:00.0"
+}
+cxl memdev: cmd_set_alert_config: set alert configuration 1 mem
+----
+
+Disable warning alert for life_used.
+----
+# cxl set-alert-config mem0 --life-used-alert=off
+{
+  "memdev":"mem0",
+  "ram_size":"1024.00 MiB (1073.74 MB)",
+  "alert_config":{
+    "life_used_prog_warn_threshold_valid":false,
+    "dev_over_temperature_prog_warn_threshold_valid":false,
+    "dev_under_temperature_prog_warn_threshold_valid":false,
+    "corrected_volatile_mem_err_prog_warn_threshold_valid":false,
+    "corrected_pmem_err_prog_warn_threshold_valid":false,
+    "life_used_prog_warn_threshold_writable":true,
+    "dev_over_temperature_prog_warn_threshold_writable":true,
+    "dev_under_temperature_prog_warn_threshold_writable":true,
+    "corrected_volatile_mem_err_prog_warn_threshold_writable":true,
+    "corrected_pmem_err_prog_warn_threshold_writable":true,
+    "life_used_crit_alert_threshold":75,
+    "life_used_prog_warn_threshold":30,
+    "dev_over_temperature_crit_alert_threshold":0,
+    "dev_under_temperature_crit_alert_threshold":0,
+    "dev_over_temperature_prog_warn_threshold":0,
+    "dev_under_temperature_prog_warn_threshold":0,
+    "corrected_volatile_mem_err_prog_warn_threshold":0,
+    "corrected_pmem_err_prog_warn_threshold":0
+  },
+  "serial":"0",
+  "host":"0000:0d:00.0"
+}
+cxl memdev: cmd_set_alert_config: set alert configuration 1 mem
+----
+
+OPTIONS
+-------
+<memory device(s)>::
+include::memdev-option.txt[]
+
+-L::
+--life-used-threshold=::
+	Set <value> for the life used warning alert threshold.
+
+--life-used-alert=::
+	Enable or disable the life used warning alert.
+	Options are 'on' or 'off'.
+
+-O::
+--over-temperature-threshold=::
+	Set <value> for the device over temperature warning alert threshold.
+
+--over-temperature-alert=::
+	Enable or disable the device over temperature warning alert.
+	Options are 'on' or 'off'.
+
+-U::
+--under-temperature-threshold=::
+	Set <value> for the device under temperature warning alert threshold.
+
+--under-temperature-alert=::
+	Enable or disable the device under temperature warning alert.
+	Options are 'on' or 'off'.
+
+-V::
+--volatile-mem-err-threshold=::
+	Set <value> for the corrected volatile memory error warning alert
+	threshold.
+
+--volatile-mem-err-alert=::
+	Enable or disable the corrected volatile memory error warning alert.
+	Options are 'on' or 'off'.
+
+-P::
+--pmem-err-threshold=::
+	Set <value> for the corrected persistent memory error warning alert
+	threshold.
+
+--pmem-err-alert=::
+	Enable or disable the corrected persistent memory error warning alert.
+	Options are 'on' or 'off'.
+
+-v::
+--verbose::
+        Turn on verbose debug messages in the library (if libcxl was built with
+        logging and debug enabled).
+
+SEE ALSO
+--------
+CXL-3.0 8.2.9.8.3.3
Documentation/cxl/meson.build +1 -0
index c553357..865aad5 100644
@@ -47,6 +47,7 @@ cxl_manpages = [
   'cxl-destroy-region.txt',
   'cxl-monitor.txt',
   'cxl-update-firmware.txt',
+  'cxl-set-alert-config.txt',
 ]
 
 foreach man : cxl_manpages
cxl/builtin.h +1 -0
index 3ec6c6c..2c46a82 100644
@@ -15,6 +15,7 @@ int cmd_enable_memdev(int argc, const char **argv, struct cxl_ctx *ctx);
 int cmd_reserve_dpa(int argc, const char **argv, struct cxl_ctx *ctx);
 int cmd_free_dpa(int argc, const char **argv, struct cxl_ctx *ctx);
 int cmd_update_fw(int argc, const char **argv, struct cxl_ctx *ctx);
+int cmd_set_alert_config(int argc, const char **argv, struct cxl_ctx *ctx);
 int cmd_disable_port(int argc, const char **argv, struct cxl_ctx *ctx);
 int cmd_enable_port(int argc, const char **argv, struct cxl_ctx *ctx);
 int cmd_set_partition(int argc, const char **argv, struct cxl_ctx *ctx);
cxl/cxl.c +1 -0
index e1524b8..bf4822f 100644
@@ -69,6 +69,7 @@ static struct cmd_struct commands[] = {
 	{ "reserve-dpa", .c_fn = cmd_reserve_dpa },
 	{ "free-dpa", .c_fn = cmd_free_dpa },
 	{ "update-firmware", .c_fn = cmd_update_fw },
+	{ "set-alert-config", .c_fn = cmd_set_alert_config },
 	{ "disable-port", .c_fn = cmd_disable_port },
 	{ "enable-port", .c_fn = cmd_enable_port },
 	{ "set-partition", .c_fn = cmd_set_partition },
cxl/memdev.c +219 -1

257 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on the v3 series
#4 lore raw

Re: [ndctl PATCH v3 0/2] add support for Set Alert Configuration mailbox command

In reply to Jehoon Park
Quoted 20 lines · Jehoon Park

CXL 3.0 Spec 8.2.9.8.3.3 defines Set Alert Configuration mailbox command, which configures device's warning alerts.
This patchset adds support for the command.

The implementation is based on the 'ndctl-inject-smart'. Variable and function names are aligned with the implementation of 'Get Alert Configuration'.

Changes in v3
- Reorganize cover letter and commit message (Davidlohr)
- Update details of the example in man page
- Move 'verbose' option to the end in man page (Davidlohr)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2
- Rebase on the latest pending branch
- Remove full usage text in the commit message (Vishal)
- Correct texts in document and log_info() (Vishal)
- Change strncmp() to strcmp() for parsing params (Vishal)
- Link to v1: https://lore.kernel.org/r/[email protected]

Quoted 5 lines

*** BLURB HERE ***

Jehoon Park (2):
libcxl: add support for Set Alert Configuration mailbox command
cxl: add 'set-alert-config' command to cxl tool

Looks good, for the series feel free to add: