Add Get for PCIe property LanesInUse
Added Redfish property 'LanesInUse' to PCIeDevices under
redfish/v1/Systems. LanesInUse maps to dbus LanesInUse property for the
Inventory.Item.PCIeDevice interface. Note: GUI might map this property
to 'LinkWidth'
Tested:
1) Redfish validator passed
2) Curl testing
curl -k <token> \
https://$bmc/redfish/v1/Systems/system/PCIeDevices/pcie_card8
{
"@odata.id": "/redfish/v1/Systems/system/PCIeDevices/pcie_card8",
"@odata.type": "#PCIeDevice.v1_9_0.PCIeDevice",
...
"PCIeInterface": {
"LanesInUse": 16,
"PCIeType": "Gen4"
},
...
}
Signed-off-by: Myung Bae <myungbae@us.ibm.com>
Change-Id: I896abe44f55414f25d01c5a93a31bb585264657e
diff --git a/Redfish.md b/Redfish.md
index cc714eb..3f65de8 100644
--- a/Redfish.md
+++ b/Redfish.md
@@ -768,6 +768,11 @@
- Members
- Members@odata.count
+### /redfish/v1/Systems/system/PCIeDevices/{PCIeDevice}/
+
+- PCIeInterface
+ - LanesInUse
+
### /redfish/v1/Systems/system/Processors/
#### ProcessorCollection
diff --git a/redfish-core/lib/pcie.hpp b/redfish-core/lib/pcie.hpp
index c91e52d..77afd0a 100644
--- a/redfish-core/lib/pcie.hpp
+++ b/redfish-core/lib/pcie.hpp
@@ -192,11 +192,12 @@
const std::string* manufacturer = nullptr;
const std::string* deviceType = nullptr;
const std::string* generationInUse = nullptr;
+ const size_t* lanesInUse = nullptr;
const bool success = sdbusplus::unpackPropertiesNoThrow(
dbus_utils::UnpackErrorPrinter(), pcieDevProperties,
"Manufacturer", manufacturer, "DeviceType", deviceType,
- "GenerationInUse", generationInUse);
+ "LanesInUse", lanesInUse, "GenerationInUse", generationInUse);
if (!success)
{
@@ -204,6 +205,14 @@
return;
}
+ // 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;
+ }
+
if (generationInUse != nullptr)
{
std::optional<pcie_device::PCIeTypes> redfishGenerationInUse =