This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 60cc4b660bea6af9b37a14fbf1ad07589b15b34e (commit) via a9e3b02a54cd9a18baf8042e389ffbdb9266a9c7 (commit) via ce5951842845b519c7887479c8e4e128e1951add (commit) via 808acd63c4ec54af93eb5bbf717d4b591df1d904 (commit) via 6b947deb94b45660a5140472565886e9d5f1203f (commit) from 0330e7369aa682ac2c2feb2bcb197e52dc1810fb (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 60cc4b660bea6af9b37a14fbf1ad07589b15b34e Author: Petri Savolainen petri.savolainen@linaro.org Date: Mon Jun 25 13:29:08 2018 +0300
linux-gen: sysinfo: parse aarch64 cpuinfo
Parse /proc/cpuinfo also on aarch64 and fill in cpu model information.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index c6b5ac99..a3399011 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -266,7 +266,7 @@ endif if ARCH_IS_AARCH64 __LIB__libodp_linux_la_SOURCES += arch/default/odp_cpu_cycles.c \ arch/aarch64/odp_global_time.c \ - arch/default/odp_sysinfo_parse.c + arch/aarch64/odp_sysinfo_parse.c odpapiabiarchinclude_HEADERS += arch/default/odp/api/abi/cpu_inlines.h \ arch/default/odp/api/abi/cpu_time.h if !ODP_ABI_COMPAT diff --git a/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c b/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c new file mode 100644 index 00000000..85aec6a6 --- /dev/null +++ b/platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c @@ -0,0 +1,212 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include "config.h" + +#include <stdio.h> +#include <string.h> +#include <stdlib.h> + +#include <odp_sysinfo_internal.h> +#include <odp_debug_internal.h> + +#define DUMMY_MAX_MHZ 1000 +#define TMP_STR_LEN 64 + +static void aarch64_impl_str(char *str, int maxlen, int implementer) +{ + switch (implementer) { + case 0x41: + snprintf(str, maxlen, "ARM Limited"); + return; + case 0x42: + snprintf(str, maxlen, "Broadcom Corporation"); + return; + case 0x43: + snprintf(str, maxlen, "Cavium Inc."); + return; + case 0x44: + snprintf(str, maxlen, "Digital Equipment Corporation"); + return; + case 0x49: + snprintf(str, maxlen, "Infineon Technologies AG"); + return; + case 0x4d: + snprintf(str, maxlen, "Freescale Semiconductor Inc."); + return; + case 0x4e: + snprintf(str, maxlen, "NVIDIA Corporation"); + return; + case 0x50: + snprintf(str, maxlen, "Applied Micro Circuits Corporation"); + return; + case 0x51: + snprintf(str, maxlen, "Qualcomm Inc."); + return; + case 0x56: + snprintf(str, maxlen, "Marvell International Ltd."); + return; + case 0x69: + snprintf(str, maxlen, "Intel Corporation"); + return; + default: + break; + } + + snprintf(str, maxlen, "UNKNOWN (0x%x)", implementer); +} + +static void aarch64_part_str(char *str, int maxlen, int implementer, + int part, int variant, int revision) +{ + if (implementer == 0x41) { + switch (part) { + case 0xd03: + snprintf(str, maxlen, "Cortex-A53"); + return; + case 0xd05: + snprintf(str, maxlen, "Cortex-A55"); + return; + case 0xd07: + snprintf(str, maxlen, "Cortex-A57"); + return; + case 0xd08: + snprintf(str, maxlen, "Cortex-A72"); + return; + case 0xd09: + snprintf(str, maxlen, "Cortex-A73"); + return; + case 0xd0a: + snprintf(str, maxlen, "Cortex-A75"); + return; + default: + break; + } + } else if (implementer == 0x43) { + switch (part) { + case 0xa1: + snprintf(str, maxlen, "CN88XX, Pass %i.%i", + variant + 1, revision); + return; + case 0xa2: + snprintf(str, maxlen, "CN81XX, Pass %i.%i", + variant + 1, revision); + return; + case 0xa3: + snprintf(str, maxlen, "CN83XX, Pass %i.%i", + variant + 1, revision); + return; + case 0xaf: + snprintf(str, maxlen, "CN99XX, Pass %i.%i", + variant + 1, revision); + return; + default: + break; + } + } + + snprintf(str, maxlen, "part 0x%x, var 0x%x, rev 0x%x", + part, variant, revision); +} + +int cpuinfo_parser(FILE *file, system_info_t *sysinfo) +{ + char str[1024]; + char impl_str[TMP_STR_LEN]; + char part_str[TMP_STR_LEN]; + const char *cur; + long int impl, arch, var, part, rev; + int id; + + strcpy(sysinfo->cpu_arch_str, "aarch64"); + + memset(impl_str, 0, sizeof(impl_str)); + memset(part_str, 0, sizeof(part_str)); + + impl = 0; + arch = 0; + var = 0; + part = 0; + rev = 0; + id = 0; + + while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU) { + /* Parse line by line a block of cpuinfo */ + cur = strstr(str, "CPU implementer"); + + if (cur) { + cur = strchr(cur, ':'); + impl = strtol(cur + 1, NULL, 16); + aarch64_impl_str(impl_str, TMP_STR_LEN, impl); + continue; + } + + cur = strstr(str, "CPU architecture"); + + if (cur) { + cur = strchr(cur, ':'); + arch = strtol(cur + 1, NULL, 10); + continue; + } + + cur = strstr(str, "CPU variant"); + + if (cur) { + cur = strchr(cur, ':'); + var = strtol(cur + 1, NULL, 16); + continue; + } + + cur = strstr(str, "CPU part"); + + if (cur) { + cur = strchr(cur, ':'); + part = strtol(cur + 1, NULL, 16); + continue; + } + + cur = strstr(str, "CPU revision"); + + if (cur) { + cur = strchr(cur, ':'); + rev = strtol(cur + 1, NULL, 10); + + aarch64_part_str(part_str, TMP_STR_LEN, + impl, part, var, rev); + + /* This is the last line about this cpu, update + * model string. */ + snprintf(sysinfo->model_str[id], + sizeof(sysinfo->model_str[id]), + "%s, %s, arch %li", + impl_str, part_str, arch); + + /* Some CPUs do not support cpufreq, use a dummy + * max freq. */ + if (sysinfo->cpu_hz_max[id] == 0) { + uint64_t hz = DUMMY_MAX_MHZ * 1000000; + + ODP_PRINT("WARN: cpu[%i] uses dummy max frequency %u MHz\n", + id, DUMMY_MAX_MHZ); + sysinfo->cpu_hz_max[id] = hz; + } + + id++; + } + } + + return 0; +} + +void sys_info_print_arch(void) +{ +} + +uint64_t odp_cpu_arch_hz_current(int id) +{ + (void)id; + + return 0; +}
commit a9e3b02a54cd9a18baf8042e389ffbdb9266a9c7 Author: Petri Savolainen petri.savolainen@linaro.org Date: Wed Jun 27 17:10:16 2018 +0300
linux-gen: sysinfo: use cpufreq for max freq by default
Usually, maximum CPU frequency is found from a cpufreq file. Read that file first, if it's not found use cpuinfo instead. If max freq cannot be found, use hard coded value and print a warning.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/arch/default/odp_sysinfo_parse.c b/platform/linux-generic/arch/default/odp_sysinfo_parse.c index 2c3bf841..b9378887 100644 --- a/platform/linux-generic/arch/default/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/default/odp_sysinfo_parse.c @@ -10,13 +10,17 @@ #include <odp_debug_internal.h> #include <string.h>
+#define DUMMY_MAX_MHZ 1400 + int cpuinfo_parser(FILE *file ODP_UNUSED, system_info_t *sysinfo) { int i;
ODP_DBG("Warning: use dummy values for freq and model string\n"); for (i = 0; i < CONFIG_NUM_CPU; i++) { - sysinfo->cpu_hz_max[i] = 1400000000; + ODP_PRINT("WARN: cpu[%i] uses dummy max frequency %u MHz\n", + i, DUMMY_MAX_MHZ); + sysinfo->cpu_hz_max[i] = DUMMY_MAX_MHZ * 1000000; strcpy(sysinfo->model_str[i], "UNKNOWN"); }
diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c index 927cb83f..7b313b6d 100644 --- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c @@ -41,7 +41,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo)
pos = strchr(str, ':'); strncpy(sysinfo->model_str[id], pos + 2, - sizeof(sysinfo->model_str[id]) - 1); + MODEL_STR_SIZE - 1); len = strlen(sysinfo->model_str[id]); sysinfo->model_str[id][len - 1] = 0; model = 1; diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c index daa72c24..1fb1b4a3 100644 --- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c @@ -40,7 +40,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo)
pos = strchr(str, ':'); strncpy(sysinfo->model_str[id], pos + 2, - sizeof(sysinfo->model_str[id]) - 1); + MODEL_STR_SIZE - 1); len = strlen(sysinfo->model_str[id]); sysinfo->model_str[id][len - 1] = 0; model = 1; diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c index f9a21975..504aa3ef 100644 --- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c @@ -13,7 +13,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) { char str[1024]; - char *pos; + char *pos, *pos_end; double ghz = 0.0; uint64_t hz; int id = 0; @@ -22,17 +22,25 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU) { pos = strstr(str, "model name"); if (pos) { - pos = strchr(str, ':'); + /* Copy model name between : and @ characters */ + pos = strchr(str, ':'); + pos_end = strchr(str, '@'); + if (pos == NULL || pos_end == NULL) + continue; + + *(pos_end - 1) = '\0'; strncpy(sysinfo->model_str[id], pos + 2, - sizeof(sysinfo->model_str[id]) - 1); + MODEL_STR_SIZE - 1); + + if (sysinfo->cpu_hz_max[id]) { + id++; + continue; + }
- pos = strchr(sysinfo->model_str[id], '@'); - if (pos) { - *(pos - 1) = '\0'; - if (sscanf(pos, "@ %lfGHz", &ghz) == 1) { - hz = (uint64_t)(ghz * 1000000000.0); - sysinfo->cpu_hz_max[id] = hz; - } + /* max frequency needs to be set */ + if (sscanf(pos_end, "@ %lfGHz", &ghz) == 1) { + hz = (uint64_t)(ghz * 1000000000.0); + sysinfo->cpu_hz_max[id] = hz; } id++; } diff --git a/platform/linux-generic/include/odp_global_data.h b/platform/linux-generic/include/odp_global_data.h index 4a8702a6..009862a8 100644 --- a/platform/linux-generic/include/odp_global_data.h +++ b/platform/linux-generic/include/odp_global_data.h @@ -19,6 +19,7 @@ extern "C" { #include <libconfig.h> #include <odp_config_internal.h>
+#define MODEL_STR_SIZE 128 #define UID_MAXLEN 30
typedef struct { @@ -27,7 +28,7 @@ typedef struct { int cache_line_size; int cpu_count; char cpu_arch_str[128]; - char model_str[CONFIG_NUM_CPU][128]; + char model_str[CONFIG_NUM_CPU][MODEL_STR_SIZE]; } system_info_t;
typedef struct { diff --git a/platform/linux-generic/include/odp_sysinfo_internal.h b/platform/linux-generic/include/odp_sysinfo_internal.h index d34087e2..2f01d18e 100644 --- a/platform/linux-generic/include/odp_sysinfo_internal.h +++ b/platform/linux-generic/include/odp_sysinfo_internal.h @@ -14,7 +14,6 @@ extern "C" { #include <odp_global_data.h>
int cpuinfo_parser(FILE *file, system_info_t *sysinfo); -uint64_t odp_cpufreq_id(const char *filename, int id); uint64_t odp_cpu_hz_current(int id); uint64_t odp_cpu_arch_hz_current(int id); void sys_info_print_arch(void); diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 09e184a7..bca02ba1 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -265,7 +265,7 @@ static char *get_hugepage_dir(uint64_t hugepage_sz) /* * Analysis of /sys/devices/system/cpu/cpu%d/cpufreq/ files */ -uint64_t odp_cpufreq_id(const char *filename, int id) +static uint64_t read_cpufreq(const char *filename, int id) { char path[256], buffer[256], *endptr = NULL; FILE *file; @@ -343,23 +343,25 @@ int odp_system_info_init(void)
odp_global_data.system_info.page_size = ODP_PAGE_SIZE;
+ /* By default, read max frequency from a cpufreq file */ + for (i = 0; i < CONFIG_NUM_CPU; i++) { + uint64_t cpu_hz_max = read_cpufreq("cpuinfo_max_freq", i); + + if (cpu_hz_max) + odp_global_data.system_info.cpu_hz_max[i] = cpu_hz_max; + } + file = fopen("/proc/cpuinfo", "rt"); if (file == NULL) { ODP_ERR("Failed to open /proc/cpuinfo\n"); return -1; }
+ /* Read CPU model, and set max cpu frequency if not set from cpufreq. */ cpuinfo_parser(file, &odp_global_data.system_info);
fclose(file);
- for (i = 0; i < CONFIG_NUM_CPU; i++) { - uint64_t cpu_hz_max = odp_cpufreq_id("cpuinfo_max_freq", i); - - if (cpu_hz_max) - odp_global_data.system_info.cpu_hz_max[i] = cpu_hz_max; - } - if (systemcpu(&odp_global_data.system_info)) { ODP_ERR("systemcpu failed\n"); return -1; @@ -387,7 +389,7 @@ int odp_system_info_term(void) */ uint64_t odp_cpu_hz_current(int id) { - uint64_t cur_hz = odp_cpufreq_id("cpuinfo_cur_freq", id); + uint64_t cur_hz = read_cpufreq("cpuinfo_cur_freq", id);
if (!cur_hz) cur_hz = odp_cpu_arch_hz_current(id);
commit ce5951842845b519c7887479c8e4e128e1951add Author: Petri Savolainen petri.savolainen@linaro.org Date: Wed Jun 27 16:11:56 2018 +0300
linux-gen: config: increase max number of cpus
Enable testing on a new system that has more than 128 cpus.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h index d47ce55e..14fa4f6c 100644 --- a/platform/linux-generic/include/odp_config_internal.h +++ b/platform/linux-generic/include/odp_config_internal.h @@ -14,7 +14,7 @@ extern "C" { /* * Maximum number of CPUs supported. Maximum CPU ID is CONFIG_NUM_CPU - 1. */ -#define CONFIG_NUM_CPU 128 +#define CONFIG_NUM_CPU 256
/* * Maximum number of pools
commit 808acd63c4ec54af93eb5bbf717d4b591df1d904 Author: Petri Savolainen petri.savolainen@linaro.org Date: Wed Jun 27 15:58:28 2018 +0300
linux-gen: cpu: move num cpu into config header file
Rename and move number of CPUs define into the config header file.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/arch/default/odp_sysinfo_parse.c b/platform/linux-generic/arch/default/odp_sysinfo_parse.c index 49e94029..2c3bf841 100644 --- a/platform/linux-generic/arch/default/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/default/odp_sysinfo_parse.c @@ -15,7 +15,7 @@ int cpuinfo_parser(FILE *file ODP_UNUSED, system_info_t *sysinfo) int i;
ODP_DBG("Warning: use dummy values for freq and model string\n"); - for (i = 0; i < MAX_CPU_NUMBER; i++) { + for (i = 0; i < CONFIG_NUM_CPU; i++) { sysinfo->cpu_hz_max[i] = 1400000000; strcpy(sysinfo->model_str[i], "UNKNOWN"); } diff --git a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c index 339c6749..927cb83f 100644 --- a/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/mips64/odp_sysinfo_parse.c @@ -20,7 +20,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) int id = 0;
strcpy(sysinfo->cpu_arch_str, "mips64"); - while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) { + while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU) { if (!mhz) { pos = strstr(str, "BogoMIPS");
diff --git a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c index 810f3758..daa72c24 100644 --- a/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/powerpc/odp_sysinfo_parse.c @@ -20,7 +20,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) int id = 0;
strcpy(sysinfo->cpu_arch_str, "powerpc"); - while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) { + while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU) { if (!mhz) { pos = strstr(str, "clock");
diff --git a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c index d9f3a82d..f9a21975 100644 --- a/platform/linux-generic/arch/x86/odp_sysinfo_parse.c +++ b/platform/linux-generic/arch/x86/odp_sysinfo_parse.c @@ -19,7 +19,7 @@ int cpuinfo_parser(FILE *file, system_info_t *sysinfo) int id = 0;
strcpy(sysinfo->cpu_arch_str, "x86"); - while (fgets(str, sizeof(str), file) != NULL && id < MAX_CPU_NUMBER) { + while (fgets(str, sizeof(str), file) != NULL && id < CONFIG_NUM_CPU) { pos = strstr(str, "model name"); if (pos) { pos = strchr(str, ':'); diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h index d579381e..d47ce55e 100644 --- a/platform/linux-generic/include/odp_config_internal.h +++ b/platform/linux-generic/include/odp_config_internal.h @@ -11,6 +11,11 @@ extern "C" { #endif
+/* + * Maximum number of CPUs supported. Maximum CPU ID is CONFIG_NUM_CPU - 1. + */ +#define CONFIG_NUM_CPU 128 + /* * Maximum number of pools */ diff --git a/platform/linux-generic/include/odp_global_data.h b/platform/linux-generic/include/odp_global_data.h index a5c2abd1..4a8702a6 100644 --- a/platform/linux-generic/include/odp_global_data.h +++ b/platform/linux-generic/include/odp_global_data.h @@ -17,17 +17,17 @@ extern "C" { #include <pthread.h> #include <stdint.h> #include <libconfig.h> +#include <odp_config_internal.h>
-#define MAX_CPU_NUMBER 128 #define UID_MAXLEN 30
typedef struct { - uint64_t cpu_hz_max[MAX_CPU_NUMBER]; + uint64_t cpu_hz_max[CONFIG_NUM_CPU]; uint64_t page_size; int cache_line_size; int cpu_count; char cpu_arch_str[128]; - char model_str[MAX_CPU_NUMBER][128]; + char model_str[CONFIG_NUM_CPU][128]; } system_info_t;
typedef struct { diff --git a/platform/linux-generic/odp_system_info.c b/platform/linux-generic/odp_system_info.c index 8b2bfc5c..09e184a7 100644 --- a/platform/linux-generic/odp_system_info.c +++ b/platform/linux-generic/odp_system_info.c @@ -353,7 +353,7 @@ int odp_system_info_init(void)
fclose(file);
- for (i = 0; i < MAX_CPU_NUMBER; i++) { + for (i = 0; i < CONFIG_NUM_CPU; i++) { uint64_t cpu_hz_max = odp_cpufreq_id("cpuinfo_max_freq", i);
if (cpu_hz_max) @@ -414,7 +414,7 @@ uint64_t odp_cpu_hz_max(void)
uint64_t odp_cpu_hz_max_id(int id) { - if (id >= 0 && id < MAX_CPU_NUMBER) + if (id >= 0 && id < CONFIG_NUM_CPU) return odp_global_data.system_info.cpu_hz_max[id]; else return 0; @@ -473,7 +473,7 @@ const char *odp_cpu_model_str(void)
const char *odp_cpu_model_str_id(int id) { - if (id >= 0 && id < MAX_CPU_NUMBER) + if (id >= 0 && id < CONFIG_NUM_CPU) return odp_global_data.system_info.model_str[id]; else return NULL;
commit 6b947deb94b45660a5140472565886e9d5f1203f Author: Petri Savolainen petri.savolainen@linaro.org Date: Tue Jun 26 13:37:35 2018 +0300
example: sysinfo: application to print system information
Add new application that simply queries and prints out various system information which is available through ODP APIs. This can be useful e.g. when examining HW or ODP implementation capabilities, when debugging other ODP applications, etc.
Signed-off-by: Petri Savolainen petri.savolainen@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/example/Makefile.am b/example/Makefile.am index 2ea244cf..0e12baf1 100644 --- a/example/Makefile.am +++ b/example/Makefile.am @@ -9,6 +9,7 @@ SUBDIRS = classifier \ l3fwd \ packet \ switch \ + sysinfo \ time \ timer \ traffic_mgmt diff --git a/example/m4/configure.m4 b/example/m4/configure.m4 index 1ce0cb11..cbac0914 100644 --- a/example/m4/configure.m4 +++ b/example/m4/configure.m4 @@ -18,6 +18,7 @@ AC_CONFIG_FILES([example/classifier/Makefile example/l3fwd/Makefile example/packet/Makefile example/switch/Makefile + example/sysinfo/Makefile example/time/Makefile example/timer/Makefile example/traffic_mgmt/Makefile diff --git a/example/sysinfo/.gitignore b/example/sysinfo/.gitignore new file mode 100644 index 00000000..208e8dfc --- /dev/null +++ b/example/sysinfo/.gitignore @@ -0,0 +1,3 @@ +odp_sysinfo +*.log +*.trs diff --git a/example/sysinfo/Makefile.am b/example/sysinfo/Makefile.am new file mode 100644 index 00000000..a8b55b5c --- /dev/null +++ b/example/sysinfo/Makefile.am @@ -0,0 +1,9 @@ +include $(top_srcdir)/example/Makefile.inc + +bin_PROGRAMS = odp_sysinfo + +odp_sysinfo_SOURCES = odp_sysinfo.c + +if test_example +TESTS = odp_sysinfo +endif diff --git a/example/sysinfo/odp_sysinfo.c b/example/sysinfo/odp_sysinfo.c new file mode 100644 index 00000000..e177319b --- /dev/null +++ b/example/sysinfo/odp_sysinfo.c @@ -0,0 +1,293 @@ +/* Copyright (c) 2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <stdio.h> +#include <string.h> +#include <stdint.h> +#include <inttypes.h> + +#include <odp_api.h> + +#define KB 1024 +#define MB (1024 * 1024) +#define MAX_HUGE_PAGES 32 + +static const char *support_level(odp_support_t support) +{ + switch (support) { + case ODP_SUPPORT_NO: return "no"; + case ODP_SUPPORT_YES: return "yes"; + case ODP_SUPPORT_PREFERRED: return "yes, preferred"; + default: return "UNKNOWN"; + } +} + +static void print_cipher_algos(odp_crypto_cipher_algos_t ciphers) +{ + if (ciphers.bit.null) + printf("null "); + if (ciphers.bit.des) + printf("des "); + if (ciphers.bit.trides_cbc) + printf("trides_cbc "); + if (ciphers.bit.aes_cbc) + printf("aes_cbc "); + if (ciphers.bit.aes_ctr) + printf("aes_ctr "); + if (ciphers.bit.aes_gcm) + printf("aes_gcm "); + if (ciphers.bit.aes_ccm) + printf("aes_ccm "); + if (ciphers.bit.chacha20_poly1305) + printf("chacha20_poly1305 "); +} + +static void print_auth_algos(odp_crypto_auth_algos_t auths) +{ + if (auths.bit.null) + printf("null "); + if (auths.bit.md5_hmac) + printf("md5_hmac "); + if (auths.bit.sha1_hmac) + printf("sha1_hmac "); + if (auths.bit.sha256_hmac) + printf("sha256_hmac "); + if (auths.bit.sha384_hmac) + printf("sha384_hmac "); + if (auths.bit.sha512_hmac) + printf("sha512_hmac "); + if (auths.bit.aes_gcm) + printf("aes_gcm "); + if (auths.bit.aes_gmac) + printf("aes_gmac "); + if (auths.bit.aes_ccm) + printf("aes_ccm "); + if (auths.bit.aes_cmac) + printf("aes_cmac "); + if (auths.bit.aes_xcbc_mac) + printf("aes_xcbc_mac "); + if (auths.bit.chacha20_poly1305) + printf("chacha20_poly1305 "); +} + +int main(void) +{ + odp_instance_t inst; + int i, num_hp, num_hp_print; + int num_ava, num_work, num_ctrl; + odp_cpumask_t ava_mask, work_mask, ctrl_mask; + odp_shm_capability_t shm_capa; + odp_pool_capability_t pool_capa; + odp_queue_capability_t queue_capa; + odp_timer_capability_t timer_capa; + odp_crypto_capability_t crypto_capa; + uint64_t huge_page[MAX_HUGE_PAGES]; + char ava_mask_str[ODP_CPUMASK_STR_SIZE]; + char work_mask_str[ODP_CPUMASK_STR_SIZE]; + char ctrl_mask_str[ODP_CPUMASK_STR_SIZE]; + + printf("\n"); + printf("ODP system info example\n"); + printf("***********************************************************\n"); + printf("\n"); + + if (odp_init_global(&inst, NULL, NULL)) { + printf("Global init failed.\n"); + return -1; + } + + if (odp_init_local(inst, ODP_THREAD_CONTROL)) { + printf("Local init failed.\n"); + return -1; + } + + odp_sys_info_print(); + + memset(ava_mask_str, 0, ODP_CPUMASK_STR_SIZE); + num_ava = odp_cpumask_all_available(&ava_mask); + odp_cpumask_to_str(&ava_mask, ava_mask_str, ODP_CPUMASK_STR_SIZE); + + memset(work_mask_str, 0, ODP_CPUMASK_STR_SIZE); + num_work = odp_cpumask_default_worker(&work_mask, 0); + odp_cpumask_to_str(&work_mask, work_mask_str, ODP_CPUMASK_STR_SIZE); + + memset(ctrl_mask_str, 0, ODP_CPUMASK_STR_SIZE); + num_ctrl = odp_cpumask_default_control(&ctrl_mask, 0); + odp_cpumask_to_str(&ctrl_mask, ctrl_mask_str, ODP_CPUMASK_STR_SIZE); + + num_hp = odp_sys_huge_page_size_all(huge_page, MAX_HUGE_PAGES); + + num_hp_print = num_hp; + if (num_hp_print > MAX_HUGE_PAGES) + num_hp_print = MAX_HUGE_PAGES; + + if (odp_shm_capability(&shm_capa)) { + printf("shm capability failed\n"); + return -1; + } + + if (odp_pool_capability(&pool_capa)) { + printf("pool capability failed\n"); + return -1; + } + + if (odp_queue_capability(&queue_capa)) { + printf("queue capability failed\n"); + return -1; + } + + if (odp_timer_capability(ODP_CLOCK_CPU, &timer_capa)) { + printf("timer capability failed\n"); + return -1; + } + + if (odp_crypto_capability(&crypto_capa)) { + printf("crypto capability failed\n"); + return -1; + } + + printf("\n"); + printf("S Y S T E M I N F O R M A T I O N\n"); + printf("***********************************************************\n"); + printf("\n"); + printf(" ODP API version: %s\n", odp_version_api_str()); + printf(" ODP impl name: %s\n", odp_version_impl_name()); + printf(" ODP impl details: %s\n", odp_version_impl_str()); + printf(" CPU model: %s\n", odp_cpu_model_str()); + printf(" CPU max freq: %" PRIu64 " hz\n", odp_cpu_hz_max()); + printf(" Current CPU: %i\n", odp_cpu_id()); + printf(" Current CPU freq: %" PRIu64 " hz\n", odp_cpu_hz()); + printf(" CPU count: %i\n", odp_cpu_count()); + printf(" CPU available num: %i\n", num_ava); + printf(" CPU available mask: %s\n", ava_mask_str); + printf(" CPU worker num: %i\n", num_work); + printf(" CPU worker mask: %s\n", work_mask_str); + printf(" CPU control num: %i\n", num_ctrl); + printf(" CPU control mask: %s\n", ctrl_mask_str); + printf(" Max threads (define): %i\n", ODP_THREAD_COUNT_MAX); + printf(" Max threads: %i\n", odp_thread_count_max()); + printf(" Byte order: %s (%i / %i)\n", + ODP_BYTE_ORDER == ODP_BIG_ENDIAN ? "big" : "little", + ODP_BIG_ENDIAN, ODP_LITTLE_ENDIAN); + printf(" Bitfield order: %s (%i / %i)\n", + ODP_BITFIELD_ORDER == ODP_BIG_ENDIAN_BITFIELD ? + "big" : "little", + ODP_BIG_ENDIAN_BITFIELD, ODP_LITTLE_ENDIAN_BITFIELD); + printf(" Cache line size: %i B\n", odp_sys_cache_line_size()); + printf(" Page size: %" PRIu64 " kB\n", + odp_sys_page_size() / KB); + printf(" Default huge page size: %" PRIu64 " kB\n", + odp_sys_huge_page_size() / KB); + printf(" Num huge page sizes: %i\n", num_hp); + + for (i = 0; i < num_hp_print; i++) + printf(" Huge page size [%i]: %" PRIu64 " kB\n", + i, huge_page[i] / KB); + + printf("\n"); + printf(" SHM\n"); + printf(" max_blocks: %u\n", shm_capa.max_blocks); + printf(" max_size: %" PRIu64 " MB\n", + shm_capa.max_size / MB); + printf(" max_align: %" PRIu64 " B\n", shm_capa.max_align); + + printf("\n"); + printf(" POOL\n"); + printf(" max_pools: %u\n", pool_capa.max_pools); + printf(" buf.max_pools: %u\n", pool_capa.buf.max_pools); + printf(" buf.max_align: %" PRIu32 " B\n", + pool_capa.buf.max_align); + printf(" buf.max_size: %" PRIu32 " kB\n", + pool_capa.buf.max_size / KB); + printf(" buf.max_num: %" PRIu32 "\n", + pool_capa.buf.max_num); + printf(" pkt.max_pools: %u\n", pool_capa.pkt.max_pools); + printf(" pkt.max_len: %" PRIu32 " kB\n", + pool_capa.pkt.max_len / KB); + printf(" pkt.max_num: %" PRIu32 "\n", + pool_capa.pkt.max_num); + printf(" pkt.max_segs: %" PRIu32 "\n", + pool_capa.pkt.max_segs_per_pkt); + printf(" pkt.max_seg_len: %" PRIu32 " B\n", + pool_capa.pkt.max_seg_len); + printf(" pkt.max_uarea: %" PRIu32 " B\n", + pool_capa.pkt.max_uarea_size); + printf(" tmo.max_pools: %u\n", pool_capa.tmo.max_pools); + printf(" tmo.max_num: %" PRIu32 "\n", + pool_capa.tmo.max_num); + + printf("\n"); + printf(" QUEUE\n"); + printf(" max queues: %" PRIu32 "\n", + queue_capa.max_queues); + printf(" plain.max_num: %" PRIu32 "\n", + queue_capa.plain.max_num); + printf(" plain.max_size: %" PRIu32 "\n", + queue_capa.plain.max_size); + printf(" plain.lf.max_num: %" PRIu32 "\n", + queue_capa.plain.lockfree.max_num); + printf(" plain.lf.max_size: %" PRIu32 "\n", + queue_capa.plain.lockfree.max_size); + printf(" plain.wf.max_num: %" PRIu32 "\n", + queue_capa.plain.waitfree.max_num); + printf(" plain.wf.max_size: %" PRIu32 "\n", + queue_capa.plain.waitfree.max_size); + + printf("\n"); + printf(" SCHEDULER\n"); + printf(" max ordered locks: %" PRIu32 "\n", + queue_capa.max_ordered_locks); + printf(" max groups: %u\n", queue_capa.max_sched_groups); + printf(" priorities: %u\n", queue_capa.sched_prios); + printf(" sched.max_num: %" PRIu32 "\n", + queue_capa.sched.max_num); + printf(" sched.max_size: %" PRIu32 "\n", + queue_capa.sched.max_size); + printf(" sched.lf.max_num: %" PRIu32 "\n", + queue_capa.sched.lockfree.max_num); + printf(" sched.lf.max_size: %" PRIu32 "\n", + queue_capa.sched.lockfree.max_size); + printf(" sched.wf.max_num: %" PRIu32 "\n", + queue_capa.sched.waitfree.max_num); + printf(" sched.wf.max_size: %" PRIu32 "\n", + queue_capa.sched.waitfree.max_size); + + printf("\n"); + printf(" TIMER\n"); + printf(" highest resolution: %" PRIu64 " nsec\n", + timer_capa.highest_res_ns); + + printf("\n"); + printf(" CRYPTO\n"); + printf(" max sessions: %" PRIu32 "\n", + crypto_capa.max_sessions); + printf(" sync mode support: %s\n", + support_level(crypto_capa.sync_mode)); + printf(" async mode support: %s\n", + support_level(crypto_capa.async_mode)); + printf(" cipher algorithms: "); + print_cipher_algos(crypto_capa.ciphers); + printf("\n"); + printf(" auth algorithms: "); + print_auth_algos(crypto_capa.auths); + printf("\n"); + + printf("\n"); + printf("***********************************************************\n"); + printf("\n"); + + if (odp_term_local()) { + printf("Local term failed.\n"); + return -1; + } + + if (odp_term_global(inst)) { + printf("Global term failed.\n"); + return -1; + } + + return 0; +}
-----------------------------------------------------------------------
Summary of changes: example/Makefile.am | 1 + example/m4/configure.m4 | 1 + example/{hello => sysinfo}/.gitignore | 2 +- example/sysinfo/Makefile.am | 9 + example/sysinfo/odp_sysinfo.c | 293 +++++++++++++++++++++ platform/linux-generic/Makefile.am | 2 +- .../linux-generic/arch/aarch64/odp_sysinfo_parse.c | 212 +++++++++++++++ .../linux-generic/arch/default/odp_sysinfo_parse.c | 8 +- .../linux-generic/arch/mips64/odp_sysinfo_parse.c | 4 +- .../linux-generic/arch/powerpc/odp_sysinfo_parse.c | 4 +- .../linux-generic/arch/x86/odp_sysinfo_parse.c | 30 ++- .../linux-generic/include/odp_config_internal.h | 5 + platform/linux-generic/include/odp_global_data.h | 7 +- .../linux-generic/include/odp_sysinfo_internal.h | 1 - platform/linux-generic/odp_system_info.c | 24 +- 15 files changed, 569 insertions(+), 34 deletions(-) copy example/{hello => sysinfo}/.gitignore (50%) create mode 100644 example/sysinfo/Makefile.am create mode 100644 example/sysinfo/odp_sysinfo.c create mode 100644 platform/linux-generic/arch/aarch64/odp_sysinfo_parse.c
hooks/post-receive