Move PCIe functions to common file
Move redfishPcieGenerationFromDbus, called from both pcie.hpp and
pcie_slots.hpp, and busSlotTypeToRf functions, called from
pcie_slots.hpp, to a common PCIe utility file.
In the future commit, when integrating PCIeSlot with PCIeDevice, we will
call the busSlotTypeToRf function from pcie.hpp, so having it in the
common utility file will make it readily available.
Tested: build successful, no additional testing needed.
Change-Id: I6286bd5547ddafa6eac4f224ac56f6d790a44c7a
Signed-off-by: Lakshmi Yadlapati <lakshmiy@us.ibm.com>
diff --git a/redfish-core/lib/pcie_slots.hpp b/redfish-core/lib/pcie_slots.hpp
index 51a5e69..7246aea 100644
--- a/redfish-core/lib/pcie_slots.hpp
+++ b/redfish-core/lib/pcie_slots.hpp
@@ -4,11 +4,12 @@
#include "dbus_utility.hpp"
#include "error_messages.hpp"
#include "generated/enums/pcie_slots.hpp"
-#include "pcie.hpp"
+#include "query.hpp"
#include "registries/privilege_registry.hpp"
#include "utility.hpp"
#include "utils/dbus_utils.hpp"
#include "utils/json_utils.hpp"
+#include "utils/pcie_util.hpp"
#include <boost/system/error_code.hpp>
#include <boost/url/format.hpp>
@@ -21,61 +22,6 @@
namespace redfish
{
-inline std::optional<pcie_slots::SlotTypes>
- dbusSlotTypeToRf(const std::string& slotType)
-{
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.FullLength")
- {
- return pcie_slots::SlotTypes::FullLength;
- }
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.HalfLength")
- {
- return pcie_slots::SlotTypes::HalfLength;
- }
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.LowProfile")
- {
- return pcie_slots::SlotTypes::LowProfile;
- }
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.Mini")
- {
- return pcie_slots::SlotTypes::Mini;
- }
- if (slotType == "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.M_2")
- {
- return pcie_slots::SlotTypes::M2;
- }
- if (slotType == "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.OEM")
- {
- return pcie_slots::SlotTypes::OEM;
- }
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.OCP3Small")
- {
- return pcie_slots::SlotTypes::OCP3Small;
- }
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.OCP3Large")
- {
- return pcie_slots::SlotTypes::OCP3Large;
- }
- if (slotType == "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.U_2")
- {
- return pcie_slots::SlotTypes::U2;
- }
- if (slotType ==
- "xyz.openbmc_project.Inventory.Item.PCIeSlot.SlotTypes.Unknown")
- {
- return pcie_slots::SlotTypes::Invalid;
- }
-
- // Unspecified slotType should return an internal error.
- return std::nullopt;
-}
-
inline void
onPcieSlotGetAllDone(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
const boost::system::error_code& ec,
@@ -120,7 +66,7 @@
if (generation != nullptr)
{
std::optional<pcie_device::PCIeTypes> pcieType =
- redfishPcieGenerationFromDbus(*generation);
+ pcie_util::redfishPcieGenerationFromDbus(*generation);
if (!pcieType)
{
messages::internalError(asyncResp->res);
@@ -140,7 +86,7 @@
if (slotType != nullptr)
{
std::optional<pcie_slots::SlotTypes> redfishSlotType =
- dbusSlotTypeToRf(*slotType);
+ pcie_util::dbusSlotTypeToRf(*slotType);
if (!redfishSlotType)
{
messages::internalError(asyncResp->res);