From patchwork Thu Oct 1 07:08:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1374873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C246k6Fzrz9sVN for ; Thu, 1 Oct 2020 17:11:26 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=Ru/OZZ08; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4C246k39TYzDqTv for ; Thu, 1 Oct 2020 17:11:26 +1000 (AEST) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4C246b37Y4zDqQt for ; Thu, 1 Oct 2020 17:11:19 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=Ru/OZZ08; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4C246X5Nw6z9sVJ; Thu, 1 Oct 2020 17:11:15 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1601536279; bh=hKaTn4RcM8td7y1+jRhoRRLzQBYK4vtQ97sYQ3a4q6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ru/OZZ08mK+3MXWAHDo2aK1URAVEXei9q4G4JYtEYdkScRxtXOuyKSwOVd+i+gNnZ lrV2lGjSJxcGEw7tHxujqBm75MKdZMG/r+mM3b6OQsicuvVB8gk2pj4ZlRVZWIP6rG 9F81H3T6o0vNjkmvcCQqGnAGyok+M5tZMfPqlNiSm3c5EFF1E+ALL6v1UZAYvhkqer tnP9IviTejDfxcjHCn0axncZzW7VtP0gJH8Eb5MLUKZIiP4+GTsvihUBIomTheOSz+ MvLrZoPLB2rWjT5K40OKIas5tOY3tZ/+f0NJUTHJxDyOxG8AXdP9CQx0657YUrOEv1 cnsXR8qp96jmA== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Thu, 1 Oct 2020 17:08:01 +1000 Message-Id: <20201001070814.102735-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201001070814.102735-1-amitay@ozlabs.org> References: <20201001070814.102735-1-amitay@ozlabs.org> MIME-Version: 1.0 Subject: [Pdbg] [PATCH v2 07/20] tests: Add fapi p10 address translation tests X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" From: Alistair Popple Signed-off-by: Alistair Popple Reviewed-by: Joel Stanley --- 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 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 +#include + +#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 \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; +}