refactor(lib/pcie): rename macro CHECK_DA_SUPPORT_IN_RMI
Rename macro CHECK_DA_SUPPORT_IN_RMI to SKIP_DA_TEST_IF_PREREQS_NOT_MET
and move it to host_da_helper.h
Signed-off-by: Arunachalam Ganapathy <arunachalam.ganapathy@arm.com>
Change-Id: Ie955e1dcb2edefa0f41edfc36b4b2587cb465a29
diff --git a/include/lib/pcie/pcie_doe.h b/include/lib/pcie/pcie_doe.h
index 777309a..2d9016d 100644
--- a/include/lib/pcie/pcie_doe.h
+++ b/include/lib/pcie/pcie_doe.h
@@ -91,23 +91,6 @@
uint8_t next_index;
} pcie_doe_disc_resp_t;
-/* Skip test if DA is not supported in RMI features */
-#define CHECK_DA_SUPPORT_IN_RMI(_reg0) \
- do { \
- SKIP_TEST_IF_RME_NOT_SUPPORTED_OR_RMM_IS_TRP(); \
- /* Get feature register0 */ \
- if (host_rmi_features(0UL, &_reg0) != REALM_SUCCESS) { \
- ERROR("Failed to get RMI feat_reg0\n"); \
- return TEST_RESULT_FAIL; \
- } \
- \
- /* DA not supported in RMI features? */ \
- if ((_reg0 & RMI_FEATURE_REGISTER_0_DA_EN) == 0UL) { \
- WARN("DA not in RMI features, skipping\n"); \
- return TEST_RESULT_SKIPPED; \
- } \
- } while (false)
-
#define SKIP_TEST_IF_DOE_NOT_SUPPORTED(_bdf, _doe_cap_base) \
do { \
/* Test PCIe DOE only for RME */ \
diff --git a/include/runtime_services/host_realm_managment/host_da_helper.h b/include/runtime_services/host_realm_managment/host_da_helper.h
index 0f6bf6a..e60948d 100644
--- a/include/runtime_services/host_realm_managment/host_da_helper.h
+++ b/include/runtime_services/host_realm_managment/host_da_helper.h
@@ -9,6 +9,29 @@
#include <host_realm_rmi.h>
+/*
+ * Skip DA test if any of the below check is true
+ * RMM is TRP
+ * FEAT_RME not supported
+ * DA is not supported in RMI features
+ */
+#define SKIP_DA_TEST_IF_PREREQS_NOT_MET(_reg0) \
+ do { \
+ SKIP_TEST_IF_RME_NOT_SUPPORTED_OR_RMM_IS_TRP(); \
+ \
+ /* Get feature register0 */ \
+ if (host_rmi_features(0UL, &_reg0) != REALM_SUCCESS) { \
+ ERROR("Failed to get RMI feat_reg0\n"); \
+ return TEST_RESULT_FAIL; \
+ } \
+ \
+ /* DA not supported in RMI features? */ \
+ if ((_reg0 & RMI_FEATURE_REGISTER_0_DA_EN) == 0UL) { \
+ WARN("DA not in RMI features, skipping\n"); \
+ return TEST_RESULT_SKIPPED; \
+ } \
+ } while (false)
+
/* SPDM_MAX_CERTIFICATE_CHAIN_SIZE is 64KB */
#define HOST_PDEV_CERT_LEN_MAX (64 * 1024)
diff --git a/lib/pcie/pcie_doe.c b/lib/pcie/pcie_doe.c
index bd8e53a..e1d6449 100644
--- a/lib/pcie/pcie_doe.c
+++ b/lib/pcie/pcie_doe.c
@@ -13,6 +13,7 @@
#include <debug.h>
#include <pcie.h>
+#include <pcie_spec.h>
#include <pcie_doe.h>
#include <tftf_lib.h>
@@ -241,10 +242,12 @@
return rc;
}
+/* TODO: add an iterator interface to get next eligible device */
int pcie_find_doe_device(uint32_t *bdf_ptr, uint32_t *cap_base_ptr)
{
pcie_device_bdf_table_t *bdf_table_ptr = pcie_get_bdf_table();
uint32_t num_bdf = bdf_table_ptr->num_entries;
+ pcie_dev_t *dev;
INFO("PCI BDF table entries: %u\n", num_bdf);
@@ -257,15 +260,13 @@
INFO("PCI BDF table 0x%lx\n", (uintptr_t)bdf_table_ptr);
while (num_bdf-- != 0) {
- uint32_t bdf = bdf_table_ptr->device[num_bdf].bdf;
- uint32_t status, doe_cap_base;
+ dev = &bdf_table_ptr->device[num_bdf];
- /* Check for DOE capability */
- status = pcie_find_capability(bdf, PCIE_ECAP, DOE_CAP_ID, &doe_cap_base);
- if (status == PCIE_SUCCESS) {
- INFO("PCIe DOE capability: bdf 0x%x cap_base 0x%x\n", bdf, doe_cap_base);
- *bdf_ptr = bdf;
- *cap_base_ptr = doe_cap_base;
+ if ((dev->dp_type == EP) && (pcie_dev_has_doe(dev))) {
+ INFO("PCIe DOE capability: bdf 0x%x cap_base 0x%x\n",
+ dev->bdf, dev->doe_cap_base);
+ *bdf_ptr = dev->bdf;
+ *cap_base_ptr = dev->doe_cap_base;
return 0;
}
}
diff --git a/tftf/tests/runtime_services/host_realm_managment/host_rmi_da_flow.c b/tftf/tests/runtime_services/host_realm_managment/host_rmi_da_flow.c
index f110e10..96f79a7 100644
--- a/tftf/tests/runtime_services/host_realm_managment/host_rmi_da_flow.c
+++ b/tftf/tests/runtime_services/host_realm_managment/host_rmi_da_flow.c
@@ -49,7 +49,7 @@
struct realm realm;
test_result_t result = TEST_RESULT_FAIL;
- CHECK_DA_SUPPORT_IN_RMI(rmi_feat_reg0);
+ SKIP_DA_TEST_IF_PREREQS_NOT_MET(rmi_feat_reg0);
SKIP_TEST_IF_DOE_NOT_SUPPORTED(pdev_bdf, doe_cap_base);
INFO("DA on bdf: 0x%x, doe_cap_base: 0x%x\n", pdev_bdf, doe_cap_base);
diff --git a/tftf/tests/runtime_services/host_realm_managment/rmi_dev_delegate_tests.c b/tftf/tests/runtime_services/host_realm_managment/rmi_dev_delegate_tests.c
index 554029c..ae81946 100644
--- a/tftf/tests/runtime_services/host_realm_managment/rmi_dev_delegate_tests.c
+++ b/tftf/tests/runtime_services/host_realm_managment/rmi_dev_delegate_tests.c
@@ -8,10 +8,10 @@
#include <arch_features.h>
#include <common_def.h>
+#include <host_da_helper.h>
#include <host_realm_helper.h>
#include <host_realm_mem_layout.h>
#include <host_shared_data.h>
-#include <pcie_doe.h>
#include <plat_topology.h>
#include <platform.h>
#include <power_management.h>
@@ -90,7 +90,7 @@
u_register_t rmi_feat_reg0;
unsigned int num_reg = 0U;
- CHECK_DA_SUPPORT_IN_RMI(rmi_feat_reg0);
+ SKIP_DA_TEST_IF_PREREQS_NOT_MET(rmi_feat_reg0);
host_rmi_init_cmp_result();
@@ -147,7 +147,7 @@
u_register_t rmi_feat_reg0, lead_mpid;
unsigned int num_reg = 0U;
- CHECK_DA_SUPPORT_IN_RMI(rmi_feat_reg0);
+ SKIP_DA_TEST_IF_PREREQS_NOT_MET(rmi_feat_reg0);
lead_mpid = read_mpidr_el1() & MPID_MASK;
@@ -275,7 +275,7 @@
u_register_t rmi_feat_reg0;
unsigned int num_reg = 0U;
- CHECK_DA_SUPPORT_IN_RMI(rmi_feat_reg0);
+ SKIP_DA_TEST_IF_PREREQS_NOT_MET(rmi_feat_reg0);
host_rmi_init_cmp_result();
diff --git a/tftf/tests/runtime_services/host_realm_managment/rmi_dev_mem_map_tests.c b/tftf/tests/runtime_services/host_realm_managment/rmi_dev_mem_map_tests.c
index f55a1c9..1a28d4f 100644
--- a/tftf/tests/runtime_services/host_realm_managment/rmi_dev_mem_map_tests.c
+++ b/tftf/tests/runtime_services/host_realm_managment/rmi_dev_mem_map_tests.c
@@ -12,7 +12,6 @@
#include <host_realm_helper.h>
#include <host_realm_mem_layout.h>
#include <host_shared_data.h>
-#include <pcie_doe.h>
#include <plat_topology.h>
#include <platform.h>
#include <test_helpers.h>
@@ -77,7 +76,7 @@
unsigned int num[NUM_INFO_TESTS];
unsigned int num_reg, offset, i, j;
- CHECK_DA_SUPPORT_IN_RMI(rmi_features);
+ SKIP_DA_TEST_IF_PREREQS_NOT_MET(rmi_features);
/* Initialise memory test structures */