cpumf/lspai: Add command line flags for hexadecimal output

Add command line flags -x and -X to print counter values in
hexadecimal format with leading 0x prefix (-X) and without (-x).

Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Thomas Richter
2025-06-25 08:03:49 +02:00
committed by Jan Höppner
parent 973059438f
commit 43067df78e
2 changed files with 27 additions and 0 deletions

View File

@@ -69,6 +69,14 @@ static struct util_opt opt_vec[] = {
.argument = "TYPE",
.desc = "Type of PAI counters to show: crypto, nnpa"
},
{
.option = { "hex0x", no_argument, NULL, 'X' },
.desc = "Counter values in hexadecimal format with leading 0x"
},
{
.option = { "hex", no_argument, NULL, 'x' },
.desc = "Counter values in hexadecimal format"
},
UTIL_OPT_HELP,
UTIL_OPT_VERSION,
UTIL_OPT_END
@@ -659,6 +667,14 @@ int main(int argc, char **argv)
case 't':
check_type_name(optarg);
break;
case 'x':
list_only = false;
ctrformat = "%lx";
break;
case 'X':
list_only = false;
ctrformat = "%#lx";
break;
case OPT_FORMAT:
if (!util_fmt_name_to_type(optarg, &fmt))
errx(EXIT_FAILURE, "Supported formats:" FMT_TYPE_NAMES);

View File

@@ -30,6 +30,7 @@
.IR SECONDS ]
.RB [ \-l
.IR COUNT ]
.RB [ \-x ][ \-X ]
.RI [ CPULIST ]
.br
\*c
@@ -48,6 +49,8 @@ and numbers in various formats.
If
.I CPULIST
is specified or any of the options
.BR \-x ,
.BR \-X ,
.B \-l
or
.BR \-i,
@@ -106,6 +109,14 @@ The default is 60 seconds.
Performs the specified number of read operations.
The default is one.
.
.TP
.BR \-x ", " \-\-hex
Displays counter values as hexadecimal values.
.
.TP
.BR \-X ", " \-\-hex0x
Displays counter values as hexadecimal values with a leading 0x prefix.
.
.SH "EXAMPLE"
The \*c invocation lists all PAI Neural Network Processing Assist Facility
(NNPA) counters in numeric order: