From a8b0d7ace8f7aa3d61ae818b3e23bd60c5c53548 Mon Sep 17 00:00:00 2001 From: Harald Freudenberger Date: Fri, 18 Feb 2022 16:12:46 +0100 Subject: [PATCH] lszcrypt: new options to filter cards/queues only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New options: --cardonly --queueonly which filter the output to show only card or queue information. Signed-off-by: Harald Freudenberger Signed-off-by: Jan Höppner --- zconf/zcrypt/lszcrypt.8 | 16 +++++++++++++++- zconf/zcrypt/lszcrypt.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/zconf/zcrypt/lszcrypt.8 b/zconf/zcrypt/lszcrypt.8 index 4e3c3e93..1c53a80e 100644 --- a/zconf/zcrypt/lszcrypt.8 +++ b/zconf/zcrypt/lszcrypt.8 @@ -16,7 +16,7 @@ lszcrypt \- display zcrypt device and configuration information .SH SYNOPSIS .TP 9 .B lszcrypt -.RB "[" --accelonly | --ccaonly | --ep11only "]" +.RB "[" "]" .RB "[" -V "]" [ .I @@ -33,6 +33,9 @@ lszcrypt \- display zcrypt device and configuration information .B lszcrypt -h .TP .B lszcrypt -v +. TP +.B +[--accelonly|--ccaonly|--ep11only] [--cardonly|--queueonly] .SH DESCRIPTION The .B lszcrypt @@ -121,6 +124,12 @@ Show only information for cards/queues in CCA-Coprocessor mode. .TP 8 .B --ep11only Show only information for cards/queues in EP11-Coprocessor mode. +.TP 8 +.B --cardonly +Show only information for cards but no queue info. +.TP 8 +.B --queueonly +Show only information for queues but no card info. .SH LISTING DETAILS Here is an explanation of the columns displayed. Please note that some of the columns show up in verbose mode only. @@ -223,6 +232,11 @@ cex2acard/cex2aqueue (CEX2A and CEX3A hardware) and vfio_ap (queue reserved for use by kvm hypervisor for kvm guests and not accessible to host applications). It is also valid to have no driver handling a queue which is shown as a -no-driver- entry. +.SH NOTES +Use only one of the mode filtering options --accelonly, --ccaonly, --ep11only. +Same with card/queue filtering: Use only one of --cardonly, --queueonly. +However, one of the mode filtering options and one of the card/queue filtering +can be combined. .SH EXAMPLES .TP .B lszcrypt diff --git a/zconf/zcrypt/lszcrypt.c b/zconf/zcrypt/lszcrypt.c index dc807759..a0884417 100644 --- a/zconf/zcrypt/lszcrypt.c +++ b/zconf/zcrypt/lszcrypt.c @@ -32,6 +32,8 @@ static struct lszcrypt_l { int showaccel; int showcca; int showep11; + int showcard; + int showqueue; } l; /* @@ -103,6 +105,8 @@ static const struct util_prg prg = { #define OPT_ACCELONLY 0x81 #define OPT_CCAONLY 0x82 #define OPT_EP11ONLY 0x83 +#define OPT_CARDONLY 0x84 +#define OPT_QUEUEONLY 0x85 static struct util_opt opt_vec[] = { { @@ -137,6 +141,16 @@ static struct util_opt opt_vec[] = { .flags = UTIL_OPT_FLAG_NOSHORT, .desc = "Show only information from cards/queues in EP11-Coprocessor mode", }, + { + .option = {"cardonly", 0, NULL, OPT_CARDONLY}, + .flags = UTIL_OPT_FLAG_NOSHORT, + .desc = "Show only information from cards but no queue info", + }, + { + .option = {"queueonly", 0, NULL, OPT_QUEUEONLY}, + .flags = UTIL_OPT_FLAG_NOSHORT, + .desc = "Show only information from queues but no card info", + }, UTIL_OPT_HELP, UTIL_OPT_VERSION, UTIL_OPT_END @@ -522,6 +536,9 @@ static void show_subdevice(struct util_rec *rec, const char *grp_dev, !util_path_is_readable("%s/%s/online", grp_dev, sub_dev))) return; + if (!l.showqueue) + return; + util_rec_set(rec, "card", sub_dev); read_subdev_rec_default(rec, grp_dev, sub_dev); read_subdev_rec_verbose(rec, grp_dev, sub_dev); @@ -669,8 +686,10 @@ static void show_device(struct util_rec *rec, const char *device) read_rec_default(rec, grp_dev); read_rec_verbose(rec, grp_dev); - util_rec_print(rec); - show_subdevices(rec, grp_dev); + if (l.showcard) + util_rec_print(rec); + if (l.showqueue) + show_subdevices(rec, grp_dev); out_free: free(grp_dev); } @@ -856,6 +875,12 @@ int main(int argc, char **argv) case OPT_EP11ONLY: l.showep11 = 1; break; + case OPT_CARDONLY: + l.showcard = 1; + break; + case OPT_QUEUEONLY: + l.showqueue = 1; + break; case 'h': util_prg_print_help(); util_opt_print_help(); @@ -881,6 +906,17 @@ int main(int argc, char **argv) return EXIT_FAILURE; } + switch (l.showcard + l.showqueue) { + case 0: + l.showcard = l.showqueue = 1; + break; + case 1: + break; + default: + warnx("Only one of --cardonly or --queueonly can be specified"); + return EXIT_FAILURE; + } + if (optind == argc) show_devices_all(); else