Add option to use RdEndpointConfig for PCIe reads
The current solution uses RdPCIConfig command which is expected
to be replaced by RdEndpointConfig in the future. This change
adds an option to switch to the RdEndpointConfig command for
PCIe reads.
Tested:
Compared the PCIe device list in Redfish with both RdPCIConfig
and RdEndpointConfig and they match.
Change-Id: Ibff549d43e8d49c757f618ea2fa481324ece6872
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c3f0d6..c1718df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,8 +12,15 @@
OFF
)
+option (
+ USE_RDENDPOINTCFG
+ "Use the RdEndpointConfig PECI command to read PCI data"
+ OFF
+)
+
target_compile_definitions (
peci-pcie PRIVATE $<$<BOOL:${WAIT_FOR_OS_STANDBY}>: -DWAIT_FOR_OS_STANDBY>
+ peci-pcie PRIVATE $<$<BOOL:${USE_RDENDPOINTCFG}>: -DUSE_RDENDPOINTCFG>
)
option (YOCTO "Enable Building in Yocto" OFF)
diff --git a/src/peci_pcie.cpp b/src/peci_pcie.cpp
index 9182ea5..8b942aa 100644
--- a/src/peci_pcie.cpp
+++ b/src/peci_pcie.cpp
@@ -171,6 +171,17 @@
int ret = PECI_CC_TIMEOUT;
for (int index = 0; (index < 5) && (ret == PECI_CC_TIMEOUT); index++)
{
+#ifdef USE_RDENDPOINTCFG
+ ret = peci_RdEndPointConfigPci(clientAddr, // CPU Address
+ 0, // PCI Seg (use 0 for now)
+ bus, // PCI Bus
+ dev, // PCI Device
+ func, // PCI Function
+ pciOffset, // PCI Offset
+ pciReadSize, // PCI Read Size
+ data.data(), // PCI Read Data
+ &cc); // PECI Completion Code
+#else
ret = peci_RdPCIConfig(clientAddr, // CPU Address
bus, // PCI Bus
dev, // PCI Device
@@ -178,6 +189,7 @@
pciOffset, // PCI Offset
data.data(), // PCI Read Data
&cc); // PECI Completion Code
+#endif
}
if (ret != PECI_CC_SUCCESS || cc != PECI_DEV_CC_SUCCESS)
{