diff --git a/include/lib/libcpumf.h b/include/lib/libcpumf.h index 1f7468e2..832d9124 100644 --- a/include/lib/libcpumf.h +++ b/include/lib/libcpumf.h @@ -17,6 +17,7 @@ #define S390_CPUS_ONLINE "/sys/devices/system/cpu/online" #define S390_CPUMSF_BUFFERSZ "/sys/module/kernel/parameters/cpum_sfb_size" #define S390_SYSFS_PAI_CRYPTO "/sys/devices/pai_crypto/" +#define S390_SYSFS_PAI_NNPA "/sys/devices/pai_nnpa/" /** * Read out the PMU type from a given file. @@ -144,4 +145,13 @@ bool libcpumf_sfb_info(unsigned long *min, unsigned long *max); * @retval false PAI_CRYPTO counter Facility is not available */ bool libcpumf_have_pai_crypto(void); + +/** + * Return true if PAI_NNPA counter Facility is supported. This PMU facility + * supports the Neural Network Processing Assist (NNPA) counter set. + * + * @retval true PAI_NNPA counter Facility is available + * @retval false PAI_NNPA counter Facility is not available + */ +bool libcpumf_have_pai_nnpa(void); #endif diff --git a/libcpumf/libcpumf_example.c b/libcpumf/libcpumf_example.c index 57e17603..f962b5bc 100644 --- a/libcpumf/libcpumf_example.c +++ b/libcpumf/libcpumf_example.c @@ -83,5 +83,7 @@ int main(void) printf("PMU type 10 PMU name %s\n", pmuname); free(pmuname); } + + printf("PAI NNPA support %d\n", libcpumf_have_pai_nnpa()); return EXIT_SUCCESS; } diff --git a/libcpumf/libcpumf_support.c b/libcpumf/libcpumf_support.c index 3e25835f..bd6e4079 100644 --- a/libcpumf/libcpumf_support.c +++ b/libcpumf/libcpumf_support.c @@ -146,3 +146,10 @@ bool libcpumf_have_pai_crypto(void) return (stat(S390_SYSFS_PAI_CRYPTO, &statbuf) == -1) ? false : true; } + +bool libcpumf_have_pai_nnpa(void) +{ + struct stat statbuf; + + return (stat(S390_SYSFS_PAI_NNPA, &statbuf) == -1) ? false : true; +}