From a29b3c8997b8a5aa818005bb060fb7770c07e5b5 Mon Sep 17 00:00:00 2001 From: Harald Freudenberger Date: Fri, 18 Feb 2022 15:42:36 +0100 Subject: [PATCH] lszcrypt: new options to show only accel, cca or ep11 cards/queues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New options: --accelonly --ccaonly --ep11only which restrict the output to only cards/queues with the given mode. Signed-off-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zconf/zcrypt/lszcrypt.8 | 12 ++++++++- zconf/zcrypt/lszcrypt.c | 54 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/zconf/zcrypt/lszcrypt.8 b/zconf/zcrypt/lszcrypt.8 index 7a822fc4..4e3c3e93 100644 --- a/zconf/zcrypt/lszcrypt.8 +++ b/zconf/zcrypt/lszcrypt.8 @@ -16,7 +16,8 @@ lszcrypt \- display zcrypt device and configuration information .SH SYNOPSIS .TP 9 .B lszcrypt -.RB "[ " -V " ] " +.RB "[" --accelonly | --ccaonly | --ep11only "]" +.RB "[" -V "]" [ .I [...]] @@ -111,6 +112,15 @@ Displays help text and exits. .TP 8 .B -v, --version Displays version information and exits. +.TP 8 +.B --accelonly +Show only information for cards/queues in Accelerator mode. +.TP 8 +.B --ccaonly +Show only information for cards/queues in CCA-Coprocessor mode. +.TP 8 +.B --ep11only +Show only information for cards/queues in EP11-Coprocessor mode. .SH LISTING DETAILS Here is an explanation of the columns displayed. Please note that some of the columns show up in verbose mode only. diff --git a/zconf/zcrypt/lszcrypt.c b/zconf/zcrypt/lszcrypt.c index b180d1e3..dc807759 100644 --- a/zconf/zcrypt/lszcrypt.c +++ b/zconf/zcrypt/lszcrypt.c @@ -29,6 +29,9 @@ */ static struct lszcrypt_l { int verbose; + int showaccel; + int showcca; + int showep11; } l; /* @@ -96,6 +99,11 @@ static const struct util_prg prg = { /* * Configuration of command line options */ + +#define OPT_ACCELONLY 0x81 +#define OPT_CCAONLY 0x82 +#define OPT_EP11ONLY 0x83 + static struct util_opt opt_vec[] = { { .option = {"bus", 0, NULL, 'b'}, @@ -114,6 +122,21 @@ static struct util_opt opt_vec[] = { .option = {"verbose", 0, NULL, 'V'}, .desc = "Print verbose messages", }, + { + .option = {"accelonly", 0, NULL, OPT_ACCELONLY}, + .flags = UTIL_OPT_FLAG_NOSHORT, + .desc = "Show only information from cards/queues in Accelerator mode", + }, + { + .option = {"ccaonly", 0, NULL, OPT_CCAONLY}, + .flags = UTIL_OPT_FLAG_NOSHORT, + .desc = "Show only information from cards/queues in CCA-Coprocessor mode", + }, + { + .option = {"ep11only", 0, NULL, OPT_EP11ONLY}, + .flags = UTIL_OPT_FLAG_NOSHORT, + .desc = "Show only information from cards/queues in EP11-Coprocessor mode", + }, UTIL_OPT_HELP, UTIL_OPT_VERSION, UTIL_OPT_END @@ -617,7 +640,7 @@ static void read_rec_verbose(struct util_rec *rec, const char *grp_dev) */ static void show_device(struct util_rec *rec, const char *device) { - char *grp_dev, card[16]; + char *grp_dev, card[16], type[16], t = '\0'; strcpy(card, &device[4]); grp_dev = util_path_sysfs("devices/ap/%s", device); @@ -635,6 +658,14 @@ static void show_device(struct util_rec *rec, const char *device) } util_rec_set(rec, "card", card); + if (util_file_read_line(type, sizeof(type), "%s/type", grp_dev) == 0) + t = type[strlen(type) - 1]; + + if ((t == 'A' && !l.showaccel) || + (t == 'C' && !l.showcca) || + (t == 'P' && !l.showep11)) + goto out_free; + read_rec_default(rec, grp_dev); read_rec_verbose(rec, grp_dev); @@ -816,6 +847,15 @@ int main(int argc, char **argv) case 'V': l.verbose++; break; + case OPT_ACCELONLY: + l.showaccel = 1; + break; + case OPT_CCAONLY: + l.showcca = 1; + break; + case OPT_EP11ONLY: + l.showep11 = 1; + break; case 'h': util_prg_print_help(); util_opt_print_help(); @@ -829,6 +869,18 @@ int main(int argc, char **argv) return EXIT_FAILURE; } } + + switch (l.showaccel + l.showcca + l.showep11) { + case 0: + l.showaccel = l.showcca = l.showep11 = 1; + break; + case 1: + break; + default: + warnx("Only one of --accelonly or --ccaonly or --ep11only can be specified"); + return EXIT_FAILURE; + } + if (optind == argc) show_devices_all(); else