summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Aladyshev <aladyshev22@gmail.com>2023-07-04 16:30:10 +0300
committerKonstantin Aladyshev <aladyshev22@gmail.com>2023-07-11 18:31:59 +0300
commit814bf20a383c891931b9f68b2d49c6b52318603d (patch)
tree10e9e93343ee5cf7a8a31f44e2af5f5dee61b081
parent82f80326afb1e1cfd6b682d4fa2f75319c83004f (diff)
downloadbmcweb-814bf20a383c891931b9f68b2d49c6b52318603d.tar.xz
Add MaxLanes and MaxPCIeType properties to the PCIeInterface
According to the Redfish Data Model specification PCIeInterface (v1.3+) of the PCIeDevice model contains the following properties: MaxLanes (v1.3+) The number of PCIe lanes supported by this device. - This property shall contain the maximum number of PCIe lanes supported by this device. MaxPCIeType (v1.3+) The highest version of the PCIe specification supported by this device. - This property shall contain the maximum PCIe specification that this device supports. Since PCIeDevice interface from the phosphor-dbus-interfaces has these values in the 'MaxLanes' and 'GenerationSupported' properties, populate the fields to Redfish. Tested: Redfish validator passed Before: redfish/v1/Systems/system/PCIeDevices/Bus_c3_Device_00 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/Bus_c3_Device_00", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", ... "PCIeInterface": { "LanesInUse": 4, "PCIeType": "Gen3" }, ... } After: redfish/v1/Systems/system/PCIeDevices/Bus_c3_Device_00 { "@odata.id": "/redfish/v1/Systems/system/PCIeDevices/Bus_c3_Device_00", "@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice", ... "PCIeInterface": { "LanesInUse": 4, "MaxLanes": 4, "MaxPCIeType": "Gen3", "PCIeType": "Gen3" }, ... } Change-Id: Iec786e376cea8fd2aa516b5b2a3da4286e59627a Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
-rw-r--r--Redfish.md2
-rw-r--r--redfish-core/lib/pcie.hpp36
2 files changed, 36 insertions, 2 deletions
diff --git a/Redfish.md b/Redfish.md
index a7b3445d82..f2fb141916 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -861,6 +861,8 @@ other.
- PCIeInterface
- DeviceType
- LanesInUse
+ - MaxLanes
+ - MaxPCIeType
- PCIeType
- SerialNumber
- Slot
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index f5c5303554..195ec8727a 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -418,12 +418,14 @@ inline void addPCIeDeviceProperties(
{
const std::string* deviceType = nullptr;
const std::string* generationInUse = nullptr;
+ const std::string* generationSupported = nullptr;
const size_t* lanesInUse = nullptr;
+ const size_t* maxLanes = nullptr;
const bool success = sdbusplus::unpackPropertiesNoThrow(
dbus_utils::UnpackErrorPrinter(), pcieDevProperties, "DeviceType",
- deviceType, "GenerationInUse", generationInUse, "LanesInUse",
- lanesInUse);
+ deviceType, "GenerationInUse", generationInUse, "GenerationSupported",
+ generationSupported, "LanesInUse", lanesInUse, "MaxLanes", maxLanes);
if (!success)
{
@@ -460,12 +462,42 @@ inline void addPCIeDeviceProperties(
}
}
+ if (generationSupported != nullptr)
+ {
+ std::optional<pcie_device::PCIeTypes> redfishGenerationSupported =
+ pcie_util::redfishPcieGenerationFromDbus(*generationSupported);
+
+ if (!redfishGenerationSupported)
+ {
+ BMCWEB_LOG_WARNING << "Unknown PCIe Device Generation: "
+ << *generationSupported;
+ }
+ else
+ {
+ if (*redfishGenerationSupported == pcie_device::PCIeTypes::Invalid)
+ {
+ BMCWEB_LOG_ERROR << "Invalid PCIe Device Generation: "
+ << *generationSupported;
+ messages::internalError(asyncResp->res);
+ return;
+ }
+ asyncResp->res.jsonValue["PCIeInterface"]["MaxPCIeType"] =
+ *redfishGenerationSupported;
+ }
+ }
+
// The default value of LanesInUse is 0, and the field will be
// left as off if it is a default value.
if (lanesInUse != nullptr && *lanesInUse != 0)
{
asyncResp->res.jsonValue["PCIeInterface"]["LanesInUse"] = *lanesInUse;
}
+ // The default value of MaxLanes is 0, and the field will be
+ // left as off if it is a default value.
+ if (maxLanes != nullptr && *maxLanes != 0)
+ {
+ asyncResp->res.jsonValue["PCIeInterface"]["MaxLanes"] = *maxLanes;
+ }
asyncResp->res.jsonValue["PCIeFunctions"]["@odata.id"] =
boost::urls::format(