Add support for Set Alert Configuration mailbox command
A message that is not in the archive (sent off-list or not yet received): CGME20230807063148epcas2p44093513a86545a3d1b0c3e0900f7ff4b@epcas2p4.samsung.com
v2 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. This patchset adds support for the command to configure warning alert.
Example:
# ./cxl set-alert-config mem0 -L 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 memThe implementation is based on the 'ndctl-inject-smart'. Variable and function names are aligned with the implementation of 'Get Alert Configuration'.
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]
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 | 96 +++++++++ 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, 380 insertions(+), 1 deletion(-) create mode 100644 Documentation/cxl/cxl-set-alert-config.txt
base-commit: a871e6153b11fe63780b37cdcb1eb347b296095c
Signature · 1 line
2.17.1
PATCH v2 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v2 2/2 cxl: add 'set-alert-config' command to cxl tool
In reply to Jehoon ParkAdd a new command: 'set-alert-config', which configures device's warning alert.
--- Documentation/cxl/cxl-set-alert-config.txt | 96 +++++++++ Documentation/cxl/meson.build | 1 + cxl/builtin.h | 1 + cxl/cxl.c | 1 + cxl/memdev.c | 220 ++++++++++++++++++++- 5 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 Documentation/cxl/cxl-set-alert-config.txt
Documentation/cxl/cxl-set-alert-config.txt new file +96 -0
@@ -0,0 +1,96 @@ +// 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. +[verse] +cxl set-alert-config mem0 -L 30 --life-used-alert=on + +Disable warning alert for device over temperature. +[verse] +cxl set-alert-config mem0 --over-temperature-alert=off + +OPTIONS +------- +<memory device(s)>:: +include::memdev-option.txt[] + +-v:: +--verbose=:: + Turn on verbose debug messages in the library (if libcxl was built with + logging and debug enabled). + +-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'. + +SEE ALSO +-------- +CXL-3.0 8.2.9.8.3.3
Documentation/cxl/meson.build +1 -0
@@ -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
@@ -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
@@ -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
Re: [ndctl PATCH v2 2/2] cxl: add 'set-alert-config' command to cxl tool
Quoted 1 line · Jehoon Park
Add a new command: 'set-alert-config', which configures device's warning alert.
The example in the cover-letter should be here and also mention explicitly that the get counterpart is via cxl-list -A, like you have in the manpage.
Quoted 34 lines
Signed-off-by Jehoon Park <[email protected]>---
Documentation/cxl/cxl-set-alert-config.txt | 96 +++++++++ Documentation/cxl/meson.build | 1 + cxl/builtin.h | 1 + cxl/cxl.c | 1 + cxl/memdev.c | 220 ++++++++++++++++++++- 5 files changed, 318 insertions(+), 1 deletion(-)create mode 100644
Documentation/cxl/cxl-set-alert-config.txtDocumentation/cxl/cxl-set-alert-config.txt new file +17
-0@@ -0,0 +1,96 @@ +// 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
Documentation/cxl/cxl-set-alert-config.txt line 27
Quoted 10 lines
Documentation/cxl/cxl-set-alert-config.txt new file +10
-0+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.
So what's the point of having to use double parameter to enable the warning? Just do alert=threshold if you've established that threshold=N and alert=off is not valid.
Quoted 13 lines
Documentation/cxl/cxl-set-alert-config.txt new file +13
-0+ +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. +[verse] +cxl set-alert-config mem0 -L 30 --life-used-alert=on + +Disable warning alert for device over temperature. +[verse] +cxl set-alert-config mem0 --over-temperature-alert=off
Documentation/cxl/cxl-set-alert-config.txt line 50
Quoted 10 lines
Documentation/cxl/cxl-set-alert-config.txt new file +10
-0+ +OPTIONS +------- +<memory device(s)>:: +include::memdev-option.txt[] + +-v:: +--verbose=:: + Turn on verbose debug messages in the library (if libcxl was built with + logging and debug enabled).
Should be at the end.
Thanks,
Davidlohr
Re: [ndctl PATCH v2 2/2] cxl: add 'set-alert-config' command to cxl tool
Quoted 7 lines · Davidlohr Bueso
Quoted 1 line · Jehoon Park
Add a new command: 'set-alert-config', which configures device's warning alert.
The example in the cover-letter should be here and also mention explicitly that the get counterpart is via cxl-list -A, like you have in the manpage.
Thank you for comments.
I will reorganize and update cover letter and commit message for clear explanation about the patchset.
Quoted 40 lines
Quoted 40 lines
Signed-off-by Jehoon Park <[email protected]>---
Documentation/cxl/cxl-set-alert-config.txt | 96 +++++++++ Documentation/cxl/meson.build | 1 + cxl/builtin.h | 1 + cxl/cxl.c | 1 + cxl/memdev.c | 220 ++++++++++++++++++++- 5 files changed, 318 insertions(+), 1 deletion(-)create mode 100644
Documentation/cxl/cxl-set-alert-config.txtDocumentation/cxl/cxl-set-alert-config.txt new file +23
-0@@ -0,0 +1,96 @@ +// 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
Quoted 9 lines
Documentation/cxl/cxl-set-alert-config.txt line 27
Quoted 4 lines
Documentation/cxl/cxl-set-alert-config.txt new file +4
-0+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.So what's the point of having to use double parameter to enable the warning? Just do alert=threshold if you've established that threshold=N and alert=off is not valid.
IMHO, using two separate parameters would be better because it would be safer by protecting a misuse out of an user. I think it is important to clearly interpret user's intention.
Also, CXL spec (8.2.9.8.3.3) defines two payload fields, threshold and enablement, separetely.
Please also remind that the 'ndctl-inject-smart' command already uses two parameters, threshold and alarm, to set smart threshold.
Quoted 17 lines
Quoted 17 lines
Documentation/cxl/cxl-set-alert-config.txt new file +17
-0+ +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. +[verse] +cxl set-alert-config mem0 -L 30 --life-used-alert=on + +Disable warning alert for device over temperature. +[verse] +cxl set-alert-config mem0 --over-temperature-alert=off + +OPTIONS +------- +<memory device(s)>::
Quoted 9 lines
Documentation/cxl/cxl-set-alert-config.txt line 50
Quoted 6 lines
Documentation/cxl/cxl-set-alert-config.txt new file +6
-0+include::memdev-option.txt[] + +-v:: +--verbose=:: + Turn on verbose debug messages in the library (if libcxl was built with + logging and debug enabled).Should be at the end.
Agree
Quoted 3 lines
Thanks,
Davidlohr
Sincerely,
Jehoon