Subject: [PATCH] [BZ 184585] cpumf: Add support for CPU-Measurement Facility counters SVN 6
From: Thomas Richter <tmricht@linux.ibm.com>

Description:  lscpumf: New z15 CPU-MF counters not available
Symptom:      Command lscpumf -c does not show the new
              deflate counters on IBM z15.
Problem:      The new counter names have not been published
              in document SA23-2261-06 by the time te code was
              release.
Solution:     Add the definition for the new deflate counters.
Reproduction:  Run command lscpumf -c and check for counters
               rf7, rfc, r107 and r108.
Upstream-ID:   f110a77b68d46f10cab8847cf73fe92686ae7d11
Problem-ID:    184585

Upstream-Description:

              cpumf: Add support for CPU-Measurement Facility counters SVN 6

              Add support for CPU-Measurement facility counter second version
              number 6. This adds some more counters to the crypto counter set.
              Extended counter set is the same as for z14.

              Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
              Signed-off-by: Jan Hoeppner <hoeppner@linux.ibm.com>


Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
---
 cpumf/Makefile                      |    2 
 cpumf/bin/cpumf_helper.in           |    7 ++
 cpumf/data/cpum-cf-csvn-12345.ctr   |  100 ++++++++++++++++++++++++++++++++++++
 cpumf/data/cpum-cf-csvn-6.ctr       |   33 +++++++++++
 cpumf/data/cpum-cf-csvn-generic.ctr |   84 ------------------------------
 cpumf/data/cpum-cf-hw-counter.map   |    6 +-
 6 files changed, 145 insertions(+), 87 deletions(-)

--- a/cpumf/Makefile
+++ b/cpumf/Makefile
@@ -6,7 +6,7 @@ include ../common.mak
 CPUMF_DATADIR = $(TOOLS_DATADIR)/cpumf
 DATA_FILES = cpum-cf-hw-counter.map \
 	     cpum-cf-cfvn-1.ctr cpum-cf-cfvn-3.ctr \
-	     cpum-cf-csvn-generic.ctr \
+	     cpum-cf-csvn-12345.ctr cpum-cf-csvn-6.ctr \
              cpum-cf-extended-z10.ctr cpum-cf-extended-z196.ctr \
 	     cpum-cf-extended-zEC12.ctr cpum-sf-modes.ctr \
 	     cpum-cf-extended-z13.ctr cpum-cf-extended-z14.ctr
--- a/cpumf/bin/cpumf_helper.in
+++ b/cpumf/bin/cpumf_helper.in
@@ -266,7 +266,12 @@ sub cpumf_load_ctrdef($;$)
 	# List of "generic" counter sets
 	my @def = ();
 	push @def, "cfvn-" . $version->{cfvn};
-	push @def, "csvn-generic";
+	if ($version->{csvn} >= 1 && $version->{csvn} <= 6) {
+		push @def, "csvn-12345";
+	}
+	if ($version->{csvn} == 6) {
+		push @def, "csvn-6";
+	}
 
 	my $h = {};
 	# Load counter set definition
