intel-ipmi-oem: Replace yield with ctx for mfg cmd
Replace yield with ctx pointer where ever possible
in manufacturing commands. This gives option to avoid
getSdBus() calls as sdbus pointer & yield will be used.
Tested:
Verified existing manufacturing commands are working fine.
Change-Id: Ifdd7f0c3872768cf167648396ca194e77fcb13b2
Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com>
diff --git a/src/manufacturingcommands.cpp b/src/manufacturingcommands.cpp
index eefdc76..5e3dbdd 100644
--- a/src/manufacturingcommands.cpp
+++ b/src/manufacturingcommands.cpp
@@ -48,13 +48,12 @@
"org.freedesktop.systemd1.Manager";
const static constexpr char* pidControlService = "phosphor-pid-control.service";
-static inline Cc resetMtmTimer(boost::asio::yield_context yield)
+static inline Cc resetMtmTimer(ipmi::Context::ptr ctx)
{
- auto sdbusp = getSdBus();
boost::system::error_code ec;
- sdbusp->yield_method_call<>(yield, ec, specialModeService,
- specialModeObjPath, specialModeIntf,
- "ResetTimer");
+ ctx->bus->yield_method_call<>(ctx->yield, ec, specialModeService,
+ specialModeObjPath, specialModeIntf,
+ "ResetTimer");
if (ec)
{
phosphor::logging::log<phosphor::logging::level::ERR>(
@@ -259,7 +258,7 @@
ipmi::RspType<uint8_t, // Signal value
std::optional<uint16_t> // Fan tach value
>
- appMTMGetSignal(boost::asio::yield_context yield, uint8_t signalTypeByte,
+ appMTMGetSignal(ipmi::Context::ptr ctx, uint8_t signalTypeByte,
uint8_t instance, uint8_t actionByte)
{
// mfg filter logic is used to allow MTM get signal command only in
@@ -285,20 +284,19 @@
return ipmi::responseUnspecifiedError();
}
uint8_t sensorVal = std::round(*doubleVal);
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
return ipmi::responseSuccess(sensorVal, std::nullopt);
}
break;
case SmSignalGet::smFanTachometerGet:
{
- auto sdbusp = getSdBus();
boost::system::error_code ec;
using objFlatMap = boost::container::flat_map<
std::string, boost::container::flat_map<
std::string, std::vector<std::string>>>;
- auto flatMap = sdbusp->yield_method_call<objFlatMap>(
- yield, ec, "xyz.openbmc_project.ObjectMapper",
+ auto flatMap = ctx->bus->yield_method_call<objFlatMap>(
+ ctx->yield, ec, "xyz.openbmc_project.ObjectMapper",
"/xyz/openbmc_project/object_mapper",
"xyz.openbmc_project.ObjectMapper", "GetSubTree",
fanTachBasePath, 0, std::array<const char*, 1>{fanIntf});
@@ -328,7 +326,7 @@
uint8_t sensorVal = FAN_PRESENT | FAN_SENSOR_PRESENT;
std::optional<uint16_t> fanTach = std::round(*doubleVal);
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
return ipmi::responseSuccess(sensorVal, fanTach);
}
break;
@@ -398,7 +396,7 @@
{
return ipmi::responseUnspecifiedError();
}
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
uint8_t sensorVal = *valPtr;
return ipmi::responseSuccess(sensorVal, std::nullopt);
}
@@ -415,7 +413,7 @@
}
std::string carrier;
netIfs >> carrier;
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
return ipmi::responseSuccess(
static_cast<uint8_t>(std::stoi(carrier)), std::nullopt);
}
@@ -426,9 +424,8 @@
}
}
-ipmi::RspType<> appMTMSetSignal(boost::asio::yield_context yield,
- uint8_t signalTypeByte, uint8_t instance,
- uint8_t actionByte,
+ipmi::RspType<> appMTMSetSignal(ipmi::Context::ptr ctx, uint8_t signalTypeByte,
+ uint8_t instance, uint8_t actionByte,
std::optional<uint8_t> pwmSpeed)
{
// mfg filter logic is used to allow MTM set signal command only in
@@ -567,12 +564,12 @@
}
if (retCode == ccSuccess)
{
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
}
return ipmi::response(retCode);
}
-ipmi::RspType<> mtmKeepAlive(boost::asio::yield_context yield, uint8_t reserved,
+ipmi::RspType<> mtmKeepAlive(ipmi::Context::ptr ctx, uint8_t reserved,
const std::array<char, 5>& intentionalSignature)
{
// mfg filter logic is used to allow MTM keep alive command only in
@@ -583,7 +580,7 @@
{
return ipmi::responseInvalidFieldRequest();
}
- return ipmi::response(resetMtmTimer(yield));
+ return ipmi::response(resetMtmTimer(ctx));
}
static constexpr unsigned int makeCmdKey(unsigned int netFn, unsigned int cmd)
@@ -633,8 +630,7 @@
static constexpr const char* factoryEthAddrBaseFileName =
"/var/sofs/factory-settings/network/mac/eth";
-ipmi::RspType<> setManufacturingData(boost::asio::yield_context yield,
- uint8_t dataType,
+ipmi::RspType<> setManufacturingData(ipmi::Context::ptr ctx, uint8_t dataType,
std::array<uint8_t, maxEthSize> ethData)
{
// mfg filter logic will restrict this command executing only in mfg mode.
@@ -664,12 +660,12 @@
oEthFile << fflush;
oEthFile.close();
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
return ipmi::responseSuccess();
}
ipmi::RspType<uint8_t, std::array<uint8_t, maxEthSize>>
- getManufacturingData(boost::asio::yield_context yield, uint8_t dataType)
+ getManufacturingData(ipmi::Context::ptr ctx, uint8_t dataType)
{
// mfg filter logic will restrict this command executing only in mfg mode.
if (dataType >= maxSupportedEth)
@@ -694,7 +690,7 @@
data, (data + 1), (data + 2), (data + 3), (data + 4),
(data + 5));
- resetMtmTimer(yield);
+ resetMtmTimer(ctx);
return ipmi::responseSuccess(validData, ethData);
}