From 27dce3317a99c3f22f6bcc9a5e68f581cd470164 Mon Sep 17 00:00:00 2001 From: Harald Freudenberger Date: Wed, 17 Nov 2021 15:02:01 +0100 Subject: [PATCH] lszcrypt: add support for checkstop state MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Newer kernel show a sysfs attribute chkstop which displays the checkstop state of a crypto card. This patch enables support for lszcrypt to display the checkstop state. Signed-off-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zconf/zcrypt/lszcrypt.8 | 3 +++ zconf/zcrypt/lszcrypt.c | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/zconf/zcrypt/lszcrypt.8 b/zconf/zcrypt/lszcrypt.8 index 351ce3e6..7a822fc4 100644 --- a/zconf/zcrypt/lszcrypt.8 +++ b/zconf/zcrypt/lszcrypt.8 @@ -154,6 +154,9 @@ cryptographic operations. 'offline' is displayed when a card or queue is switched to (software) offline. If a card is 'deconfigured' via HMC, SE or chzcrypt the field shows 'deconfig'. .br +A crypto card may also reach a 'checkstopped' state. lszcrypt shows +this as 'chkstop'. +.br If a queue is not bound to a device driver there is no detailed information available and thus the status shows only '-'. .br diff --git a/zconf/zcrypt/lszcrypt.c b/zconf/zcrypt/lszcrypt.c index cb06325d..b180d1e3 100644 --- a/zconf/zcrypt/lszcrypt.c +++ b/zconf/zcrypt/lszcrypt.c @@ -381,7 +381,7 @@ static int read_driver(const char *dir, const char *subdir, char *buf, size_t bu static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev, const char *sub_dev) { - long config = -1, online = -1; + long config = -1, online = -1, chkstop = -1; char buf[256]; unsigned long facility; @@ -392,6 +392,8 @@ static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev, if (util_path_is_readable("%s/%s/config", grp_dev, sub_dev)) util_file_read_l(&config, 10, "%s/%s/config", grp_dev, sub_dev); + if (util_path_is_readable("%s/%s/chkstop", grp_dev, sub_dev)) + util_file_read_l(&chkstop, 10, "%s/%s/chkstop", grp_dev, sub_dev); if (util_path_is_readable("%s/%s/online", grp_dev, sub_dev)) util_file_read_l(&online, 10, "%s/%s/online", grp_dev, sub_dev); @@ -399,7 +401,9 @@ static void read_subdev_rec_default(struct util_rec *rec, const char *grp_dev, if (config == 0) { util_rec_set(rec, "status", "deconfig"); } else { - if (online > 0) + if (chkstop > 0) + util_rec_set(rec, "status", "chkstop"); + else if (online > 0) util_rec_set(rec, "status", "online"); else if (online == 0) util_rec_set(rec, "status", "offline"); @@ -522,7 +526,7 @@ static void show_subdevices(struct util_rec *rec, const char *grp_dev) */ static void read_rec_default(struct util_rec *rec, const char *grp_dev) { - long config = -1, online = -1; + long config = -1, online = -1, chkstop = -1; char buf[256]; unsigned long facility; @@ -543,12 +547,16 @@ static void read_rec_default(struct util_rec *rec, const char *grp_dev) if (util_path_is_readable("%s/config", grp_dev)) util_file_read_l(&config, 10, "%s/config", grp_dev); + if (util_path_is_readable("%s/chkstop", grp_dev)) + util_file_read_l(&chkstop, 10, "%s/chkstop", grp_dev); if (util_path_is_readable("%s/online", grp_dev)) util_file_read_l(&online, 10, "%s/online", grp_dev); if (config == 0) { util_rec_set(rec, "status", "deconfig"); } else { - if (online > 0) + if (chkstop > 0) + util_rec_set(rec, "status", "chkstop"); + else if (online > 0) util_rec_set(rec, "status", "online"); else if (online == 0) util_rec_set(rec, "status", "offline");