@@ -7,5 +7,6 @@ sources += files(
'rte_cpuflags.c',
'rte_cycles.c',
'rte_hypervisor.c',
+ 'rte_mmu.c',
'rte_power_intrinsics.c',
)
new file mode 100644
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+ return true;
+}
@@ -93,6 +93,13 @@ int rte_eal_memzone_init(void);
*/
int rte_eal_cpu_init(void);
+/**
+ * Check for architecture supported MMU.
+ *
+ * This function is private to EAL.
+ */
+bool eal_mmu_supported(void);
+
/**
* Create memseg lists
*
@@ -597,6 +597,13 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ /* verify if DPDK supported on architecture MMU */
+ if (!eal_mmu_supported()) {
+ rte_eal_init_alert("unsupported MMU type.");
+ rte_errno = ENOTSUP;
+ return -1;
+ }
+
if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
rte_memory_order_relaxed, rte_memory_order_relaxed)) {
rte_eal_init_alert("already called initialization.");
@@ -983,6 +983,13 @@ rte_eal_init(int argc, char **argv)
return -1;
}
+ /* verify if DPDK supported on architecture MMU */
+ if (!eal_mmu_supported()) {
+ rte_eal_init_alert("unsupported MMU type.");
+ rte_errno = ENOTSUP;
+ return -1;
+ }
+
if (!rte_atomic_compare_exchange_strong_explicit(&run_once, &has_run, 1,
rte_memory_order_relaxed, rte_memory_order_relaxed)) {
rte_eal_init_alert("already called initialization.");
@@ -7,5 +7,6 @@ sources += files(
'rte_cpuflags.c',
'rte_cycles.c',
'rte_hypervisor.c',
+ 'rte_mmu.c',
'rte_power_intrinsics.c',
)
new file mode 100644
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+ return true;
+}
@@ -7,5 +7,6 @@ sources += files(
'rte_cpuflags.c',
'rte_cycles.c',
'rte_hypervisor.c',
+ 'rte_mmu.c',
'rte_power_intrinsics.c',
)
new file mode 100644
@@ -0,0 +1,68 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "stdio.h"
+#include "string.h"
+#include "rte_log.h"
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+#ifdef RTE_EXEC_ENV_LINUX
+ static const char proc_cpuinfo[] = "/proc/cpuinfo";
+ static const char str_mmu[] = "MMU";
+ static const char str_radix[] = "Radix";
+ static const char err_msg[] = "DPDK on PPC64 requires radix-mmu";
+ char buf[512];
+ char *ret = NULL;
+ FILE *f = fopen(proc_cpuinfo, "r");
+
+ if (f == NULL) {
+ RTE_LOG(ERR, EAL, "Cannot open %s\n", proc_cpuinfo);
+ return false;
+ }
+
+ /*
+ * Example "MMU" in /proc/cpuinfo:
+ * ...
+ * model : 8335-GTW
+ * machine : PowerNV 8335-GTW
+ * firmware : OPAL
+ * MMU : Radix
+ * ... or ...
+ * model : IBM,9009-22A
+ * machine : CHRP IBM,9009-22A
+ * MMU : Hash
+ */
+ while (fgets(buf, sizeof(buf), f) != NULL) {
+ ret = strstr(buf, str_mmu);
+ if (ret == NULL)
+ continue;
+ ret += sizeof(str_mmu) - 1;
+ ret = strchr(ret, ':');
+ if (ret == NULL)
+ continue;
+ ret = strstr(ret, str_radix);
+ break;
+ }
+ fclose(f);
+
+ if (ret == NULL) {
+ fprintf(stderr, "EAL: FATAL: %s\n", err_msg);
+ RTE_LOG(ERR, EAL, "%s\n", err_msg);
+ }
+ return (ret != NULL);
+#elif RTE_EXEC_ENV_FREEBSD
+ /*
+ * Method to detect MMU type in FreeBSD not known
+ * by this author. Return true for now to emulate
+ * previous behavior and avoid unnecessary failures.
+ */
+ return true;
+#else
+ /* Force false for other execution environments */
+ return false;
+#endif
+}
@@ -7,5 +7,6 @@ sources += files(
'rte_cpuflags.c',
'rte_cycles.c',
'rte_hypervisor.c',
+ 'rte_mmu.c',
'rte_power_intrinsics.c',
)
new file mode 100644
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+ return true;
+}
@@ -7,6 +7,7 @@ sources += files(
'rte_cpuflags.c',
'rte_cycles.c',
'rte_hypervisor.c',
+ 'rte_mmu.c',
'rte_spinlock.c',
'rte_power_intrinsics.c',
)
new file mode 100644
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright (C) IBM Corporation 2023
+ */
+
+#include "eal_private.h"
+
+bool
+eal_mmu_supported(void)
+{
+ return true;
+}