lszcrypt: new options to show only accel, cca or ep11 cards/queues

New options:
  --accelonly
  --ccaonly
  --ep11only
which restrict the output to only cards/queues with the given mode.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Harald Freudenberger
2022-02-18 15:42:36 +01:00
committed by Jan Höppner
parent 27dce3317a
commit a29b3c8997
2 changed files with 64 additions and 2 deletions

View File

@@ -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 <device-id>
[...]]
@@ -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.

View File

@@ -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