--- /dev/null
+++ b/cpumf/data/cpum-cf-csvn-12345.ctr
@@ -0,0 +1,100 @@
+Counter:  64	Name:PRNG_FUNCTIONS
+Short-Description:PRNG Functions
+Description:
+Total number of the PRNG functions issued by the CPU
+.
+Counter:  65	Name:PRNG_CYCLES
+Short-Description:PRNG Cycles
+Description:
+Total number of CPU cycles when the DEA/AES coprocessor is busy
+performing PRNG functions issued by the CPU
+.
+Counter:  66	Name:PRNG_BLOCKED_FUNCTIONS
+Short-Description:PRNG Blocked Functions
+Description:
+Total number of the PRNG functions that are issued by the CPU and are
+blocked because the DEA/AES coprocessor is busy performing a function
+issued by another CPU
+.
+Counter:  67	Name:PRNG_BLOCKED_CYCLES
+Short-Description:PRNG Blocked Cycles
+Description:
+Total number of CPU cycles blocked for the PRNG functions issued by
+the CPU because the DEA/AES coprocessor is busy performing a function
+issued by another CPU
+.
+Counter:  68	Name:SHA_FUNCTIONS
+Short-Description:SHA Functions
+Description:
+Total number of SHA functions issued by the CPU
+.
+Counter:  69	Name:SHA_CYCLES
+Short-Description:SHA Cycles
+Description:
+Total number of CPU cycles when the SHA coprocessor is busy performing
+the SHA functions issued by the CPU
+.
+Counter:  70	Name:SHA_BLOCKED_FUNCTIONS
+Short-Description:SHA Blocked Functions
+Description:
+Total number of the SHA functions that are issued by the CPU and are
+blocked because the SHA coprocessor is busy performing a function issued
+by another CPU
+.
+Counter:  71	Name:SHA_BLOCKED_CYCLES
+Short-Description:SHA Bloced Cycles
+Description:
+Total number of CPU cycles blocked for the SHA functions issued by the
+CPU because the SHA coprocessor is busy performing a function issued
+by another CPU
+.
+Counter:  72	Name:DEA_FUNCTIONS
+Short-Description:DEA Functions
+Description:
+Total number of the DEA functions issued by the CPU
+.
+Counter:  73	Name:DEA_CYCLES
+Short-Description:DEA Cycles
+Description:
+Total number of CPU cycles when the DEA/AES coprocessor is busy
+performing the DEA functions issued by the CPU
+.
+Counter:  74	Name:DEA_BLOCKED_FUNCTIONS
+Short-Description:DEA Blocked Functions
+Description:
+Total number of the DEA functions that are issued by the CPU and are
+blocked because the DEA/AES coprocessor is busy performing a function
+issued by another CPU
+.
+Counter:  75	Name:DEA_BLOCKED_CYCLES
+Short-Description:DEA Blocked Cycles
+Description:
+Total number of CPU cycles blocked for the DEA functions issued by the
+CPU because the DEA/AES coprocessor is busy performing a function issued
+by another CPU
+.
+Counter:  76	Name:AES_FUNCTIONS
+Short-Description:AES Functions
+Description:
+Total number of AES functions issued by the CPU
+.
+Counter:  77	Name:AES_CYCLES
+Short-Description:AES Cycles
+Description:
+Total number of CPU cycles when the DEA/AES coprocessor is busy
+performing the AES functions issued by the CPU
+.
+Counter:  78	Name:AES_BLOCKED_FUNCTIONS
+Short-Description:AES Blocked Functions
+Description:
+Total number of AES functions that are issued by the CPU and are blocked
+because the DEA/AES coprocessor is busy performing a function issued
+by another CPU
+.
+Counter:  79	Name:AES_BLOCKED_CYCLES
+Short-Description:AES Blocked Cycles
+Description:
+Total number of CPU cycles blocked for the AES functions issued by the
+CPU because the DEA/AES coprocessor is busy performing a function issued
+by another CPU
+.
--- /dev/null
+++ b/cpumf/data/cpum-cf-csvn-6.ctr
@@ -0,0 +1,33 @@
+Counter:  80	Name:ECC_FUNCTION_COUNT
+Short-Description:ECC Function Count
+Description:
+This counter counts the
+total number of the elliptic-curve cryptography (ECC)
+functions issued by the CPU.
+.
+Counter:  81	Name:ECC_CYCLES_COUNT
+Short-Description:ECC Cycles Count
+Description:
+This counter counts the total
+number of CPU cycles when the ECC coprocessor is
+busy performing the elliptic-curve cryptography
+(ECC) functions issued by the CPU.
+.
+Counter:  82	Name:ECC_BLOCKED_FUNCTION_COUNT
+Short-Description:Ecc Blocked Function Count
+Description:
+This counter
+counts the total number of the elliptic-curve
+cryptography (ECC) functions that are issued by the CPU
+and are blocked because the ECC coprocessor is
+busy performing a function issued by another CPU.
+.
+Counter:  83	Name:ECC_BLOCKED_CYCLES_COUNT
+Short-Description:ECC Blocked Cycles Count
+Description:
+This counter counts
+the total number of CPU cycles blocked for the elliptic-curve
+cryptography (ECC) functions issued by the
+CPU because the ECC coprocessor is busy perform-
+ing a function issued by another CPU.
+.
--- a/cpumf/data/cpum-cf-csvn-generic.ctr
+++ /dev/null
@@ -1,84 +0,0 @@
-Counter:  64	Name:PRNG_FUNCTIONS
-Description:
-Total number of the PRNG functions issued by the CPU
-.
-Counter:  65	Name:PRNG_CYCLES
-Description:
-Total number of CPU cycles when the DEA/AES coprocessor is busy
-performing PRNG functions issued by the CPU
-.
-Counter:  66	Name:PRNG_BLOCKED_FUNCTIONS
-Description:
-Total number of the PRNG functions that are issued by the CPU and are
-blocked because the DEA/AES coprocessor is busy performing a function
-issued by another CPU
-.
-Counter:  67	Name:PRNG_BLOCKED_CYCLES
-Description:
-Total number of CPU cycles blocked for the PRNG functions issued by
-the CPU because the DEA/AES coprocessor is busy performing a function
-issued by another CPU
-.
-Counter:  68	Name:SHA_FUNCTIONS
-Description:
-Total number of SHA functions issued by the CPU
-.
-Counter:  69	Name:SHA_CYCLES
-Description:
-Total number of CPU cycles when the SHA coprocessor is busy performing
-the SHA functions issued by the CPU
-.
-Counter:  70	Name:SHA_BLOCKED_FUNCTIONS
-Description:
-Total number of the SHA functions that are issued by the CPU and are
-blocked because the SHA coprocessor is busy performing a function issued
-by another CPU
-.
-Counter:  71	Name:SHA_BLOCKED_CYCLES
-Description:
-Total number of CPU cycles blocked for the SHA functions issued by the
-CPU because the SHA coprocessor is busy performing a function issued
-by another CPU
-.
-Counter:  72	Name:DEA_FUNCTIONS
-Description:
-Total number of the DEA functions issued by the CPU
-.
-Counter:  73	Name:DEA_CYCLES
-Description:
-Total number of CPU cycles when the DEA/AES coprocessor is busy
-performing the DEA functions issued by the CPU
-.
-Counter:  74	Name:DEA_BLOCKED_FUNCTIONS
-Description:
-Total number of the DEA functions that are issued by the CPU and are
-blocked because the DEA/AES coprocessor is busy performing a function
-issued by another CPU
-.
-Counter:  75	Name:DEA_BLOCKED_CYCLES
-Description:
-Total number of CPU cycles blocked for the DEA functions issued by the
-CPU because the DEA/AES coprocessor is busy performing a function issued
-by another CPU
-.
-Counter:  76	Name:AES_FUNCTIONS
-Description:
-Total number of AES functions issued by the CPU
-.
-Counter:  77	Name:AES_CYCLES
-Description:
-Total number of CPU cycles when the DEA/AES coprocessor is busy
-performing the AES functions issued by the CPU
-.
-Counter:  78	Name:AES_BLOCKED_FUNCTIONS
-Description:
-Total number of AES functions that are issued by the CPU and are blocked
-because the DEA/AES coprocessor is busy performing a function issued
-by another CPU
-.
-Counter:  79	Name:AES_BLOCKED_CYCLES
-Description:
-Total number of CPU cycles blocked for the AES functions issued by the
-CPU because the DEA/AES coprocessor is busy performing a function issued
-by another CPU
-.
--- a/cpumf/data/cpum-cf-hw-counter.map
+++ b/cpumf/data/cpum-cf-hw-counter.map
@@ -14,7 +14,8 @@
 	'cfvn-3'	=> 'cpum-cf-cfvn-3.ctr',
 
 	# CSVN
-	'csvn-generic'	=> 'cpum-cf-csvn-generic.ctr',
+	'csvn-12345'	=> 'cpum-cf-csvn-12345.ctr',
+	'csvn-6'	=> 'cpum-cf-csvn-6.ctr',
 
 	# Extended counters
 	2097		=> 'cpum-cf-extended-z10.ctr',
@@ -27,4 +28,7 @@
 	2965		=> 'cpum-cf-extended-z13.ctr',
 	3906		=> 'cpum-cf-extended-z14.ctr',
 	3907		=> 'cpum-cf-extended-z14.ctr',
+	# Identical with z14
+	8561		=> 'cpum-cf-extended-z14.ctr',
+	8562		=> 'cpum-cf-extended-z14.ctr',
 };
