Message ID | 20221003232306.1326511-3-jonzhang@fb.com |
---|---|
State | New, archived |
Headers | show |
Series | add support for CCI command Get Alert Configuration | expand |
On Mon, 2022-10-03 at 16:23 -0700, Jonathan Zhang wrote: > From: Jonathan Zhang <jonzhang@meta.com> > > When list commands are issued, display alert config: > > Signed-off-by: Jonathan Zhang <jonzhang@meta.com> > --- > Documentation/cxl/cxl-list.txt | 33 +++++++++ > cxl/filter.c | 2 + > cxl/filter.h | 1 + > cxl/json.c | 131 +++++++++++++++++++++++++++++++++ > cxl/list.c | 3 + > util/json.h | 1 + > 6 files changed, 171 insertions(+) > > diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt > index 14a2b4b..66dfa15 100644 > --- a/Documentation/cxl/cxl-list.txt > +++ b/Documentation/cxl/cxl-list.txt > @@ -219,6 +219,39 @@ OPTIONS > } > ] > ---- > +-A:: > +--alert:: > + Include alert configuration in the memdev listing. Example listing: > +---- > +# cxl list -m mem0 -A > +[ > + { > + "memdev":"mem0", > + "pmem_size":0, > + "ram_size":273535729664, > + "alert":{ > + "life_used_prog_warn_threshold_valid":false, > + "dev_over_temp_prog_warn_threshold_valid":false, > + "dev_under_temp_prog_warn_threshold_valid":false, > + "corr_vol_mem_err_prog_warn_threshold_valid":true, > + "corr_pers_mem_err_prog_warn_threshold_valid":false, > + "life_used_prog_warn_threshold_programmable":false, I feel the 'prog' and 'programmabnle' conflict a bit. How about: "life_used_prog_warn_threshold_writable":false, > + "dev_over_temp_prog_warn_threshold_programmable":false, > + "dev_under_temp_prog_warn_threshold_programmable":false, > + "corr_vol_mem_err_prog_warn_threshold_programmable":true, > + "corr_pers_mem_err_prog_warn_threshold_programmable":false, The health info output uses long form 'corrected', and 'volatile'. Even though the final string becomes a bit longer, I think it would be better to maintain consistency with health_info on these. Same for 'temp' actually - use 'temperature', especially so it isn't confused with 'temporary'. And for persistent, we've used 'pmem' everywhere else, so this should become something like: "corrected_pmem_err_prog_warn_threshold_writable":false, > + "life_used_crit_alert_threshold":0, > + "life_used_prog_warn_threshold":0, > + "dev_over_temp_crit_alert_threshold":0, > + "dev_under_temp_crit_alert_threshold":0, > + "dev_over_temp_prog_warn_threshold":0, > + "dev_under_temp_prog_warn_threshold":0, > + "corr_vol_mem_err_prog_warn_threshold":0, > + "corr_pers_mem_err_prog_warn_threshold":0 > + }, > + } > +] > +---- > > -B:: > --buses:: > diff --git a/cxl/filter.c b/cxl/filter.c > index 56c6599..6d71c1c 100644 > --- a/cxl/filter.c > +++ b/cxl/filter.c > @@ -686,6 +686,8 @@ static unsigned long params_to_flags(struct > cxl_filter_params *param) > flags |= UTIL_JSON_TARGETS; > if (param->partition) > flags |= UTIL_JSON_PARTITION; > + if (param->alert) > + flags |= UTIL_JSON_ALERT; Maybe call this flag UTIL_JSON_ALERT_CONFIG. Just ALERT might be a bit too generic, since JSON flags are shared among ndctl and daxctl as well. > return flags; > } > > diff --git a/cxl/filter.h b/cxl/filter.h > index 256df49..ec0f74c 100644 > --- a/cxl/filter.h > +++ b/cxl/filter.h > @@ -26,6 +26,7 @@ struct cxl_filter_params { > bool human; > bool health; > bool partition; > + bool alert; > int verbose; > struct log_ctx ctx; > }; > diff --git a/cxl/json.c b/cxl/json.c > index 63c1751..dd83ed6 100644 > --- a/cxl/json.c > +++ b/cxl/json.c > @@ -185,6 +185,131 @@ err_jobj: > return NULL; > } > > +static struct json_object *util_cxl_memdev_alert_to_json( > + struct cxl_memdev *memdev, unsigned long flags) > +{ > + struct json_object *jalert; > + struct json_object *jobj; > + struct cxl_cmd *cmd; > + int rc; > + > + jalert = json_object_new_object(); > + if (!jalert) > + return NULL; > + if (!memdev) > + goto err_jobj; > + > + cmd = cxl_cmd_new_get_alert_config(memdev); > + if (!cmd) > + goto err_jobj; > + > + rc = cxl_cmd_submit(cmd); > + if (rc < 0) > + goto err_cmd; > + rc = cxl_cmd_get_mbox_status(cmd); > + if (rc != 0) > + goto err_cmd; > + > + rc = cxl_cmd_alert_config_get_life_used_prog_warn_threshold_valid(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "life_used_prog_warn_threshold_valid", jobj); Same comment as patch 1 about long lines. > + > + rc = cxl_cmd_alert_config_get_dev_over_temp_prog_warn_threshold_valid(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_over_temp_prog_warn_threshold_valid", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_under_temp_prog_warn_threshold_valid(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_under_temp_prog_warn_threshold_valid", jobj); > + > + rc = cxl_cmd_alert_config_get_corr_vol_mem_err_prog_warn_threshold_valid(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "corr_vol_mem_err_prog_warn_threshold_valid", jobj); > + > + rc = cxl_cmd_alert_config_get_corr_pers_mem_err_prog_warn_threshold_valid(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "corr_pers_mem_err_prog_warn_threshold_valid", jobj); > + > + rc = cxl_cmd_alert_config_get_life_used_prog_warn_threshold_prog(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "life_used_prog_warn_threshold_programmable", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_over_temp_prog_warn_threshold_prog(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_over_temp_prog_warn_threshold_programmable", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_under_temp_prog_warn_threshold_prog(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_under_temp_prog_warn_threshold_programmable", jobj); > + > + rc = cxl_cmd_alert_config_get_corr_vol_mem_err_prog_warn_threshold_prog(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "corr_vol_mem_err_prog_warn_threshold_programmable", jobj); > + > + rc = cxl_cmd_alert_config_get_corr_pers_mem_err_prog_warn_threshold_prog(cmd); > + jobj = json_object_new_boolean(rc); > + if (jobj) > + json_object_object_add(jalert, "corr_pers_mem_err_prog_warn_threshold_programmable", jobj); > + > + rc = cxl_cmd_alert_config_get_life_used_crit_alert_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "life_used_crit_alert_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_life_used_prog_warn_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "life_used_prog_warn_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_over_temp_crit_alert_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_over_temp_crit_alert_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_under_temp_crit_alert_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_under_temp_crit_alert_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_over_temp_prog_warn_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_over_temp_prog_warn_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_dev_under_temp_prog_warn_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "dev_under_temp_prog_warn_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_corr_vol_mem_err_prog_warn_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "corr_vol_mem_err_prog_warn_threshold", jobj); > + > + rc = cxl_cmd_alert_config_get_corr_pers_mem_err_prog_warn_threshold(cmd); > + jobj = json_object_new_int(rc); > + if (jobj) > + json_object_object_add(jalert, "corr_pers_mem_err_prog_warn_threshold", jobj); > + > + cxl_cmd_unref(cmd); > + return jalert; > + > +err_cmd: > + cxl_cmd_unref(cmd); > +err_jobj: > + json_object_put(jalert); > + return NULL; > +} > + > /* > * Present complete view of memdev partition by presenting fields from > * both GET_PARTITION_INFO and IDENTIFY mailbox commands. > @@ -330,6 +455,12 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev, > json_object_object_add(jdev, "health", jobj); > } > > + if (flags & UTIL_JSON_ALERT) { > + jobj = util_cxl_memdev_alert_to_json(memdev, flags); > + if (jobj) > + json_object_object_add(jdev, "alert", jobj); > + } > + > serial = cxl_memdev_get_serial(memdev); > if (serial < ULLONG_MAX) { > jobj = util_json_object_hex(serial, flags); > diff --git a/cxl/list.c b/cxl/list.c > index 8c48fbb..6ec4403 100644 > --- a/cxl/list.c > +++ b/cxl/list.c > @@ -52,6 +52,8 @@ static const struct option options[] = { > "include memory device health information"), > OPT_BOOLEAN('I', "partition", ¶m.partition, > "include memory device partition information"), > + OPT_BOOLEAN('A', "alert", ¶m.alert, > + "include alert configuration information"), This should be --alert-config - in case there is a future need to list, e.g. alerts that have triggered. And regardless of the future need, we're listing the alert config, not alerts themselves. Likewise rename param.alert to param.alert_config too. > OPT_INCR('v', "verbose", ¶m.verbose, > "increase output detail"), > #ifdef ENABLE_DEBUG > @@ -113,6 +115,7 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) > case 3: > param.health = true; > param.partition = true; > + param.alert = true; > /* fallthrough */ > case 2: > param.idle = true; > diff --git a/util/json.h b/util/json.h > index 73bb9f0..06594b5 100644 > --- a/util/json.h > +++ b/util/json.h > @@ -20,6 +20,7 @@ enum util_json_flags { > UTIL_JSON_HEALTH = (1 << 10), > UTIL_JSON_TARGETS = (1 << 11), > UTIL_JSON_PARTITION = (1 << 12), > + UTIL_JSON_ALERT = (1 << 13), > }; > > void util_display_json_array(FILE *f_out, struct json_object *jarray,
diff --git a/Documentation/cxl/cxl-list.txt b/Documentation/cxl/cxl-list.txt index 14a2b4b..66dfa15 100644 --- a/Documentation/cxl/cxl-list.txt +++ b/Documentation/cxl/cxl-list.txt @@ -219,6 +219,39 @@ OPTIONS } ] ---- +-A:: +--alert:: + Include alert configuration in the memdev listing. Example listing: +---- +# cxl list -m mem0 -A +[ + { + "memdev":"mem0", + "pmem_size":0, + "ram_size":273535729664, + "alert":{ + "life_used_prog_warn_threshold_valid":false, + "dev_over_temp_prog_warn_threshold_valid":false, + "dev_under_temp_prog_warn_threshold_valid":false, + "corr_vol_mem_err_prog_warn_threshold_valid":true, + "corr_pers_mem_err_prog_warn_threshold_valid":false, + "life_used_prog_warn_threshold_programmable":false, + "dev_over_temp_prog_warn_threshold_programmable":false, + "dev_under_temp_prog_warn_threshold_programmable":false, + "corr_vol_mem_err_prog_warn_threshold_programmable":true, + "corr_pers_mem_err_prog_warn_threshold_programmable":false, + "life_used_crit_alert_threshold":0, + "life_used_prog_warn_threshold":0, + "dev_over_temp_crit_alert_threshold":0, + "dev_under_temp_crit_alert_threshold":0, + "dev_over_temp_prog_warn_threshold":0, + "dev_under_temp_prog_warn_threshold":0, + "corr_vol_mem_err_prog_warn_threshold":0, + "corr_pers_mem_err_prog_warn_threshold":0 + }, + } +] +---- -B:: --buses:: diff --git a/cxl/filter.c b/cxl/filter.c index 56c6599..6d71c1c 100644 --- a/cxl/filter.c +++ b/cxl/filter.c @@ -686,6 +686,8 @@ static unsigned long params_to_flags(struct cxl_filter_params *param) flags |= UTIL_JSON_TARGETS; if (param->partition) flags |= UTIL_JSON_PARTITION; + if (param->alert) + flags |= UTIL_JSON_ALERT; return flags; } diff --git a/cxl/filter.h b/cxl/filter.h index 256df49..ec0f74c 100644 --- a/cxl/filter.h +++ b/cxl/filter.h @@ -26,6 +26,7 @@ struct cxl_filter_params { bool human; bool health; bool partition; + bool alert; int verbose; struct log_ctx ctx; }; diff --git a/cxl/json.c b/cxl/json.c index 63c1751..dd83ed6 100644 --- a/cxl/json.c +++ b/cxl/json.c @@ -185,6 +185,131 @@ err_jobj: return NULL; } +static struct json_object *util_cxl_memdev_alert_to_json( + struct cxl_memdev *memdev, unsigned long flags) +{ + struct json_object *jalert; + struct json_object *jobj; + struct cxl_cmd *cmd; + int rc; + + jalert = json_object_new_object(); + if (!jalert) + return NULL; + if (!memdev) + goto err_jobj; + + cmd = cxl_cmd_new_get_alert_config(memdev); + if (!cmd) + goto err_jobj; + + rc = cxl_cmd_submit(cmd); + if (rc < 0) + goto err_cmd; + rc = cxl_cmd_get_mbox_status(cmd); + if (rc != 0) + goto err_cmd; + + rc = cxl_cmd_alert_config_get_life_used_prog_warn_threshold_valid(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "life_used_prog_warn_threshold_valid", jobj); + + rc = cxl_cmd_alert_config_get_dev_over_temp_prog_warn_threshold_valid(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "dev_over_temp_prog_warn_threshold_valid", jobj); + + rc = cxl_cmd_alert_config_get_dev_under_temp_prog_warn_threshold_valid(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "dev_under_temp_prog_warn_threshold_valid", jobj); + + rc = cxl_cmd_alert_config_get_corr_vol_mem_err_prog_warn_threshold_valid(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "corr_vol_mem_err_prog_warn_threshold_valid", jobj); + + rc = cxl_cmd_alert_config_get_corr_pers_mem_err_prog_warn_threshold_valid(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "corr_pers_mem_err_prog_warn_threshold_valid", jobj); + + rc = cxl_cmd_alert_config_get_life_used_prog_warn_threshold_prog(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "life_used_prog_warn_threshold_programmable", jobj); + + rc = cxl_cmd_alert_config_get_dev_over_temp_prog_warn_threshold_prog(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "dev_over_temp_prog_warn_threshold_programmable", jobj); + + rc = cxl_cmd_alert_config_get_dev_under_temp_prog_warn_threshold_prog(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "dev_under_temp_prog_warn_threshold_programmable", jobj); + + rc = cxl_cmd_alert_config_get_corr_vol_mem_err_prog_warn_threshold_prog(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "corr_vol_mem_err_prog_warn_threshold_programmable", jobj); + + rc = cxl_cmd_alert_config_get_corr_pers_mem_err_prog_warn_threshold_prog(cmd); + jobj = json_object_new_boolean(rc); + if (jobj) + json_object_object_add(jalert, "corr_pers_mem_err_prog_warn_threshold_programmable", jobj); + + rc = cxl_cmd_alert_config_get_life_used_crit_alert_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "life_used_crit_alert_threshold", jobj); + + rc = cxl_cmd_alert_config_get_life_used_prog_warn_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "life_used_prog_warn_threshold", jobj); + + rc = cxl_cmd_alert_config_get_dev_over_temp_crit_alert_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "dev_over_temp_crit_alert_threshold", jobj); + + rc = cxl_cmd_alert_config_get_dev_under_temp_crit_alert_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "dev_under_temp_crit_alert_threshold", jobj); + + rc = cxl_cmd_alert_config_get_dev_over_temp_prog_warn_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "dev_over_temp_prog_warn_threshold", jobj); + + rc = cxl_cmd_alert_config_get_dev_under_temp_prog_warn_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "dev_under_temp_prog_warn_threshold", jobj); + + rc = cxl_cmd_alert_config_get_corr_vol_mem_err_prog_warn_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "corr_vol_mem_err_prog_warn_threshold", jobj); + + rc = cxl_cmd_alert_config_get_corr_pers_mem_err_prog_warn_threshold(cmd); + jobj = json_object_new_int(rc); + if (jobj) + json_object_object_add(jalert, "corr_pers_mem_err_prog_warn_threshold", jobj); + + cxl_cmd_unref(cmd); + return jalert; + +err_cmd: + cxl_cmd_unref(cmd); +err_jobj: + json_object_put(jalert); + return NULL; +} + /* * Present complete view of memdev partition by presenting fields from * both GET_PARTITION_INFO and IDENTIFY mailbox commands. @@ -330,6 +455,12 @@ struct json_object *util_cxl_memdev_to_json(struct cxl_memdev *memdev, json_object_object_add(jdev, "health", jobj); } + if (flags & UTIL_JSON_ALERT) { + jobj = util_cxl_memdev_alert_to_json(memdev, flags); + if (jobj) + json_object_object_add(jdev, "alert", jobj); + } + serial = cxl_memdev_get_serial(memdev); if (serial < ULLONG_MAX) { jobj = util_json_object_hex(serial, flags); diff --git a/cxl/list.c b/cxl/list.c index 8c48fbb..6ec4403 100644 --- a/cxl/list.c +++ b/cxl/list.c @@ -52,6 +52,8 @@ static const struct option options[] = { "include memory device health information"), OPT_BOOLEAN('I', "partition", ¶m.partition, "include memory device partition information"), + OPT_BOOLEAN('A', "alert", ¶m.alert, + "include alert configuration information"), OPT_INCR('v', "verbose", ¶m.verbose, "increase output detail"), #ifdef ENABLE_DEBUG @@ -113,6 +115,7 @@ int cmd_list(int argc, const char **argv, struct cxl_ctx *ctx) case 3: param.health = true; param.partition = true; + param.alert = true; /* fallthrough */ case 2: param.idle = true; diff --git a/util/json.h b/util/json.h index 73bb9f0..06594b5 100644 --- a/util/json.h +++ b/util/json.h @@ -20,6 +20,7 @@ enum util_json_flags { UTIL_JSON_HEALTH = (1 << 10), UTIL_JSON_TARGETS = (1 << 11), UTIL_JSON_PARTITION = (1 << 12), + UTIL_JSON_ALERT = (1 << 13), }; void util_display_json_array(FILE *f_out, struct json_object *jarray,