From d0f63ef62c76c932a2003eaa42c0b250065ae06f Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Wed, 31 Jul 2019 10:43:37 -0700 Subject: Update to internal 7-31-19 Signed-off-by: Ed Tanous --- ...ve-Get-SOL-config-parameter-to-host-ipmid.patch | 270 +++++++-------------- 1 file changed, 94 insertions(+), 176 deletions(-) (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch') diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch index 24f355d80..01a3e49b8 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch @@ -1,12 +1,12 @@ -From 3c95de833eba73b3585941ade42ad1775e723280 Mon Sep 17 00:00:00 2001 +From e8ad148601fc3b45fac9092fdd45c537433e662f Mon Sep 17 00:00:00 2001 From: Cheng C Yang -Date: Tue, 7 May 2019 08:03:56 +0800 +Date: Thu, 11 Jul 2019 00:32:58 +0800 Subject: [PATCH] Move Get SOL config parameter to host-ipmid Move Get SOL config parameter command from net-ipmid to host-ipmid. Tested: -Run command ipmitool sol info +Run command ipmitool sol info 1 Set in progress : set-complete Enabled : true Force Encryption : false @@ -18,21 +18,20 @@ Retry Count : 6 Retry Interval (ms) : 200 Volatile Bit Rate (kbps) : IPMI-Over-Serial-Setting Non-Volatile Bit Rate (kbps) : 115.2 -Payload Channel : 14 (0x0e) +Payload Channel : 1 (0x01) Payload Port : 623 Signed-off-by: Cheng C Yang --- host-ipmid-whitelist.conf | 1 + - transporthandler.cpp | 198 ++++++++++++++++++++++++++++++++++++++++++++-- - transporthandler.hpp | 27 ++++++- - 3 files changed, 217 insertions(+), 9 deletions(-) + transporthandler.cpp | 191 ++++++++++++++++++++++++++++++++++++++++++++++ + 2 files changed, 192 insertions(+) diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf -index 2ce44c6..383b412 100644 +index 44c2181..0fcac4e 100644 --- a/host-ipmid-whitelist.conf +++ b/host-ipmid-whitelist.conf -@@ -43,6 +43,7 @@ +@@ -41,6 +41,7 @@ 0x0A:0x49 //: 0x0C:0x02 //: 0x0C:0x21 //: @@ -41,22 +40,15 @@ index 2ce44c6..383b412 100644 0x2C:0x01 //: 0x2C:0x02 //: diff --git a/transporthandler.cpp b/transporthandler.cpp -index 850172d..0c1223a 100644 +index 25062ae..9ba2868 100644 --- a/transporthandler.cpp +++ b/transporthandler.cpp -@@ -38,6 +38,8 @@ static const std::array ipAddressEnablesType = { - - constexpr const char* solInterface = "xyz.openbmc_project.Ipmi.SOL"; - constexpr const char* solPath = "/xyz/openbmc_project/ipmi/sol"; -+constexpr const char* consoleInterface = "xyz.openbmc_project.console"; -+constexpr const char* consolePath = "/xyz/openbmc_project/console"; - - std::map> channelConfig; - -@@ -1668,6 +1670,26 @@ static int setSOLParameter(std::string property, const ipmi::Value& value) +@@ -1719,6 +1719,28 @@ static int getSOLParameter(const std::string& property, ipmi::Value& value, return 0; } ++constexpr const char* consoleInterface = "xyz.openbmc_project.console"; ++constexpr const char* consolePath = "/xyz/openbmc_project/console"; +static int getSOLBaudRate(ipmi::Value& value) +{ + auto dbus = getSdBus(); @@ -77,134 +69,142 @@ index 850172d..0c1223a 100644 + return 0; +} + - static int getSOLParameter(std::string property, ipmi::Value& value) + void initializeSOLInProgress() { - auto dbus = getSdBus(); -@@ -1711,11 +1733,170 @@ void initializeSOLInProgress() - } + ipmi::ChannelInfo chInfo; +@@ -1913,6 +1935,171 @@ ipmi::RspType<> setSOLConfParams(ipmi::Context::ptr ctx, uint4_t chNum, + return ipmi::responseSuccess(); } --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 retryCountMask = 0x07; -+// For getsetSOLConfParams, there are still three tings TODO: -+// 1. session less channel number request has to return error. -+// 2. convert 0xE channel number. -+// 3. have unique object for every session based channel. -+ipmi_ret_t getSOLConfParams(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 constexpr uint16_t ipmiStdPort = 623; ++static constexpr uint8_t solParameterRevision = 0x11; ++ipmi::RspType, std::optional> ++ getSOLConfParams(ipmi::Context::ptr ctx, uint4_t chNum, uint3_t reserved, ++ bool getParamRev, uint8_t paramSelector, ++ uint8_t setSelector, uint8_t blockSelector) +{ -+ auto reqData = reinterpret_cast(request); -+ std::vector outPayload; -+ -+ if (*dataLen < sizeof(GetSOLConfParamsRequest) - 2) ++ ipmi::ChannelInfo chInfo; ++ uint8_t channelNum = ipmi::convertCurrentChannelNum( ++ static_cast(chNum), ctx->channel); ++ if (reserved != 0 || ++ (!ipmi::isValidChannel(static_cast(channelNum))) || ++ (ipmi::EChannelSessSupported::none == ++ ipmi::getChannelSessionSupport(static_cast(channelNum)))) + { -+ *dataLen = 0; -+ return IPMI_CC_REQ_DATA_LEN_INVALID; ++ return ipmi::responseInvalidFieldRequest(); ++ } ++ ipmi_ret_t compCode = ++ ipmi::getChannelInfo(static_cast(channelNum), chInfo); ++ if (compCode != IPMI_CC_OK || ++ chInfo.mediumType != ++ static_cast(ipmi::EChannelMediumType::lan8032)) ++ { ++ return ipmi::responseInvalidFieldRequest(); + } + -+ *dataLen = 0; -+ -+ outPayload.push_back(solParameterRevision); -+ if (reqData->getParamRev) ++ if (getParamRev) + { -+ std::copy(outPayload.begin(), outPayload.end(), -+ static_cast(response)); -+ *dataLen = outPayload.size(); -+ return IPMI_CC_OK; ++ return ipmi::responseSuccess(solParameterRevision, std::nullopt, ++ std::nullopt); + } + + ipmi::Value value; -+ switch (static_cast(reqData->paramSelector)) ++ switch (static_cast(paramSelector)) + { + case sol::Parameter::progress: + { -+ if (getSOLParameter("Progress", value) < 0) ++ if (getSOLParameter("Progress", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } -+ outPayload.push_back(std::get(value)); -+ break; ++ return ipmi::responseSuccess( ++ solParameterRevision, std::get(value), std::nullopt); + } + case sol::Parameter::enable: + { -+ if (getSOLParameter("Enable", value) < 0) ++ if (getSOLParameter("Enable", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } -+ outPayload.push_back(static_cast(std::get(value))); -+ break; ++ return ipmi::responseSuccess( ++ solParameterRevision, ++ static_cast(std::get(value)), std::nullopt); + } + case sol::Parameter::authentication: + { + uint8_t authentication = 0; -+ if (getSOLParameter("Privilege", value) < 0) ++ if (getSOLParameter("Privilege", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } + authentication = (std::get(value) & 0x0f); + -+ if (getSOLParameter("ForceAuthentication", value) < 0) ++ if (getSOLParameter("ForceAuthentication", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } + authentication |= + (static_cast(std::get(value)) << 6); + -+ if (getSOLParameter("ForceEncryption", value) < 0) ++ if (getSOLParameter("ForceEncryption", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } + authentication |= + (static_cast(std::get(value)) << 7); -+ outPayload.push_back(authentication); -+ break; ++ return ipmi::responseSuccess(solParameterRevision, authentication, ++ std::nullopt); + } + case sol::Parameter::accumulate: + { -+ if (getSOLParameter("AccumulateIntervalMS", value) < 0) ++ if (getSOLParameter("AccumulateIntervalMS", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } -+ outPayload.push_back(std::get(value)); + -+ if (getSOLParameter("Threshold", value) < 0) ++ ipmi::Value value1; ++ if (getSOLParameter("Threshold", value1, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } -+ outPayload.push_back(std::get(value)); -+ break; ++ return ipmi::responseSuccess(solParameterRevision, ++ std::get(value), ++ std::get(value1)); + } + case sol::Parameter::retry: + { -+ if (getSOLParameter("RetryCount", value) < 0) ++ if (getSOLParameter("RetryCount", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } -+ outPayload.push_back(std::get(value) & retryCountMask); + -+ if (getSOLParameter("RetryIntervalMS", value) < 0) ++ ipmi::Value value1; ++ if (getSOLParameter("RetryIntervalMS", value1, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } -+ outPayload.push_back(std::get(value)); -+ break; ++ return ipmi::responseSuccess( ++ solParameterRevision, std::get(value) & retryCountMask, ++ std::get(value1)); ++ } ++ case sol::Parameter::channel: ++ { ++ return ipmi::responseSuccess(solParameterRevision, channelNum, ++ std::nullopt); + } + case sol::Parameter::port: + { + uint16_t port = htole16(ipmiStdPort); + auto buffer = reinterpret_cast(&port); -+ std::copy(buffer, buffer + sizeof(port), -+ std::back_inserter(outPayload)); -+ break; ++ return ipmi::responseSuccess(solParameterRevision, buffer[0], ++ buffer[1]); + } + case sol::Parameter::nvbitrate: + { + if (getSOLBaudRate(value) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } + uint8_t bitRate = 0; + uint32_t* pBaudRate = std::get_if(&value); @@ -233,110 +233,28 @@ index 850172d..0c1223a 100644 + default: + break; + } -+ outPayload.push_back(bitRate); -+ break; ++ return ipmi::responseSuccess(solParameterRevision, bitRate, ++ std::nullopt); + } + default: -+ return IPMI_CC_PARM_NOT_SUPPORTED; ++ return ipmi::responseParmNotSupported(); + } -+ std::copy(outPayload.begin(), outPayload.end(), -+ static_cast(response)); -+ *dataLen = outPayload.size(); -+ -+ return IPMI_CC_OK; +} + -+ipmi_ret_t setSOLConfParams(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) + void register_netfn_transport_functions() { -- auto reqData = reinterpret_cast(request); -+ auto reqData = reinterpret_cast(request); - - // Check request length first - switch (static_cast(reqData->paramSelector)) -@@ -1724,7 +1905,7 @@ ipmi_ret_t setConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - case sol::Parameter::enable: - case sol::Parameter::authentication: - { -- if (*dataLen != sizeof(SetConfParamsRequest) - 1) -+ if (*dataLen != sizeof(SetSOLConfParamsRequest) - 1) - { - *dataLen = 0; - return IPMI_CC_REQ_DATA_LEN_INVALID; -@@ -1734,7 +1915,7 @@ ipmi_ret_t setConfParams(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - case sol::Parameter::accumulate: - case sol::Parameter::retry: - { -- if (*dataLen != sizeof(SetConfParamsRequest)) -+ if (*dataLen != sizeof(SetSOLConfParamsRequest)) - { - *dataLen = 0; - return IPMI_CC_REQ_DATA_LEN_INVALID; -@@ -1865,7 +2046,10 @@ void register_netfn_transport_functions() - ipmi_transport_get_lan, PRIVILEGE_OPERATOR); + // As this timer is only for transport handler +@@ -1934,6 +2121,10 @@ void register_netfn_transport_functions() + ipmi::transport::cmdSetSolConfigParameters, + ipmi::Privilege::Admin, setSOLConfParams); - ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_SET_SOL_CONF_PARAMS, NULL, -- setConfParams, PRIVILEGE_ADMIN); -+ setSOLConfParams, PRIVILEGE_ADMIN); ++ ipmi::registerHandler(ipmi::prioOpenBmcBase, ipmi::netFnTransport, ++ ipmi::transport::cmdGetSolConfigParameters, ++ ipmi::Privilege::User, getSOLConfParams); + -+ ipmi_register_callback(NETFUN_TRANSPORT, IPMI_CMD_GET_SOL_CONF_PARAMS, NULL, -+ getSOLConfParams, PRIVILEGE_ADMIN); - // Initialize dbus property progress to 0 every time sol manager restart. initializeSOLInProgress(); -diff --git a/transporthandler.hpp b/transporthandler.hpp -index 3b5e9e1..a21862b 100644 ---- a/transporthandler.hpp -+++ b/transporthandler.hpp -@@ -1,6 +1,7 @@ - #pragma once - - #include -+#include - #include - // IPMI commands for Transport net functions. - enum ipmi_netfn_storage_cmds -@@ -257,7 +258,7 @@ struct Retry - uint8_t interval; //!< SOL retry interval. - } __attribute__((packed)); --struct SetConfParamsRequest -+struct SetSOLConfParamsRequest - { - #if BYTE_ORDER == LITTLE_ENDIAN - uint8_t channelNumber : 4; //!< Channel number. -@@ -279,7 +280,29 @@ struct SetConfParamsRequest - }; - } __attribute__((packed)); - --struct SetConfParamsResponse -+struct SetSOLConfParamsResponse - { - uint8_t completionCode; //!< Completion code. - } __attribute__((packed)); -+ -+struct GetSOLConfParamsRequest -+{ -+#if BYTE_ORDER == LITTLE_ENDIAN -+ uint8_t channelNum : 4; //!< Channel number. -+ uint8_t reserved : 3; //!< Reserved. -+ uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision -+#endif -+ -+#if BYTE_ORDER == BIG_ENDIAN -+ uint8_t getParamRev : 1; //!< Get parameter or Get parameter revision -+ uint8_t reserved : 3; //!< Reserved. -+ uint8_t channelNum : 4; //!< Channel number. -+#endif -+ -+ uint8_t paramSelector; //!< Parameter selector. -+ uint8_t setSelector; //!< Set selector. -+ uint8_t blockSelector; //!< Block selector. -+} __attribute__((packed)); -+ -+static constexpr uint16_t ipmiStdPort = 623; -+static constexpr uint8_t solParameterRevision = 0x11; -- 2.7.4 -- cgit v1.2.3