From patchwork Tue Dec 26 08:09:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Hu X-Patchwork-Id: 1880205 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=fwts-devel-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SznXJ4mFFz1ydb for ; Tue, 26 Dec 2023 19:10:56 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1rI2WX-0000tK-TH; Tue, 26 Dec 2023 08:10:50 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1rI2VB-0000Xw-D3 for fwts-devel@lists.ubuntu.com; Tue, 26 Dec 2023 08:09:26 +0000 Received: from canonical.com (unknown [10.101.194.164]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPSA id 7DD213F6CD for ; Tue, 26 Dec 2023 08:09:24 +0000 (UTC) From: Ivan Hu To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] acpi: srat: add new Generic Port structure for srat tests (mantis 2236) Date: Tue, 26 Dec 2023 16:09:19 +0800 Message-Id: <20231226080920.115233-1-ivan.hu@canonical.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: fwts-devel-bounces@lists.ubuntu.com Sender: "fwts-devel" BugLink: https://bugs.launchpad.net/fwts/+bug/2047212 The new structure(Generic Port Structure 6) was add in ACPI 6.5 Signed-off-by: Ivan Hu --- src/acpi/srat/srat.c | 67 +++++++++++++++++++++++++++++++++++++ src/lib/include/fwts_acpi.h | 11 ++++++ 2 files changed, 78 insertions(+) diff --git a/src/acpi/srat/srat.c b/src/acpi/srat/srat.c index 848d0bf6..7c98bed5 100644 --- a/src/acpi/srat/srat.c +++ b/src/acpi/srat/srat.c @@ -337,6 +337,70 @@ done: *data += sizeof(fwts_acpi_table_initiator_affinity); } +static void srat_check_port_affinity( + fwts_framework *fw, + ssize_t *length, + uint8_t **data, + bool *passed) +{ + uint32_t h_reserved = 0; + + fwts_acpi_table_port_affinity *affinity = + (fwts_acpi_table_port_affinity *)*data; + + if ((ssize_t)sizeof(fwts_acpi_table_port_affinity) > *length) { + fwts_failed(fw, LOG_LEVEL_MEDIUM, + "SRATPortAffinityShort", + "SRAT Port Affinity structure too short, got " + "%zu bytes, expecting %zu bytes", + *length, sizeof(fwts_acpi_table_port_affinity)); + *passed = false; + goto done; + } + + if (!fwts_acpi_structure_length(fw, "SRAT", affinity->type, + affinity->length, sizeof(fwts_acpi_table_port_affinity))) { + *passed = false; + goto done; + } + + fwts_log_info_verbatim(fw, "SRAT Port Affinity Structure:"); + fwts_log_info_simp_int(fw, " Type: ", affinity->type); + fwts_log_info_simp_int(fw, " Length: ", affinity->length); + fwts_log_info_simp_int(fw, " Reserved: ", affinity->reserved1); + fwts_log_info_simp_int(fw, " Device Handle Type: ", affinity->device_handle_type); + fwts_log_info_simp_int(fw, " Proximity Domain: ", affinity->proximity_domain); + + fwts_acpi_reserved_zero("SRAT", "Port Affinity Reserved", affinity->reserved1, passed); + fwts_acpi_reserved_bits("SRAT", "Port Affinity Device Handle Type", affinity->device_handle_type, 1, 7, passed); + + fwts_log_info_verbatim(fw, " Device Handle:"); + if (affinity->device_handle_type == 0) { + fwts_log_info_simp_int(fw, " ACPI _HID: ", *(uint64_t *)(affinity->device_handle)); + fwts_log_info_simp_int(fw, " ACPI _UID: ", *(uint32_t *)(affinity->device_handle + 8)); + h_reserved = *(uint32_t *)(affinity->device_handle + 12); + fwts_log_info_simp_int(fw, " Reserved: ", *(uint32_t *)(affinity->device_handle + 12)); + fwts_acpi_reserved_zero("SRAT", "Port Affinity Device Handle Reserved", h_reserved, passed); + } else if (affinity->device_handle_type == 1) { + fwts_log_info_simp_int(fw, " PCI Segment: ", *(uint16_t *)(affinity->device_handle)); + fwts_log_info_simp_int(fw, " PCI BDF Number: ", *(uint16_t *)(affinity->device_handle + 2)); + fwts_log_info_verbatim(fw, " Reserved:"); + fwts_hexdump_data_prefix_all(fw, affinity->device_handle + 4, " ", 12); + fwts_acpi_reserved_zero_array(fw, "SRAT", " Port Affinity Device Handle Reserved", affinity->device_handle + 4, 12, passed); + } + fwts_log_info_simp_int(fw, " Flags: ", affinity->flags); + fwts_log_info_simp_int(fw, " Reserved: ", affinity->reserved2); + fwts_log_nl(fw); + + fwts_acpi_reserved_bits("SRAT", "Port Affinity Flags", affinity->flags, 2, 31, passed); + fwts_acpi_reserved_zero("SRAT", "Port Affinity Reserved", affinity->reserved2, passed); + +done: + *length -= sizeof(fwts_acpi_table_port_affinity); + *data += sizeof(fwts_acpi_table_port_affinity); +} + + /* * See ACPI 6.0, Section 5.2.16 */ @@ -372,6 +436,9 @@ static int srat_test1(fwts_framework *fw) case 0x05: srat_check_initiator_affinity(fw, &length, &data, &passed); break; + case 0x06: + srat_check_port_affinity(fw, &length, &data, &passed); + break; default: fwts_failed(fw, LOG_LEVEL_HIGH, "SRATInvalidType", diff --git a/src/lib/include/fwts_acpi.h b/src/lib/include/fwts_acpi.h index b4671b06..6b8ecefa 100644 --- a/src/lib/include/fwts_acpi.h +++ b/src/lib/include/fwts_acpi.h @@ -447,6 +447,17 @@ typedef struct { uint32_t reserved2; } __attribute__ ((packed)) fwts_acpi_table_initiator_affinity; +typedef struct { + uint8_t type; + uint8_t length; + uint8_t reserved1; + uint8_t device_handle_type; + uint32_t proximity_domain; + uint8_t device_handle[16]; + uint32_t flags; + uint32_t reserved2; +} __attribute__ ((packed)) fwts_acpi_table_port_affinity; + /* * ACPI HPET (HPET IA-PC High Precision Event Timer Table), * 3.2.4 The ACPI 2.0 HPET Description Table (HPET)