diff mbox series

[v2,07/20] tests: Add fapi p10 address translation tests

Message ID 20201001070814.102735-8-amitay@ozlabs.org
State Accepted
Headers show
Series Add p10 support to libpdbg | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning Failed to apply on branch master (9fbe2a8b236967e0b2088dfa85a8e3d23ff01413)
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Amitay Isaacs Oct. 1, 2020, 7:08 a.m. UTC
From: Alistair Popple <alistair@popple.id.au>

Signed-off-by: Alistair Popple <alistair@popple.id.au>
---
 Makefile.am                                   |   7 ++
 src/tests/libpdbg_p10_fapi_translation_test.C | 113 ++++++++++++++++++
 2 files changed, 120 insertions(+)
 create mode 100644 src/tests/libpdbg_p10_fapi_translation_test.C

Comments

Joel Stanley Oct. 7, 2020, 11:46 a.m. UTC | #1
On Thu, 1 Oct 2020 at 07:11, Amitay Isaacs <amitay@ozlabs.org> wrote:

> +++ b/src/tests/libpdbg_p10_fapi_translation_test.C
> @@ -0,0 +1,113 @@
> +#include <stdio.h>
> +#include <inttypes.h>
> +
> +#define class klass
> +#include "libpdbg/libpdbg.h"
> +#include "libpdbg/hwunit.h"
> +#include "libpdbg/target.h"
> +#undef class
> +
> +#include "p10_scominfo.H"
> +
> +#define MAX_INDEX 30
> +
> +int test_unit_translation(struct pdbg_target *target, p10ChipUnits_t cu, int index, uint64_t addr)
> +{
> +       uint64_t pdbg_addr, fapi_addr;
> +
> +       target->index = index;
> +
> +       /* TODO: Check standard chiplet translation */
> +       if (!target->translate)
> +               return 1;

Is this still a TODO?

Reviewed-by: Joel Stanley <joel@jms.id.au>



> +
> +       if (validateChipUnitNum(index, cu))
> +               return 1;
> +
Amitay Isaacs Oct. 8, 2020, 7:52 a.m. UTC | #2
On Wed, 2020-10-07 at 11:46 +0000, Joel Stanley wrote:
> On Thu, 1 Oct 2020 at 07:11, Amitay Isaacs <amitay@ozlabs.org> wrote:
> 
> > +++ b/src/tests/libpdbg_p10_fapi_translation_test.C
> > @@ -0,0 +1,113 @@
> > +#include <stdio.h>
> > +#include <inttypes.h>
> > +
> > +#define class klass
> > +#include "libpdbg/libpdbg.h"
> > +#include "libpdbg/hwunit.h"
> > +#include "libpdbg/target.h"
> > +#undef class
> > +
> > +#include "p10_scominfo.H"
> > +
> > +#define MAX_INDEX 30
> > +
> > +int test_unit_translation(struct pdbg_target *target,
> > p10ChipUnits_t cu, int index, uint64_t addr)
> > +{
> > +       uint64_t pdbg_addr, fapi_addr;
> > +
> > +       target->index = index;
> > +
> > +       /* TODO: Check standard chiplet translation */
> > +       if (!target->translate)
> > +               return 1;
> 
> Is this still a TODO?

Yes.  I need to fix that for both P9 and P10.  However, the main reason
for these tests is to confirm the special translation required for some
of the hardware units is correct.

> 
> Reviewed-by: Joel Stanley <joel@jms.id.au>
> 
> 
> 
> > +
> > +       if (validateChipUnitNum(index, cu))
> > +               return 1;
> > +

Amitay.
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index 779c52c..ceeadb9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -16,6 +16,7 @@  libpdbg_tests = libpdbg_target_test \
 bin_PROGRAMS = pdbg
 check_PROGRAMS = $(libpdbg_tests) libpdbg_dtree_test \
 		libpdbg_p9_fapi_translation_test \
+		libpdbg_p10_fapi_translation_test \
 		optcmd_test hexdump_test cronus_proxy \
 		libpdbg_prop_test libpdbg_attr_test \
 		libpdbg_traverse_test
@@ -252,6 +253,12 @@  libpdbg_p9_fapi_translation_test_CXXFLAGS = $(libpdbg_test_cflags)
 libpdbg_p9_fapi_translation_test_LDFLAGS = $(libpdbg_test_ldflags)
 libpdbg_p9_fapi_translation_test_LDADD = $(libpdbg_test_ldadd)
 
+libpdbg_p10_fapi_translation_test_SOURCES = src/tests/libpdbg_p10_fapi_translation_test.C \
+					   src/tests/p10_scominfo.C src/tests/p10_scom_addr.C
+libpdbg_p10_fapi_translation_test_CXXFLAGS = $(libpdbg_test_cflags)
+libpdbg_p10_fapi_translation_test_LDFLAGS = $(libpdbg_test_ldflags)
+libpdbg_p10_fapi_translation_test_LDADD = $(libpdbg_test_ldadd)
+
 libpdbg_prop_test_SOURCES = src/tests/libpdbg_prop_test.c
 libpdbg_prop_test_CFLAGS = $(libpdbg_test_cflags)
 libpdbg_prop_test_LDFLAGS = $(libpdbg_test_ldflags)
diff --git a/src/tests/libpdbg_p10_fapi_translation_test.C b/src/tests/libpdbg_p10_fapi_translation_test.C
new file mode 100644
index 0000000..eb6db73
--- /dev/null
+++ b/src/tests/libpdbg_p10_fapi_translation_test.C
@@ -0,0 +1,113 @@ 
+#include <stdio.h>
+#include <inttypes.h>
+
+#define class klass
+#include "libpdbg/libpdbg.h"
+#include "libpdbg/hwunit.h"
+#include "libpdbg/target.h"
+#undef class
+
+#include "p10_scominfo.H"
+
+#define MAX_INDEX 30
+
+int test_unit_translation(struct pdbg_target *target, p10ChipUnits_t cu, int index, uint64_t addr)
+{
+	uint64_t pdbg_addr, fapi_addr;
+
+	target->index = index;
+
+	/* TODO: Check standard chiplet translation */
+	if (!target->translate)
+		return 1;
+
+	if (validateChipUnitNum(index, cu))
+		return 1;
+
+	pdbg_addr = target->translate(target, addr);
+	fapi_addr = p10_scominfo_createChipUnitScomAddr(cu, 0x10, index, addr, 0);
+
+	/* Ignore bad addresses. We should really test that we get an assert error
+	 * from the translation code though. */
+	if (fapi_addr == FAILED_TRANSLATION)
+		return 1;
+
+	if (pdbg_addr != fapi_addr)
+		fprintf(stderr,
+			"PDBG Address 0x%016" PRIx64 " does not match FAPI Address 0x%016" PRIx64
+			" for address 0x%016" PRIx64 " on target %s@%d\n",
+			pdbg_addr, fapi_addr, addr, pdbg_target_path(target), index);
+
+	return pdbg_addr == fapi_addr;
+}
+
+static struct chip_unit {
+	p10ChipUnits_t cu;
+	const char *classname;
+} chip_unit[] = {
+	{ PU_C_CHIPUNIT, "core" },
+	{ PU_EQ_CHIPUNIT, "eq" },
+	{ PU_PEC_CHIPUNIT, "pec" },
+	{ PU_PHB_CHIPUNIT, "phb" },
+	{ PU_MI_CHIPUNIT, "mi" },
+	{ PU_MCC_CHIPUNIT, "mcc" },
+	{ PU_OMIC_CHIPUNIT, "omic" },
+	{ PU_OMI_CHIPUNIT, "omi" },
+	{ PU_PERV_CHIPUNIT, "chiplet" },
+	{ PU_MC_CHIPUNIT, "mc" },
+	{ PU_NMMU_CHIPUNIT, "nmmu" },
+	{ PU_IOHS_CHIPUNIT, "iohs" },
+	{ PU_PAU_CHIPUNIT, "pau" },
+	{ PU_PAUC_CHIPUNIT, "pauc" },
+	{ NONE, NULL },
+};
+
+int main(int argc, const char **argv)
+{
+	struct pdbg_target *target;
+	p10ChipUnits_t cu = NONE;
+	int i, count=0;
+
+	if (argc != 2) {
+		fprintf(stderr, "Usage: %s <class>\n", argv[0]);
+		return 1;
+	}
+
+	// pdbg_set_loglevel(PDBG_DEBUG);
+
+	pdbg_targets_init(NULL);
+
+	for (i=0; chip_unit[i].classname; i++) {
+		if (!strcmp(argv[1], chip_unit[i].classname)) {
+			cu = chip_unit[i].cu;
+		}
+	}
+
+	if (cu == NONE) {
+		fprintf(stderr, "Unknown class '%s'\n", argv[1]);
+		return 1;
+	}
+
+	pdbg_for_each_class_target(argv[1], target) {
+		uint64_t addr;
+		int index = pdbg_target_index(target);
+
+		/*  We only need to test targets on proc0, translation won't change for
+		 *  other procs */
+		if (pdbg_target_index(pdbg_target_parent("proc", target)))
+			continue;
+
+		printf("Testing %s  %d\n", pdbg_target_path(target), index);
+		/* Test every sat offset */
+		for (addr = 0; addr < 0xffffffff; addr += 0x40)
+			assert(test_unit_translation(target, cu, index, addr));
+
+		count++;
+	}
+
+	if (count == 0) {
+		printf("Test skipped for class '%s'\n", argv[1]);
+	}
+
+	return 0;
+}