summaryrefslogtreecommitdiff
path: root/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch')
-rw-r--r--meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch372
1 files changed, 184 insertions, 188 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch
index 1dc55e2f4..5623d246d 100644
--- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch
+++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch
@@ -1,6 +1,6 @@
-From 1c15df9d82254286d0773086836767f23711c5d9 Mon Sep 17 00:00:00 2001
+From 55db62a92dff4bfc3d34c590b33d9da4e7706b9d Mon Sep 17 00:00:00 2001
From: Cheng C Yang <cheng.c.yang@intel.com>
-Date: Tue, 2 Apr 2019 00:34:34 +0800
+Date: Wed, 3 Jul 2019 06:12:55 +0800
Subject: [PATCH] Move Set SOL config parameter to host-ipmid
Move Set SOL config parameter command from net-ipmid to host-ipmid,
@@ -23,16 +23,15 @@ to 0 and other properties will not reset to default value.
Signed-off-by: Cheng C Yang <cheng.c.yang@intel.com>
---
host-ipmid-whitelist.conf | 1 +
- include/ipmid/api.h | 1 +
- transporthandler.cpp | 222 ++++++++++++++++++++++++++++++++++++++
- transporthandler.hpp | 97 +++++++++++++++++
- 4 files changed, 321 insertions(+)
+ transporthandler.cpp | 289 ++++++++++++++++++++++++++++++++++++++++++++++
+ transporthandler.hpp | 33 ++++++
+ 3 files changed, 323 insertions(+)
diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf
-index 2a83347..544b766 100644
+index 2b72d23..856588e 100644
--- a/host-ipmid-whitelist.conf
+++ b/host-ipmid-whitelist.conf
-@@ -41,6 +41,7 @@
+@@ -42,6 +42,7 @@
0x0A:0x48 //<Storage>:<Get SEL Time>
0x0A:0x49 //<Storage>:<Set SEL Time>
0x0C:0x02 //<Transport>:<Get LAN Configuration Parameters>
@@ -40,20 +39,8 @@ index 2a83347..544b766 100644
0x2C:0x00 //<Group Extension>:<Group Extension Command>
0x2C:0x01 //<Group Extension>:<Get DCMI Capabilities>
0x2C:0x02 //<Group Extension>:<Get Power Reading>
-diff --git a/include/ipmid/api.h b/include/ipmid/api.h
-index f08ee11..2f366b4 100644
---- a/include/ipmid/api.h
-+++ b/include/ipmid/api.h
-@@ -113,6 +113,7 @@ enum ipmi_return_codes
- IPMI_DCMI_CC_NO_ACTIVE_POWER_LIMIT = 0x80,
- IPMI_WDOG_CC_NOT_INIT = 0x80,
- IPMI_CC_SYSTEM_INFO_PARAMETER_NOT_SUPPORTED = 0x80,
-+ IPMI_CC_SET_IN_PROGRESS_ACTIVE = 0x81,
- IPMI_CC_SYSTEM_INFO_PARAMETER_SET_READ_ONLY = 0x82,
- IPMI_CC_BUSY = 0xC0,
- IPMI_CC_INVALID = 0xC1,
diff --git a/transporthandler.cpp b/transporthandler.cpp
-index 8f18b76..a693279 100644
+index bb624c4..25062ae 100644
--- a/transporthandler.cpp
+++ b/transporthandler.cpp
@@ -36,6 +36,9 @@ static const std::array<std::string, 3> ipAddressEnablesType = {
@@ -61,37 +48,57 @@ index 8f18b76..a693279 100644
"xyz.openbmc_project.Network.EthernetInterface.IPAllowed.IPv4AndIPv6"};
+constexpr const char* solInterface = "xyz.openbmc_project.Ipmi.SOL";
-+constexpr const char* solPath = "/xyz/openbmc_project/ipmi/sol";
++constexpr const char* solPath = "/xyz/openbmc_project/ipmi/sol/";
+
std::map<int, std::unique_ptr<struct ChannelConfig_t>> channelConfig;
using namespace phosphor::logging;
-@@ -1633,6 +1636,219 @@ void createNetworkTimer()
+@@ -1631,6 +1634,285 @@ void createNetworkTimer()
}
}
-+static int setSOLParameter(std::string property, const ipmi::Value& value)
++static std::string
++ getSOLService(std::shared_ptr<sdbusplus::asio::connection> dbus,
++ const std::string& solPathWitheEthName)
+{
-+ auto dbus = getSdBus();
-+
+ static std::string solService{};
+ if (solService.empty())
+ {
+ try
+ {
-+ solService = ipmi::getService(*dbus, solInterface, solPath);
++ solService =
++ ipmi::getService(*dbus, solInterface, solPathWitheEthName);
+ }
+ catch (const sdbusplus::exception::SdBusError& e)
+ {
+ solService.clear();
+ phosphor::logging::log<phosphor::logging::level::ERR>(
+ "Error: get SOL service failed");
-+ return -1;
++ return solService;
+ }
+ }
++ return solService;
++}
++
++static int setSOLParameter(const std::string& property,
++ const ipmi::Value& value, const uint8_t& channelNum)
++{
++ auto dbus = getSdBus();
++
++ std::string ethdevice = ipmi::getChannelName(channelNum);
++
++ std::string solPathWitheEthName = std::string(solPath) + ethdevice;
++
++ std::string service = getSOLService(dbus, solPathWitheEthName);
++ if (service.empty())
++ {
++ phosphor::logging::log<phosphor::logging::level::ERR>(
++ "Unable to get SOL service failed");
++ return -1;
++ }
+ try
+ {
-+ ipmi::setDbusProperty(*dbus, solService, solPath, solInterface,
++ ipmi::setDbusProperty(*dbus, service, solPathWitheEthName, solInterface,
+ property, value);
+ }
+ catch (sdbusplus::exception_t&)
@@ -104,29 +111,26 @@ index 8f18b76..a693279 100644
+ return 0;
+}
+
-+static int getSOLParameter(std::string property, ipmi::Value& value)
++static int getSOLParameter(const std::string& property, ipmi::Value& value,
++ const uint8_t& channelNum)
+{
+ auto dbus = getSdBus();
+
-+ static std::string solService{};
-+ if (solService.empty())
++ std::string ethdevice = ipmi::getChannelName(channelNum);
++
++ std::string solPathWitheEthName = std::string(solPath) + ethdevice;
++
++ std::string service = getSOLService(dbus, solPathWitheEthName);
++ if (service.empty())
+ {
-+ try
-+ {
-+ solService = ipmi::getService(*dbus, solInterface, solPath);
-+ }
-+ catch (const sdbusplus::exception::SdBusError& e)
-+ {
-+ solService.clear();
-+ phosphor::logging::log<phosphor::logging::level::ERR>(
-+ "Error: get SOL service failed");
-+ return -1;
-+ }
++ phosphor::logging::log<phosphor::logging::level::ERR>(
++ "Unable to get SOL service failed");
++ return -1;
+ }
+ try
+ {
-+ value = ipmi::getDbusProperty(*dbus, solService, solPath, solInterface,
-+ property);
++ value = ipmi::getDbusProperty(*dbus, service, solPathWitheEthName,
++ solInterface, property);
+ }
+ catch (sdbusplus::exception_t&)
+ {
@@ -140,158 +144,208 @@ index 8f18b76..a693279 100644
+
+void initializeSOLInProgress()
+{
-+ if (setSOLParameter("Progress", static_cast<uint8_t>(0)) < 0)
++ ipmi::ChannelInfo chInfo;
++ for (int chNum = 0; chNum < ipmi::maxIpmiChannels; chNum++)
+ {
-+ phosphor::logging::log<phosphor::logging::level::ERR>(
-+ "Error initialize sol progress");
++ if (!ipmi::isValidChannel(static_cast<uint8_t>(chNum)))
++ {
++ continue;
++ }
++ ipmi_ret_t compCode =
++ ipmi::getChannelInfo(static_cast<uint8_t>(chNum), chInfo);
++ if (compCode != IPMI_CC_OK ||
++ chInfo.mediumType !=
++ static_cast<uint8_t>(ipmi::EChannelMediumType::lan8032))
++ {
++ continue;
++ }
++ if (setSOLParameter("Progress", static_cast<uint8_t>(0), chNum) < 0)
++ {
++ phosphor::logging::log<phosphor::logging::level::ERR>(
++ "Error initialize sol progress");
++ }
+ }
+}
+
-+ipmi_ret_t setConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd,
-+ ipmi_request_t request, ipmi_response_t response,
-+ ipmi_data_len_t dataLen, ipmi_context_t context)
++static const constexpr uint8_t encryptMask = 0x80;
++static const constexpr uint8_t encryptShift = 7;
++static const constexpr uint8_t authMask = 0x40;
++static const constexpr uint8_t authShift = 6;
++static const constexpr uint8_t privilegeMask = 0xf;
++
++namespace ipmi
++{
++constexpr Cc ccParmNotSupported = 0x80;
++constexpr Cc ccSetInProgressActive = 0x81;
++constexpr Cc ccSystemInfoParameterSetReadOnly = 0x82;
++
++static inline auto responseParmNotSupported()
+{
-+ auto reqData = reinterpret_cast<const SetConfParamsRequest*>(request);
++ return response(ccParmNotSupported);
++}
++static inline auto responseSetInProgressActive()
++{
++ return response(ccSetInProgressActive);
++}
++static inline auto responseSystemInfoParameterSetReadOnly()
++{
++ return response(ccSystemInfoParameterSetReadOnly);
++}
+
-+ // Check request length first
-+ switch (static_cast<sol::Parameter>(reqData->paramSelector))
++} // namespace ipmi
++
++ipmi::RspType<> setSOLConfParams(ipmi::Context::ptr ctx, uint4_t chNum,
++ uint4_t reserved, uint8_t paramSelector,
++ uint8_t configParamData1,
++ std::optional<uint8_t> configParamData2)
++{
++ ipmi::ChannelInfo chInfo;
++ uint8_t channelNum = ipmi::convertCurrentChannelNum(
++ static_cast<uint8_t>(chNum), ctx->channel);
++ if (reserved != 0 ||
++ (!ipmi::isValidChannel(static_cast<uint8_t>(channelNum))))
+ {
-+ case sol::Parameter::progress:
-+ case sol::Parameter::enable:
-+ case sol::Parameter::authentication:
-+ {
-+ if (*dataLen != sizeof(SetConfParamsRequest) - 1)
-+ {
-+ *dataLen = 0;
-+ return IPMI_CC_REQ_DATA_LEN_INVALID;
-+ }
-+ break;
-+ }
-+ case sol::Parameter::accumulate:
-+ case sol::Parameter::retry:
-+ {
-+ if (*dataLen != sizeof(SetConfParamsRequest))
-+ {
-+ *dataLen = 0;
-+ return IPMI_CC_REQ_DATA_LEN_INVALID;
-+ }
-+ break;
-+ }
-+ default:
-+ break;
++ return ipmi::responseInvalidFieldRequest();
+ }
+
-+ *dataLen = 0;
++ ipmi_ret_t compCode =
++ ipmi::getChannelInfo(static_cast<uint8_t>(channelNum), chInfo);
++ if (compCode != IPMI_CC_OK ||
++ chInfo.mediumType !=
++ static_cast<uint8_t>(ipmi::EChannelMediumType::lan8032))
++ {
++ return ipmi::responseInvalidFieldRequest();
++ }
+
-+ switch (static_cast<sol::Parameter>(reqData->paramSelector))
++ switch (static_cast<sol::Parameter>(paramSelector))
+ {
+ case sol::Parameter::progress:
+ {
-+ uint8_t progress = reqData->value & progressMask;
++ if (configParamData2)
++ {
++ return ipmi::responseReqDataLenInvalid();
++ }
++ uint8_t progress = configParamData1 & progressMask;
+ ipmi::Value currentProgress = 0;
-+ if (getSOLParameter("Progress", currentProgress) < 0)
++ if (getSOLParameter("Progress", currentProgress, channelNum) < 0)
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseUnspecifiedError();
+ }
+
+ if ((std::get<uint8_t>(currentProgress) == 1) && (progress == 1))
+ {
-+ return IPMI_CC_SET_IN_PROGRESS_ACTIVE;
++ return ipmi::responseSetInProgressActive();
+ }
+
-+ if (setSOLParameter("Progress", progress) < 0)
++ if (setSOLParameter("Progress", progress, channelNum) < 0)
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseUnspecifiedError();
+ }
+ break;
+ }
+ case sol::Parameter::enable:
+ {
-+ bool enable = reqData->value & enableMask;
-+ if (setSOLParameter("Enable", enable) < 0)
++ if (configParamData2)
++ {
++ return ipmi::responseReqDataLenInvalid();
++ }
++ bool enable = configParamData1 & enableMask;
++ if (setSOLParameter("Enable", enable, channelNum) < 0)
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseUnspecifiedError();
+ }
+ break;
+ }
+ case sol::Parameter::authentication:
+ {
-+ // if encryption is used authentication must also be used.
-+ if (reqData->auth.encrypt && !reqData->auth.auth)
++ if (configParamData2)
+ {
-+ return IPMI_CC_SYSTEM_INFO_PARAMETER_SET_READ_ONLY;
++ return ipmi::responseReqDataLenInvalid();
+ }
-+ else if (reqData->auth.privilege <
++ uint8_t encrypt = (configParamData1 & encryptMask) >> encryptShift;
++ uint8_t auth = (configParamData1 & authMask) >> authShift;
++ uint8_t privilege = configParamData1 & privilegeMask;
++ // For security considering encryption and authentication must be
++ // true.
++ if (!encrypt || !auth)
++ {
++ return ipmi::responseSystemInfoParameterSetReadOnly();
++ }
++ else if (privilege <
+ static_cast<uint8_t>(sol::Privilege::userPriv) ||
-+ reqData->auth.privilege >
-+ static_cast<uint8_t>(sol::Privilege::oemPriv))
++ privilege > static_cast<uint8_t>(sol::Privilege::oemPriv))
+ {
-+ return IPMI_CC_INVALID_FIELD_REQUEST;
++ return ipmi::responseInvalidFieldRequest();
+ }
+
-+ if ((setSOLParameter("Privilege", reqData->auth.privilege) < 0) ||
-+ (setSOLParameter("ForceEncryption",
-+ static_cast<bool>(reqData->auth.encrypt)) <
-+ 0) ||
-+ (setSOLParameter("ForceAuthentication",
-+ static_cast<bool>(reqData->auth.auth)) < 0))
++ if (setSOLParameter("Privilege", privilege, channelNum) < 0)
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseUnspecifiedError();
+ }
+
+ break;
+ }
+ case sol::Parameter::accumulate:
+ {
-+ if (reqData->acc.threshold == 0)
++ if (!configParamData2)
+ {
-+ return IPMI_CC_INVALID_FIELD_REQUEST;
++ return ipmi::responseReqDataLenInvalid();
+ }
-+ if (setSOLParameter("AccumulateIntervalMS", reqData->acc.interval) <
-+ 0)
++ if (*configParamData2 == 0)
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseInvalidFieldRequest();
+ }
-+ if (setSOLParameter("Threshold", reqData->acc.threshold) < 0)
++ if (setSOLParameter("AccumulateIntervalMS", configParamData1,
++ channelNum) < 0)
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseUnspecifiedError();
++ }
++ if (setSOLParameter("Threshold", *configParamData2, channelNum) < 0)
++ {
++ return ipmi::responseUnspecifiedError();
+ }
+ break;
+ }
+ case sol::Parameter::retry:
+ {
-+ if ((setSOLParameter("RetryCount", reqData->retry.count) < 0) ||
-+ (setSOLParameter("RetryIntervalMS", reqData->retry.interval) <
-+ 0))
++ if (!configParamData2)
++ {
++ return ipmi::responseReqDataLenInvalid();
++ }
++ if ((setSOLParameter("RetryCount", (configParamData1 & 0x7),
++ channelNum) < 0) ||
++ (setSOLParameter("RetryIntervalMS", *configParamData2,
++ channelNum) < 0))
+ {
-+ return IPMI_CC_UNSPECIFIED_ERROR;
++ return ipmi::responseUnspecifiedError();
+ }
+
+ break;
+ }
+ case sol::Parameter::port:
+ {
-+ return IPMI_CC_SYSTEM_INFO_PARAMETER_SET_READ_ONLY;
++ return ipmi::responseSystemInfoParameterSetReadOnly();
+ }
+ case sol::Parameter::nvbitrate:
+ case sol::Parameter::vbitrate:
+ case sol::Parameter::channel:
+ default:
-+ return IPMI_CC_PARM_NOT_SUPPORTED;
++ return ipmi::responseParmNotSupported();
+ }
+
-+ return IPMI_CC_OK;
++ return ipmi::responseSuccess();
+}
+
void register_netfn_transport_functions()
{
// As this timer is only for transport handler
-@@ -1650,5 +1866,11 @@ void register_netfn_transport_functions()
+@@ -1648,5 +1930,12 @@ void register_netfn_transport_functions()
ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_GET_LAN, NULL,
ipmi_transport_get_lan, PRIVILEGE_OPERATOR);
-+ ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_SET_SOL_CONF_PARAMS, NULL,
-+ setConfParams, PRIVILEGE_ADMIN);
++ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnTransport,
++ ipmi::transport::cmdSetSolConfigParameters,
++ ipmi::Privilege::Admin, setSOLConfParams);
+
+ // Initialize dbus property progress to 0 every time sol manager restart.
+ initializeSOLInProgress();
@@ -299,10 +353,17 @@ index 8f18b76..a693279 100644
return;
}
diff --git a/transporthandler.hpp b/transporthandler.hpp
-index bd23391..3b5e9e1 100644
+index bd23391..1237658 100644
--- a/transporthandler.hpp
+++ b/transporthandler.hpp
-@@ -8,6 +8,8 @@ enum ipmi_netfn_storage_cmds
+@@ -1,5 +1,6 @@
+ #pragma once
+
++#include <ipmid/api-types.hpp>
+ #include <ipmid/types.hpp>
+ #include <string>
+ // IPMI commands for Transport net functions.
+@@ -8,6 +9,8 @@ enum ipmi_netfn_storage_cmds
// Get capability bits
IPMI_CMD_SET_LAN = 0x01,
IPMI_CMD_GET_LAN = 0x02,
@@ -311,7 +372,7 @@ index bd23391..3b5e9e1 100644
};
// Command specific completion codes
-@@ -186,3 +188,98 @@ void commitNetworkChanges();
+@@ -186,3 +189,33 @@ void commitNetworkChanges();
* @param[in] channel: channel number.
*/
void applyChanges(int channel);
@@ -345,71 +406,6 @@ index bd23391..3b5e9e1 100644
+
+constexpr uint8_t progressMask = 0x03;
+constexpr uint8_t enableMask = 0x01;
-+
-+struct Auth
-+{
-+#if BYTE_ORDER == LITTLE_ENDIAN
-+ uint8_t privilege : 4; //!< SOL privilege level.
-+ uint8_t reserved : 2; //!< Reserved.
-+ uint8_t auth : 1; //!< Force SOL payload Authentication.
-+ uint8_t encrypt : 1; //!< Force SOL payload encryption.
-+#endif
-+
-+#if BYTE_ORDER == BIG_ENDIAN
-+ uint8_t encrypt : 1; //!< Force SOL payload encryption.
-+ uint8_t auth : 1; //!< Force SOL payload Authentication.
-+ uint8_t reserved : 2; //!< Reserved.
-+ uint8_t privilege : 4; //!< SOL privilege level.
-+#endif
-+} __attribute__((packed));
-+
-+struct Accumulate
-+{
-+ uint8_t interval; //!< Character accumulate interval.
-+ uint8_t threshold; //!< Character send threshold.
-+} __attribute__((packed));
-+
-+struct Retry
-+{
-+#if BYTE_ORDER == LITTLE_ENDIAN
-+ uint8_t count : 3; //!< SOL retry count.
-+ uint8_t reserved : 5; //!< Reserved.
-+#endif
-+
-+#if BYTE_ORDER == BIG_ENDIAN
-+ uint8_t reserved : 5; //!< Reserved.
-+ uint8_t count : 3; //!< SOL retry count.
-+#endif
-+
-+ uint8_t interval; //!< SOL retry interval.
-+} __attribute__((packed));
-+
-+struct SetConfParamsRequest
-+{
-+#if BYTE_ORDER == LITTLE_ENDIAN
-+ uint8_t channelNumber : 4; //!< Channel number.
-+ uint8_t reserved : 4; //!< Reserved.
-+#endif
-+
-+#if BYTE_ORDER == BIG_ENDIAN
-+ uint8_t reserved : 4; //!< Reserved.
-+ uint8_t channelNumber : 4; //!< Channel number.
-+#endif
-+
-+ uint8_t paramSelector; //!< Parameter selector.
-+ union
-+ {
-+ uint8_t value; //!< Represents one byte SOL parameters.
-+ struct Accumulate acc; //!< Character accumulate values.
-+ struct Retry retry; //!< Retry values.
-+ struct Auth auth; //!< Authentication parameters.
-+ };
-+} __attribute__((packed));
-+
-+struct SetConfParamsResponse
-+{
-+ uint8_t completionCode; //!< Completion code.
-+} __attribute__((packed));
--
-2.17.1
+2.7.4