diff options
author | Ed Tanous <ed.tanous@intel.com> | 2019-07-31 20:43:37 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2019-08-01 18:19:38 +0300 |
commit | d0f63ef62c76c932a2003eaa42c0b250065ae06f (patch) | |
tree | 4c0e3cb32dc80f80460bdbf82ff6d401d4ff194f /meta-openbmc-mods/meta-common/recipes-phosphor/ipmi | |
parent | b4f66bacb1b8e661d794fa7a189e2f66f5092e2e (diff) | |
download | openbmc-d0f63ef62c76c932a2003eaa42c0b250065ae06f.tar.xz |
Update to internal 7-31-19
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-phosphor/ipmi')
23 files changed, 806 insertions, 1790 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-config/channel_config.json b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-config/channel_config.json index c2f3c9a0e..92731f439 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-config/channel_config.json +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-config/channel_config.json @@ -22,13 +22,13 @@ } }, "2" : { - "name" : "eth2", - "is_valid" : true, + "name" : "RESERVED", + "is_valid" : false, "active_sessions" : 0, "channel_info" : { - "medium_type" : "lan-802.3", - "protocol_type" : "ipmb-1.0", - "session_supported" : "multi-session", + "medium_type" : "reserved", + "protocol_type" : "na", + "session_supported" : "session-less", "is_ipmi" : true } }, diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0002-Modify-dbus-interface-for-power-control.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0002-Modify-dbus-interface-for-power-control.patch deleted file mode 100644 index 236bd18f4..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0002-Modify-dbus-interface-for-power-control.patch +++ /dev/null @@ -1,31 +0,0 @@ -From 39df500f277eca01d6a0538d4db8ec34894d9441 Mon Sep 17 00:00:00 2001 -From: Yong Li <yong.b.li@linux.intel.com> -Date: Mon, 17 Sep 2018 12:59:12 +0800 -Subject: [PATCH] Modify dbus interface for power control - -Switch power control service namespace from "org" to "xyz", -to compatible with new intel-chassis services - -Signed-off-by: Yong Li <yong.b.li@linux.intel.com> ---- - chassishandler.cpp | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/chassishandler.cpp b/chassishandler.cpp -index 6002e7a..0e83bba 100644 ---- a/chassishandler.cpp -+++ b/chassishandler.cpp -@@ -786,8 +786,8 @@ ipmi_ret_t ipmi_get_chassis_status(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - ipmi_data_len_t data_len, - ipmi_context_t context) - { -- const char* objname = "/org/openbmc/control/power0"; -- const char* intf = "org.openbmc.control.Power"; -+ const char* objname = "/xyz/openbmc_project/Chassis/Control/Power0"; -+ const char* intf = "xyz.openbmc_project.Chassis.Control.Power"; - - sd_bus* bus = NULL; - sd_bus_message* reply = NULL; --- -2.7.4 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0010-fix-get-system-GUID-ipmi-command.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0010-fix-get-system-GUID-ipmi-command.patch index c1ec6ac6e..efee7cc26 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0010-fix-get-system-GUID-ipmi-command.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0010-fix-get-system-GUID-ipmi-command.patch @@ -1,56 +1,36 @@ -From 4953a9f2233fd24a28da84443cea6aebecd14fbc Mon Sep 17 00:00:00 2001 -From: Yong Li <yong.b.li@linux.intel.com> -Date: Mon, 17 Sep 2018 13:20:54 +0800 -Subject: [PATCH] fix "get system GUID" ipmi command +commit 72e6573f36fd3b9ce018e71b07bc1be63275d1f8 +Author: Vernon Mauery <vernon.mauery@linux.intel.com> +Date: Fri Jun 21 12:27:20 2019 -0700 -Change-Id: I15c71607c24ad8b3e2c9065a5470002ecb1761bb -Signed-off-by: Jia, Chunhui <chunhui.jia@intel.com> -Signed-off-by: Yong Li <yong.b.li@linux.intel.com> ---- - apphandler.cpp | 7 ++----- - host-ipmid-whitelist.conf | 1 + - 2 files changed, 3 insertions(+), 5 deletions(-) + Fix 'Get System GUID' to use settings UUID + + The upstream Get System GUID command looks first for a BMC interface + and then assumes that the UUID interface is next to that. But that is + not the case on Intel systems where the system GUID is found in the + settings daemon. + + Change-Id: I924bd05e0a546f2b30288c1faf72157296ab6579 + Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com> diff --git a/apphandler.cpp b/apphandler.cpp -index f2889c5..9149373 100644 +index 280d0db..25af6bb 100644 --- a/apphandler.cpp +++ b/apphandler.cpp -@@ -48,7 +48,7 @@ extern sd_bus* bus; - - constexpr auto bmc_state_interface = "xyz.openbmc_project.State.BMC"; - constexpr auto bmc_state_property = "CurrentBMCState"; --constexpr auto bmc_interface = "xyz.openbmc_project.Inventory.Item.Bmc"; -+// phosphor-setting-manager is the unique service that holds this interface - constexpr auto bmc_guid_interface = "xyz.openbmc_project.Common.UUID"; - constexpr auto bmc_guid_property = "UUID"; - constexpr auto bmc_guid_len = 16; -@@ -546,8 +545,7 @@ ipmi_ret_t ipmi_app_get_sys_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, +@@ -799,8 +799,6 @@ auto ipmiAppGetBtCapabilities() + + auto ipmiAppGetSystemGuid() -> ipmi::RspType<std::array<uint8_t, 16>> + { +- static constexpr auto bmcInterface = +- "xyz.openbmc_project.Inventory.Item.Bmc"; + static constexpr auto uuidInterface = "xyz.openbmc_project.Common.UUID"; + static constexpr auto uuidProperty = "UUID"; + +@@ -809,7 +807,7 @@ auto ipmiAppGetSystemGuid() -> ipmi::RspType<std::array<uint8_t, 16>> { // Get the Inventory object implementing BMC interface - ipmi::DbusObjectInfo bmcObject = -- ipmi::getDbusObject(bus, bmc_interface); -- -+ ipmi::getDbusObject(bus, bmc_guid_interface); + auto busPtr = getSdBus(); +- auto objectInfo = ipmi::getDbusObject(*busPtr, bmcInterface); ++ auto objectInfo = ipmi::getDbusObject(*busPtr, uuidInterface); + // Read UUID property value from bmcObject // UUID is in RFC4122 format Ex: 61a39523-78f2-11e5-9862-e6402cfc3223 - auto variant = -@@ -591,7 +589,6 @@ ipmi_ret_t ipmi_app_get_sys_guid(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - catch (const InternalFailure& e) - { - log<level::ERR>("Failed in reading BMC UUID property", -- entry("INTERFACE=%s", bmc_interface), - entry("PROPERTY_INTERFACE=%s", bmc_guid_interface), - entry("PROPERTY=%s", bmc_guid_property)); - return IPMI_CC_UNSPECIFIED_ERROR; -diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf -index 2c37ac9..164edbe 100644 ---- a/host-ipmid-whitelist.conf -+++ b/host-ipmid-whitelist.conf -@@ -40,3 +40,4 @@ - 0x2C:0x06 //<Group Extension>:<Get Asset Tag> - 0x2C:0x07 //<Group Extension>:<Get Sensor Info> - 0x2C:0x10 //<Group Extension>:<Get Temperature Readings> -+0x30:0x41 //<OEM>:<Set System GUID> --- -2.7.4 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0013-ipmi-add-set-bios-id-to-whitelist.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0013-ipmi-add-set-bios-id-to-whitelist.patch index ae10ab60a..396d2e949 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0013-ipmi-add-set-bios-id-to-whitelist.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0013-ipmi-add-set-bios-id-to-whitelist.patch @@ -10,16 +10,13 @@ Signed-off-by: Jia, Chunhui <chunhui.jia@intel.com> host-ipmid-whitelist.conf | 2 ++ 1 file changed, 2 insertions(+) -diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf -index 164edbe..db54a49 100644 ---- a/host-ipmid-whitelist.conf -+++ b/host-ipmid-whitelist.conf -@@ -41,3 +41,5 @@ +Index: phosphor-host-ipmid/host-ipmid-whitelist.conf +=================================================================== +--- phosphor-host-ipmid.orig/host-ipmid-whitelist.conf ++++ phosphor-host-ipmid/host-ipmid-whitelist.conf +@@ -47,3 +47,5 @@ + 0x2C:0x06 //<Group Extension>:<Get Asset Tag> 0x2C:0x07 //<Group Extension>:<Get Sensor Info> 0x2C:0x10 //<Group Extension>:<Get Temperature Readings> - 0x30:0x41 //<OEM>:<Set System GUID> +0x30:0x26 //<OEM>:<Set BIOS ID> +0x30:0x27 //<OEM>:<Get Device Info> --- -2.16.2 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0021-Implement-IPMI-Commmand-Get-Host-Restart-Cause.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0021-Implement-IPMI-Commmand-Get-Host-Restart-Cause.patch deleted file mode 100644 index cba0cde32..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0021-Implement-IPMI-Commmand-Get-Host-Restart-Cause.patch +++ /dev/null @@ -1,143 +0,0 @@ -From 6d5a372e0cf98de4d97a88d2cd42a00b7a8f034f Mon Sep 17 00:00:00 2001 -From: Yong Li <yong.b.li@linux.intel.com> -Date: Sun, 16 Sep 2018 21:32:38 +0800 -Subject: [PATCH] Implement IPMI Commmand - Get Host Restart Cause. - -It supports to track the information about what -action last caused the system to restart. -Return value includes: restart_cause and channel_number. - -According to IPMI Spec, it includes 12 types as following: -1. Unknown 0x0 -2. IpmiCommand 0x1 -3. ResetButton 0x2 -4. PowerButton 0x3 -5. WatchdogTimer 0x4 -6. OEM 0x5 -7. PowerPolicyAlwaysOn 0x6 -8. PowerPolicyPreviousState 0x7 -9. PEF-Reset 0x8 -10. PEF-PowerCycle 0x9 -11. SoftReset 0xA -12. RTC-Wakeup 0xB - -Change-Id: Id3b32e271b85b5fc4c69d5ca40227f8f9c08ce48 -Signed-off-by: Kuiying Wang <kuiying.wang@intel.com> -Signed-off-by: Yong Li <yong.b.li@linux.intel.com> ---- - chassishandler.cpp | 54 +++++++++++++++++++++++++++++++++++++++ - chassishandler.hpp | 1 + - host-ipmid-whitelist.conf | 1 + - 3 files changed, 56 insertions(+) - -diff --git a/chassishandler.cpp b/chassishandler.cpp -index d20b220..8a8cb26 100644 ---- a/chassishandler.cpp -+++ b/chassishandler.cpp -@@ -90,6 +90,11 @@ static constexpr auto chassisPOHStateIntf = - "xyz.openbmc_project.State.PowerOnHours"; - static constexpr auto pOHCounterProperty = "POHCounter"; - static constexpr auto match = "chassis0"; -+const static constexpr char* stateHostInterface = -+ "xyz.openbmc_project.State.Host"; -+const static constexpr char* hostRestartCauseInterface = -+ "xyz.openbmc_project.State.Host.HostRestartCause"; -+const static constexpr char* hostRestartCause = "HostRestartCause"; - const static constexpr char chassisCapIntf[] = - "xyz.openbmc_project.Control.ChassisCapabilities"; - const static constexpr char chassisCapFlagsProp[] = "CapabilitiesFlags"; -@@ -176,6 +181,13 @@ struct set_sys_boot_options_t - uint8_t data[SIZE_BOOT_OPTION]; - } __attribute__((packed)); - -+struct GetSysRestartCauseResponse -+{ -+ uint8_t restartCause; -+ uint8_t channelNum; -+ -+} __attribute__((packed)); -+ - int getHostNetworkData(get_sys_boot_options_response_t* respptr) - { - ipmi::PropertyMap properties; -@@ -1584,6 +1596,44 @@ ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - return rc; - } - -+ipmi_ret_t ipmi_chassis_get_sys_restart_cause( -+ ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request, -+ ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context) -+{ -+ ipmi_ret_t rc = IPMI_CC_OK; -+ -+ GetSysRestartCauseResponse* resp = (GetSysRestartCauseResponse*)response; -+ std::fill(reinterpret_cast<uint8_t*>(resp), -+ reinterpret_cast<uint8_t*>(resp) + sizeof(*resp), 0); -+ if (*data_len != 0) -+ { -+ rc = IPMI_CC_REQ_DATA_LEN_INVALID; -+ return rc; -+ } -+ -+ try -+ { -+ sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()}; -+ ipmi::DbusObjectInfo hostObject = -+ ipmi::getDbusObject(bus, stateHostInterface); -+ ipmi::Value variant = -+ ipmi::getDbusProperty(bus, hostObject.second, hostObject.first, -+ hostRestartCauseInterface, hostRestartCause); -+ resp->restartCause = variant.get<uint8_t>(); -+ } -+ -+ catch (std::exception& e) -+ { -+ log<level::ERR>(e.what()); -+ rc = IPMI_CC_UNSPECIFIED_ERROR; -+ return rc; -+ } -+ resp->channelNum = 0; // Fix to primary channel. -+ *data_len = sizeof(GetSysRestartCauseResponse); -+ -+ return rc; -+} -+ - /** @brief implements Get POH counter command - * @parameter - * - none -@@ -1739,4 +1789,8 @@ void register_netfn_chassis_functions() - ipmi::chassis::cmdSetPowerRestorePolicy, - ipmi::Privilege::Operator, - ipmiChassisSetPowerRestorePolicy); -+ -+ // <get Host Restart Cause> -+ ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_SYS_RESTART_CAUSE, NULL, -+ ipmi_chassis_get_sys_restart_cause, PRIVILEGE_USER); - } -diff --git a/chassishandler.hpp b/chassishandler.hpp -index 49b5ef8..2c42b11 100644 ---- a/chassishandler.hpp -+++ b/chassishandler.hpp -@@ -17,6 +17,7 @@ enum ipmi_netfn_chassis_cmds - // Set Power Restore Policy - IPMI_CMD_SET_RESTORE_POLICY = 0x06, - // Get capability bits -+ IPMI_CMD_GET_SYS_RESTART_CAUSE = 0x07, - IPMI_CMD_SET_SYS_BOOT_OPTIONS = 0x08, - IPMI_CMD_GET_SYS_BOOT_OPTIONS = 0x09, - IPMI_CMD_GET_POH_COUNTER = 0x0F, -diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf -index c1fca1d..94232de 100644 ---- a/host-ipmid-whitelist.conf -+++ b/host-ipmid-whitelist.conf -@@ -4,6 +4,7 @@ - 0x00:0x02 //<Chassis>:<Chassis Control> - 0x00:0x05 //<Chassis>:<Set Chassis Capabilities> - 0x00:0x06 //<Chassis>:<Set Power Restore Policy> -+0x00:0x07 //<Chassis>:<Get System Restart Cause> - 0x00:0x08 //<Chassis>:<Set System Boot Options> - 0x00:0x09 //<Chassis>:<Get System Boot Options> - 0x00:0x0F //<Chassis>:<Get POH Counter Command> --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0049-Fix-Unspecified-error-on-ipmi-restart-cause-command.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0049-Fix-Unspecified-error-on-ipmi-restart-cause-command.patch deleted file mode 100644 index aba5eb095..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0049-Fix-Unspecified-error-on-ipmi-restart-cause-command.patch +++ /dev/null @@ -1,71 +0,0 @@ -From 59287a8869b5253a1b4203e0cc8a92f063dcc7e6 Mon Sep 17 00:00:00 2001 -From: Yong Li <yong.b.li@linux.intel.com> -Date: Tue, 25 Sep 2018 16:08:22 +0800 -Subject: [PATCH] Fix "Unspecified error" on ipmi restart cause command - -Needs to convert the dbus value(enum) into ipmi value(uint8) - -Tested by: -ipmitool chassis restart_cause - -Signed-off-by: Yong Li <yong.b.li@linux.intel.com> ---- - chassishandler.cpp | 28 ++++++++++++++++++++++++++-- - 1 file changed, 26 insertions(+), 2 deletions(-) - -diff --git a/chassishandler.cpp b/chassishandler.cpp -index 40eb4f5..c3d4931 100644 ---- a/chassishandler.cpp -+++ b/chassishandler.cpp -@@ -106,7 +106,7 @@ static constexpr auto match = "chassis0"; - const static constexpr char* stateHostInterface = - "xyz.openbmc_project.State.Host"; - const static constexpr char* hostRestartCauseInterface = -- "xyz.openbmc_project.State.Host.HostRestartCause"; -+ "xyz.openbmc_project.State.Host"; - const static constexpr char* hostRestartCause = "HostRestartCause"; - const static constexpr char chassisCapIntf[] = - "xyz.openbmc_project.Control.ChassisCapabilities"; -@@ -1764,6 +1764,26 @@ ipmi_ret_t ipmi_chassis_set_sys_boot_options(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - return rc; - } - -+namespace restart_cause -+{ -+ -+using namespace sdbusplus::xyz::openbmc_project::State::server; -+ -+std::map<Host::RestartCause, uint8_t> dbusToIpmi = { -+ {Host::RestartCause::Unknown, 0x0}, -+ {Host::RestartCause::IpmiCommand, 0x1}, -+ {Host::RestartCause::ResetButton, 0x2}, -+ {Host::RestartCause::PowerButton, 0x3}, -+ {Host::RestartCause::WatchdogTimer, 0x4}, -+ {Host::RestartCause::OEM, 0x5}, -+ {Host::RestartCause::PowerPolicyAlwaysOn, 0x6}, -+ {Host::RestartCause::PowerPolicyPreviousState, 0x7}, -+ {Host::RestartCause::PEFReset, 0x8}, -+ {Host::RestartCause::PEFPowerCycle, 0x9}, -+ {Host::RestartCause::SoftReset, 0xa}, -+ {Host::RestartCause::RTCWakeup, 0xb}}; -+} // namespace restart_cause -+ - ipmi_ret_t ipmi_chassis_get_sys_restart_cause( - ipmi_netfn_t netfn, ipmi_cmd_t cmd, ipmi_request_t request, - ipmi_response_t response, ipmi_data_len_t data_len, ipmi_context_t context) -@@ -1787,7 +1807,11 @@ ipmi_ret_t ipmi_chassis_get_sys_restart_cause( - ipmi::Value variant = - ipmi::getDbusProperty(bus, hostObject.second, hostObject.first, - hostRestartCauseInterface, hostRestartCause); -- resp->restartCause = variant.get<uint8_t>(); -+ -+ std::string restartCause = -+ sdbusplus::message::variant_ns::get<std::string>(variant); -+ resp->restartCause = restart_cause::dbusToIpmi.at( -+ restart_cause::Host::convertRestartCauseFromString(restartCause)); - } - - catch (std::exception& e) --- -2.7.4 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0055-Implement-set-front-panel-button-enables-command.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0055-Implement-set-front-panel-button-enables-command.patch deleted file mode 100644 index fd7cf1851..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0055-Implement-set-front-panel-button-enables-command.patch +++ /dev/null @@ -1,176 +0,0 @@ -From b8b88a5c0f9e9cb6023cb8d5453e5cfadaa1a375 Mon Sep 17 00:00:00 2001 -From: Kuiying Wang <kuiying.wang@intel.com> -Date: Fri, 4 Jan 2019 10:50:21 +0800 -Subject: [PATCH] Implement set front panel button enables command - -Through modify buttons' property "Enabled" to disable/enable -corresponding button. -Currently support power and reset button. - -Test-By: ipmitool raw 0x0 0xa 0x2 //disable reset button - ipmitool raw 0x0 0xa 0x1 //disable power button - ipmitool raw 0x0 0xa 0x0 //enable all buttons - -Change-Id: Ice6f58edb898689f7a7fa08ad078d25fccaab27e -Signed-off-by: Kuiying Wang <kuiying.wang@intel.com> ---- - chassishandler.cpp | 98 +++++++++++++++++++++++++++++++++++++++ - chassishandler.hpp | 1 + - host-ipmid-whitelist.conf | 1 + - 3 files changed, 100 insertions(+) - -diff --git a/chassishandler.cpp b/chassishandler.cpp -index 4b42b3c..1a5b805 100644 ---- a/chassishandler.cpp -+++ b/chassishandler.cpp -@@ -112,6 +112,8 @@ const static constexpr char chassisSMDevAddrProp[] = "SMDeviceAddress"; - const static constexpr char chassisBridgeDevAddrProp[] = "BridgeDeviceAddress"; - static constexpr uint8_t chassisCapFlagMask = 0x0f; - static constexpr uint8_t chassisCapAddrMask = 0xfe; -+static constexpr uint8_t disableResetButton = 0x2; -+static constexpr uint8_t disablePowerButton = 0x1; - static constexpr const char* powerButtonIntf = - "xyz.openbmc_project.Chassis.Buttons.Power"; - static constexpr const char* powerButtonPath = -@@ -140,6 +142,19 @@ struct GetPOHCountResponse - uint8_t front_panel_button_cap_status; - } __attribute__((packed)) ipmi_get_chassis_status_t; - -+typedef struct -+{ -+ uint8_t disables; // Front Panel Button Enables -+ //[7:4] - reserved -+ //[3] - 1b = disable Standby (sleep) button for entering standby (sleep) -+ //(control can still be used to wake the system) -+ //[2] - 1b = disable Diagnostic Interrupt button -+ //[1] - 1b = disable Reset button -+ //[0] - 1b = disable Power off button for power off only (in the case there -+ // is a single combined power/standby (sleep) button, then this also -+ // disables sleep requests via that button) -+} __attribute__((packed)) IPMISetFrontPanelButtonEnablesReq; -+ - // Phosphor Host State manager - namespace State = sdbusplus::xyz::openbmc_project::State::server; - -@@ -1721,6 +1738,82 @@ ipmi_ret_t ipmi_chassis_set_power_restore_policy( - return ipmi::responseSuccess(power_policy::allSupport); - } - -+ipmi_ret_t ipmiSetFrontPanelButtonEnables(ipmi_netfn_t netfn, ipmi_cmd_t cmd, -+ ipmi_request_t request, -+ ipmi_response_t response, -+ ipmi_data_len_t data_len, -+ ipmi_context_t context) -+{ -+ bool enable = false; -+ constexpr const char* powerButtonIntf = -+ "xyz.openbmc_project.Chassis.Buttons.Power"; -+ constexpr const char* powerButtonPath = -+ "/xyz/openbmc_project/Chassis/Buttons/Power0"; -+ constexpr const char* resetButtonIntf = -+ "xyz.openbmc_project.Chassis.Buttons.Reset"; -+ constexpr const char* resetButtonPath = -+ "/xyz/openbmc_project/Chassis/Buttons/Reset0"; -+ using namespace chassis::internal; -+ -+ IPMISetFrontPanelButtonEnablesReq* req = -+ static_cast<IPMISetFrontPanelButtonEnablesReq*>(request); -+ if (*data_len != 1) -+ { -+ *data_len = 0; -+ log<level::ERR>("IPMI request len is invalid"); -+ return IPMI_CC_REQ_DATA_LEN_INVALID; -+ } -+ *data_len = 0; -+ if (req->disables & disablePowerButton) -+ { -+ // Disable power button -+ enable = false; -+ } -+ else -+ { -+ // Enable power button -+ enable = true; -+ } -+ // set power button Enabled property -+ try -+ { -+ auto service = ipmi::getService(dbus, powerButtonIntf, powerButtonPath); -+ ipmi::setDbusProperty(dbus, service, powerButtonPath, powerButtonIntf, -+ "Enabled", enable); -+ } -+ catch (sdbusplus::exception::SdBusError& e) -+ { -+ log<level::ERR>(e.what()); -+ log<level::ERR>("Fail to set power button Enabled property"); -+ return IPMI_CC_UNSPECIFIED_ERROR; -+ } -+ -+ if (req->disables & disableResetButton) -+ { -+ // disable reset button -+ enable = false; -+ } -+ else -+ { -+ // enable reset button -+ enable = true; -+ } -+ // set reset button Enabled property -+ try -+ { -+ auto service = ipmi::getService(dbus, resetButtonIntf, resetButtonPath); -+ ipmi::setDbusProperty(dbus, service, resetButtonPath, resetButtonIntf, -+ "Enabled", enable); -+ } -+ catch (sdbusplus::exception::SdBusError& e) -+ { -+ log<level::ERR>(e.what()); -+ log<level::ERR>("Fail to set reset button Enabled property"); -+ return IPMI_CC_UNSPECIFIED_ERROR; -+ } -+ return IPMI_CC_OK; -+} -+ - void register_netfn_chassis_functions() - { - createIdentifyTimer(); -@@ -1733,6 +1826,11 @@ void register_netfn_chassis_functions() - ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_GET_CHASSIS_CAP, NULL, - ipmi_get_chassis_cap, PRIVILEGE_USER); - -+ // Set Front Panel Button Enables -+ ipmi_register_callback(NETFUN_CHASSIS, -+ IPMI_CMD_SET_FRONT_PANEL_BUTTON_ENABLES, NULL, -+ ipmiSetFrontPanelButtonEnables, PRIVILEGE_ADMIN); -+ - // Set Chassis Capabilities - ipmi_register_callback(NETFUN_CHASSIS, IPMI_CMD_SET_CHASSIS_CAP, NULL, - ipmi_set_chassis_cap, PRIVILEGE_USER); -diff --git a/chassishandler.hpp b/chassishandler.hpp -index 49b5ef8..f4a6bff 100644 ---- a/chassishandler.hpp -+++ b/chassishandler.hpp -@@ -19,6 +19,7 @@ enum ipmi_netfn_chassis_cmds - IPMI_CMD_GET_SYS_RESTART_CAUSE = 0x07, - IPMI_CMD_SET_SYS_BOOT_OPTIONS = 0x08, - IPMI_CMD_GET_SYS_BOOT_OPTIONS = 0x09, -+ IPMI_CMD_SET_FRONT_PANEL_BUTTON_ENABLES = 0x0A, - IPMI_CMD_GET_POH_COUNTER = 0x0F, - }; - -diff --git a/host-ipmid-whitelist.conf b/host-ipmid-whitelist.conf -index e5cd0b5..d96d9ed 100644 ---- a/host-ipmid-whitelist.conf -+++ b/host-ipmid-whitelist.conf -@@ -6,6 +6,7 @@ - 0x00:0x07 //<Chassis>:<Get System Restart Cause> - 0x00:0x08 //<Chassis>:<Set System Boot Options> - 0x00:0x09 //<Chassis>:<Get System Boot Options> -+0x00:0x0A //<Chassis>:<Set Front Panel Button Enables> - 0x00:0x0F //<Chassis>:<Get POH Counter Command> - 0x04:0x02 //<Sensor/Event>:<Platform event> - 0x04:0x2D //<Sensor/Event>:<Get Sensor Reading> --- -2.19.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0058-Add-AC-failed-bit-support-for-get-chassis-status-com.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0058-Add-AC-failed-bit-support-for-get-chassis-status-com.patch deleted file mode 100644 index 42bb682c4..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0058-Add-AC-failed-bit-support-for-get-chassis-status-com.patch +++ /dev/null @@ -1,76 +0,0 @@ -From f51bef8f7c5785405ee5c83a921efb1bc05e4947 Mon Sep 17 00:00:00 2001 -From: Yong Li <yong.b.li@linux.intel.com> -Date: Wed, 27 Mar 2019 16:11:25 +0800 -Subject: [PATCH] =?UTF-8?q?Add=20=E2=80=9CAC=20failed=E2=80=9D=20bit=20sup?= - =?UTF-8?q?port=20for=20get=20chassis=20status=20command?= -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -PFail property is provided by power control service, -ture means the booting is from AC loss. - -Tested: -Remove the AC cable and reconnect it -Ipmitool chassis status to check the status: -Last Power Event : ac-failed - -Signed-off-by: Yong Li <yong.b.li@linux.intel.com> ---- - chassishandler.cpp | 26 ++++++++++++++++++++++++++ - 1 file changed, 26 insertions(+) - -diff --git a/chassishandler.cpp b/chassishandler.cpp -index 7a522ad..40d2018 100644 ---- a/chassishandler.cpp -+++ b/chassishandler.cpp -@@ -844,6 +844,7 @@ ipmi_ret_t ipmi_get_chassis_status(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - sd_bus_message* reply = NULL; - int r = 0; - int pgood = 0; -+ bool pFail = true; - char* busname = NULL; - ipmi_ret_t rc = IPMI_CC_OK; - ipmi_get_chassis_status_t chassis_status{}; -@@ -904,6 +905,26 @@ ipmi_ret_t ipmi_get_chassis_status(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - goto finish; - } - -+ r = sd_bus_get_property(bus, busname, objname, intf, "PFail", NULL, &reply, -+ "b"); -+ if (r < 0) -+ { -+ log<level::ERR>("Failed to call sd_bus_get_property", -+ entry("PROPERTY=%s", "PFail"), entry("ERRNO=0x%X", -r), -+ entry("BUS=%s", busname), entry("PATH=%s", objname), -+ entry("INTERFACE=%s", intf)); -+ rc = IPMI_CC_UNSPECIFIED_ERROR; -+ goto finish; -+ } -+ -+ r = sd_bus_message_read(reply, "b", &pFail); -+ if (r < 0) -+ { -+ log<level::ERR>("Failed to read PFail:", entry("ERRNO=0x%X", -r)); -+ rc = IPMI_CC_UNSPECIFIED_ERROR; -+ goto finish; -+ } -+ - s = dbusToIpmi.at(powerRestore); - - // Current Power State -@@ -952,6 +973,11 @@ ipmi_ret_t ipmi_get_chassis_status(ipmi_netfn_t netfn, ipmi_cmd_t cmd, - - chassis_status.last_power_event = 0; - -+ if (pFail) -+ { -+ chassis_status.last_power_event |= 1; -+ } -+ - // Misc. Chassis State - // [7] – reserved - // [6] – 1b = Chassis Identify command and state info supported (Optional) --- -2.7.4 - 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 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 <cheng.c.yang@intel.com> -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 <cheng.c.yang@intel.com> --- 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 //<Storage>:<Set SEL Time> 0x0C:0x02 //<Transport>:<Get LAN Configuration Parameters> 0x0C:0x21 //<Transport>:<Set SOL Configuration Parameters> @@ -41,22 +40,15 @@ index 2ce44c6..383b412 100644 0x2C:0x01 //<Group Extension>:<Get DCMI Capabilities> 0x2C:0x02 //<Group Extension>:<Get Power Reading> 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<std::string, 3> 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<int, std::unique_ptr<struct ChannelConfig_t>> 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<uint8_t, std::optional<uint8_t>, std::optional<uint8_t>> ++ 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<const GetSOLConfParamsRequest*>(request); -+ std::vector<uint8_t> outPayload; -+ -+ if (*dataLen < sizeof(GetSOLConfParamsRequest) - 2) ++ 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))) || ++ (ipmi::EChannelSessSupported::none == ++ ipmi::getChannelSessionSupport(static_cast<uint8_t>(channelNum)))) + { -+ *dataLen = 0; -+ return IPMI_CC_REQ_DATA_LEN_INVALID; ++ return ipmi::responseInvalidFieldRequest(); ++ } ++ 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(); + } + -+ *dataLen = 0; -+ -+ outPayload.push_back(solParameterRevision); -+ if (reqData->getParamRev) ++ if (getParamRev) + { -+ std::copy(outPayload.begin(), outPayload.end(), -+ static_cast<uint8_t*>(response)); -+ *dataLen = outPayload.size(); -+ return IPMI_CC_OK; ++ return ipmi::responseSuccess(solParameterRevision, std::nullopt, ++ std::nullopt); + } + + ipmi::Value value; -+ switch (static_cast<sol::Parameter>(reqData->paramSelector)) ++ switch (static_cast<sol::Parameter>(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<uint8_t>(value)); -+ break; ++ return ipmi::responseSuccess( ++ solParameterRevision, std::get<uint8_t>(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<uint8_t>(std::get<bool>(value))); -+ break; ++ return ipmi::responseSuccess( ++ solParameterRevision, ++ static_cast<uint8_t>(std::get<bool>(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<uint8_t>(value) & 0x0f); + -+ if (getSOLParameter("ForceAuthentication", value) < 0) ++ if (getSOLParameter("ForceAuthentication", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } + authentication |= + (static_cast<uint8_t>(std::get<bool>(value)) << 6); + -+ if (getSOLParameter("ForceEncryption", value) < 0) ++ if (getSOLParameter("ForceEncryption", value, channelNum) < 0) + { -+ return IPMI_CC_UNSPECIFIED_ERROR; ++ return ipmi::responseUnspecifiedError(); + } + authentication |= + (static_cast<uint8_t>(std::get<bool>(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<uint8_t>(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<uint8_t>(value)); -+ break; ++ return ipmi::responseSuccess(solParameterRevision, ++ std::get<uint8_t>(value), ++ std::get<uint8_t>(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<uint8_t>(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<uint8_t>(value)); -+ break; ++ return ipmi::responseSuccess( ++ solParameterRevision, std::get<uint8_t>(value) & retryCountMask, ++ std::get<uint8_t>(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<const uint8_t*>(&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<uint32_t>(&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<uint8_t*>(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<const SetConfParamsRequest*>(request); -+ auto reqData = reinterpret_cast<const SetSOLConfParamsRequest*>(request); - - // Check request length first - switch (static_cast<sol::Parameter>(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 <ipmid/types.hpp> -+#include <map> - #include <string> - // 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 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0061-Use-xyz.openbmc_project.State.Chassis-for-IPMI-chass.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0061-Use-xyz.openbmc_project.State.Chassis-for-IPMI-chass.patch deleted file mode 100644 index 877c5336a..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0061-Use-xyz.openbmc_project.State.Chassis-for-IPMI-chass.patch +++ /dev/null @@ -1,127 +0,0 @@ -From 514b76d1c05d7ed7fb7e1df27833e423e04c9a1c Mon Sep 17 00:00:00 2001 -From: "Jason M. Bills" <jason.m.bills@linux.intel.com> -Date: Tue, 21 May 2019 09:57:16 -0700 -Subject: [PATCH] Use xyz.openbmc_project.State.Chassis for IPMI chassis status - -Instead of directly using pgood on dbus, this change uses the -xyz.openbmc_project.State.Chassis "CurrentPowerState" property -for the IPMI chassis status command. This will allow us to -remove pgood from dbus. - -Tested: -Ran IPMI chassis commands and confirmed that they behave as -expected: -ipmitool power status -Chassis Power is on - -ipmitool power off -Chassis Power Control: Down/Off - -ipmitool power status -Chassis Power is off - -ipmitool power on -Chassis Power Control: Up/On - -ipmitool power status -Chassis Power is on - -Change-Id: I7836c16b76c3b309f176186f3e2453082e4cd1af -Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com> ---- - chassishandler.cpp | 61 ++++++++++++++++++++++++++++++++++++------------------ - 1 file changed, 41 insertions(+), 20 deletions(-) - -diff --git a/chassishandler.cpp b/chassishandler.cpp -index 1738ccc..e4e842d 100644 ---- a/chassishandler.cpp -+++ b/chassishandler.cpp -@@ -824,44 +824,65 @@ std::optional<uint2_t> getPowerRestorePolicy() - */ - std::optional<bool> getPowerStatus() - { -- constexpr const char* powerControlObj = -- "/xyz/openbmc_project/Chassis/Control/Power0"; -- constexpr const char* powerControlIntf = -- "xyz.openbmc_project.Chassis.Control.Power"; - bool powerGood = false; - std::shared_ptr<sdbusplus::asio::connection> busp = getSdBus(); - try - { -+ constexpr const char* chassisStatePath = -+ "/xyz/openbmc_project/state/chassis0"; -+ constexpr const char* chassisStateIntf = -+ "xyz.openbmc_project.State.Chassis"; - auto service = -- ipmi::getService(*busp, powerControlIntf, powerControlObj); -+ ipmi::getService(*busp, chassisStateIntf, chassisStatePath); - -- ipmi::Value variant = ipmi::getDbusProperty( -- *busp, service, powerControlObj, powerControlIntf, "pgood"); -- powerGood = static_cast<bool>(std::get<int>(variant)); -+ ipmi::Value variant = -+ ipmi::getDbusProperty(*busp, service, chassisStatePath, -+ chassisStateIntf, "CurrentPowerState"); -+ std::string powerState = std::get<std::string>(variant); -+ if (powerState == "xyz.openbmc_project.State.Chassis.PowerState.On") -+ { -+ powerGood = true; -+ } - } - catch (const std::exception& e) - { - try - { -- // FIXME: some legacy modules use the older path; try that next -- constexpr const char* legacyPwrCtrlObj = -- "/org/openbmc/control/power0"; -- constexpr const char* legacyPwrCtrlIntf = -- "org.openbmc.control.Power"; -+ // FIXME: some modules use pgood; try that next -+ constexpr const char* powerControlObj = -+ "/xyz/openbmc_project/Chassis/Control/Power0"; -+ constexpr const char* powerControlIntf = -+ "xyz.openbmc_project.Chassis.Control.Power"; - auto service = -- ipmi::getService(*busp, legacyPwrCtrlIntf, legacyPwrCtrlObj); -+ ipmi::getService(*busp, powerControlIntf, powerControlObj); - - ipmi::Value variant = ipmi::getDbusProperty( -- *busp, service, legacyPwrCtrlObj, legacyPwrCtrlIntf, "pgood"); -+ *busp, service, powerControlObj, powerControlIntf, "pgood"); - powerGood = static_cast<bool>(std::get<int>(variant)); - } - catch (const std::exception& e) - { -- log<level::ERR>("Failed to fetch pgood property", -- entry("ERROR=%s", e.what()), -- entry("PATH=%s", powerControlObj), -- entry("INTERFACE=%s", powerControlIntf)); -- return std::nullopt; -+ try -+ { -+ // FIXME: some legacy modules use the older path; try that next -+ constexpr const char* legacyPwrCtrlObj = -+ "/org/openbmc/control/power0"; -+ constexpr const char* legacyPwrCtrlIntf = -+ "org.openbmc.control.Power"; -+ auto service = ipmi::getService(*busp, legacyPwrCtrlIntf, -+ legacyPwrCtrlObj); -+ -+ ipmi::Value variant = -+ ipmi::getDbusProperty(*busp, service, legacyPwrCtrlObj, -+ legacyPwrCtrlIntf, "pgood"); -+ powerGood = static_cast<bool>(std::get<int>(variant)); -+ } -+ catch (const std::exception& e) -+ { -+ log<level::ERR>("Failed to fetch pgood property", -+ entry("ERROR=%s", e.what())); -+ return std::nullopt; -+ } - } - } - return std::make_optional(powerGood); --- -2.7.4 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0062-Update-IPMI-Chassis-Control-command.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0062-Update-IPMI-Chassis-Control-command.patch index 498233881..f29111758 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0062-Update-IPMI-Chassis-Control-command.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0062-Update-IPMI-Chassis-Control-command.patch @@ -1,4 +1,4 @@ -From f11928c6b39052c679c9300e9d836837ef60be06 Mon Sep 17 00:00:00 2001 +From 00fb92edcb4229eeb5b46c4eb206ba7d70e241fc Mon Sep 17 00:00:00 2001 From: "Jason M. Bills" <jason.m.bills@linux.intel.com> Date: Mon, 3 Jun 2019 17:01:47 -0700 Subject: [PATCH] Update IPMI Chassis Control command @@ -19,11 +19,11 @@ ipmitool power soft: soft power-off requested from system software Change-Id: Ic9fba3ca4abd9a758eb88f1e6ee09f7ca64ff80a Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com> --- - chassishandler.cpp | 138 +++++++++++++++++++++-------------------------------- - 1 file changed, 54 insertions(+), 84 deletions(-) + chassishandler.cpp | 206 ++++++++++++++--------------------------------------- + 1 file changed, 52 insertions(+), 154 deletions(-) diff --git a/chassishandler.cpp b/chassishandler.cpp -index e4e842d..d71b95f 100644 +index 88bf84b..ad564e2 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -31,6 +31,7 @@ @@ -134,7 +134,84 @@ index e4e842d..d71b95f 100644 } namespace power_policy -@@ -1138,61 +1143,26 @@ ipmi::RspType<> ipmiChassisControl(uint8_t chassisControl) +@@ -1033,76 +1038,6 @@ ipmi::RspType<bool, // Power is on + diagButtonDisableAllow, sleepButtonDisableAllow); + } + +-//------------------------------------------------------------- +-// Send a command to SoftPowerOff application to stop any timer +-//------------------------------------------------------------- +-int stop_soft_off_timer() +-{ +- constexpr auto iface = "org.freedesktop.DBus.Properties"; +- constexpr auto soft_off_iface = "xyz.openbmc_project.Ipmi.Internal." +- "SoftPowerOff"; +- +- constexpr auto property = "ResponseReceived"; +- constexpr auto value = "xyz.openbmc_project.Ipmi.Internal." +- "SoftPowerOff.HostResponse.HostShutdown"; +- +- // Get the system bus where most system services are provided. +- auto bus = ipmid_get_sd_bus_connection(); +- +- // Get the service name +- // TODO openbmc/openbmc#1661 - Mapper refactor +- // +- // See openbmc/openbmc#1743 for some details but high level summary is that +- // for now the code will directly call the soft off interface due to a +- // race condition with mapper usage +- // +- // char *busname = nullptr; +- // auto r = mapper_get_service(bus, SOFTOFF_OBJPATH, &busname); +- // if (r < 0) +- //{ +- // fprintf(stderr, "Failed to get %s bus name: %s\n", +- // SOFTOFF_OBJPATH, -r); +- // return r; +- //} +- +- // No error object or reply expected. +- int rc = sd_bus_call_method(bus, SOFTOFF_BUSNAME, SOFTOFF_OBJPATH, iface, +- "Set", nullptr, nullptr, "ssv", soft_off_iface, +- property, "s", value); +- if (rc < 0) +- { +- log<level::ERR>("Failed to set property in SoftPowerOff object", +- entry("ERRNO=0x%X", -rc)); +- } +- +- // TODO openbmc/openbmc#1661 - Mapper refactor +- // free(busname); +- return rc; +-} +- +-//---------------------------------------------------------------------- +-// Create file to indicate there is no need for softoff notification to host +-//---------------------------------------------------------------------- +-void indicate_no_softoff_needed() +-{ +- fs::path path{HOST_INBAND_REQUEST_DIR}; +- if (!fs::is_directory(path)) +- { +- fs::create_directory(path); +- } +- +- // Add the host instance (default 0 for now) to the file name +- std::string file{HOST_INBAND_REQUEST_FILE}; +- auto size = std::snprintf(nullptr, 0, file.c_str(), 0); +- size++; // null +- std::unique_ptr<char[]> buf(new char[size]); +- std::snprintf(buf.get(), size, file.c_str(), 0); +- +- // Append file name to directory and create it +- path /= buf.get(); +- std::ofstream(path.c_str()); +-} +- + /** @brief Implementation of chassis control command + * + * @param - chassisControl command byte +@@ -1115,61 +1050,24 @@ ipmi::RspType<> ipmiChassisControl(uint8_t chassisControl) switch (chassisControl) { case CMD_POWER_ON: @@ -204,8 +281,6 @@ index e4e842d..d71b95f 100644 + rc = initiateHostStateTransition(State::Host::Transition::Off); + break; + case CMD_PULSE_DIAGNOSTIC_INTR: -+ rc = -+ initiateHostStateTransition(State::Host::Transition::Interrupt); break; default: diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0064-Enable-watchdog-to-save-useflag-after-host-power-off.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0064-Enable-watchdog-to-save-useflag-after-host-power-off.patch new file mode 100644 index 000000000..6a7b056ab --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0064-Enable-watchdog-to-save-useflag-after-host-power-off.patch @@ -0,0 +1,29 @@ +diff --git a/app/watchdog.cpp b/app/watchdog.cpp +index 2938d23..bc5df29 100644 +--- a/app/watchdog.cpp ++++ b/app/watchdog.cpp +@@ -445,23 +445,21 @@ ipmi_ret_t ipmi_app_watchdog_get(ipmi_netfn_t netfn, ipmi_cmd_t cmd, + wdTimerUseToIpmiTimerUse(wd_prop.expiredTimerUse)); + } + ++ res.expire_flags = timerUseExpirationFlags; + if (wd_prop.enabled) + { + res.timer_use |= wd_running; + res.present_countdown = htole16(wd_prop.timeRemaining / 100); +- res.expire_flags = 0; + } + else + { + if (wd_prop.expiredTimerUse == WatchdogService::TimerUse::Reserved) + { + res.present_countdown = res.initial_countdown; +- res.expire_flags = 0; + } + else + { + res.present_countdown = 0; +- res.expire_flags = timerUseExpirationFlags; + } + } + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0064-Update-provisioning-mode-filter-logic.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0064-Update-provisioning-mode-filter-logic.patch new file mode 100644 index 000000000..57a31c991 --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/0064-Update-provisioning-mode-filter-logic.patch @@ -0,0 +1,286 @@ +From 3279300bb9afd1f169b35b7830d7f054045ab35f Mon Sep 17 00:00:00 2001 +From: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> +Date: Tue, 18 Jun 2019 19:42:30 +0530 +Subject: [PATCH] Update provisioning mode filter logic + +Updated provisioning mode filtering logic support. Based on the +RestrictionMode property, Host (system) interface commands will be +filtered as per the allowed list in ProvisionedHostWhitelist once +POST complete is achieved. No commands will be allowed in +ProvisionedHostDisabled after POST complete and in all other cases +filterning logic will not be applied. + +Tested +1. Verified the filtering logic through EFI shell and made sure +filtering logic is applied when RestrictionMode is in +ProvisionedHostWhitelist mode +2. Verified no filtering logic is applied in normal modes +3. Made sure BIOS is able to execute commands, which are not in +whitelist (Note: New whitelist conf is under review). + +Change-Id: I7a14e827d70e2d8d6975e600a0fd00e2a790bc22 +Signed-off-by: Richard Marian Thomaiyar <richard.marian.thomaiyar@linux.intel.com> +--- + whitelist-filter.cpp | 155 ++++++++++++++++++++++++++++++++++++++++----------- + 1 file changed, 122 insertions(+), 33 deletions(-) + +diff --git a/whitelist-filter.cpp b/whitelist-filter.cpp +index 9f1e7c8..2c56087 100644 +--- a/whitelist-filter.cpp ++++ b/whitelist-filter.cpp +@@ -25,6 +25,7 @@ namespace + */ + class WhitelistFilter + { ++ + public: + WhitelistFilter(); + ~WhitelistFilter() = default; +@@ -35,17 +36,26 @@ class WhitelistFilter + + private: + void postInit(); +- void cacheRestrictedMode(); ++ void cacheRestrictedAndPostCompleteMode(); + void handleRestrictedModeChange(sdbusplus::message::message& m); ++ void handlePostCompleteChange(sdbusplus::message::message& m); + ipmi::Cc filterMessage(ipmi::message::Request::ptr request); + +- bool restrictedMode = true; ++ sdbusplus::xyz::openbmc_project::Control::Security::server:: ++ RestrictionMode::Modes restrictionMode = ++ sdbusplus::xyz::openbmc_project::Control::Security::server:: ++ RestrictionMode::Modes::ProvisionedHostWhitelist; ++ bool postCompleted = false; + std::shared_ptr<sdbusplus::asio::connection> bus; + std::unique_ptr<settings::Objects> objects; ++ std::unique_ptr<settings::Objects> postCompleteObj; + std::unique_ptr<sdbusplus::bus::match::match> modeChangeMatch; ++ std::unique_ptr<sdbusplus::bus::match::match> postCompleteMatch; + + static constexpr const char restrictionModeIntf[] = + "xyz.openbmc_project.Control.Security.RestrictionMode"; ++ static constexpr const char* systemOsStatusIntf = ++ "xyz.openbmc_project.State.OperatingSystem.Status"; + }; + + WhitelistFilter::WhitelistFilter() +@@ -63,16 +73,22 @@ WhitelistFilter::WhitelistFilter() + post_work([this]() { postInit(); }); + } + +-void WhitelistFilter::cacheRestrictedMode() ++void WhitelistFilter::cacheRestrictedAndPostCompleteMode() + { + using namespace sdbusplus::xyz::openbmc_project::Control::Security::server; + std::string restrictionModeSetting; + std::string restrictionModeService; ++ std::string systemOsStatusPath; ++ std::string systemOsStatusService; + try + { + restrictionModeSetting = objects->map.at(restrictionModeIntf).at(0); + restrictionModeService = + objects->service(restrictionModeSetting, restrictionModeIntf); ++ ++ systemOsStatusPath = postCompleteObj->map.at(systemOsStatusIntf).at(0); ++ systemOsStatusService = ++ postCompleteObj->service(systemOsStatusPath, systemOsStatusIntf); + } + catch (const std::out_of_range& e) + { +@@ -80,26 +96,50 @@ void WhitelistFilter::cacheRestrictedMode() + "Could not look up restriction mode interface from cache"); + return; + } ++ + bus->async_method_call( + [this](boost::system::error_code ec, ipmi::Value v) { + if (ec) + { + log<level::ERR>("Error in RestrictionMode Get"); + // Fail-safe to true. +- restrictedMode = true; ++ restrictionMode = ++ RestrictionMode::Modes::ProvisionedHostWhitelist; + return; + } + auto mode = std::get<std::string>(v); +- auto restrictionMode = +- RestrictionMode::convertModesFromString(mode); +- restrictedMode = +- (restrictionMode == RestrictionMode::Modes::Whitelist); +- log<level::INFO>((restrictedMode ? "Set restrictedMode = true" +- : "Set restrictedMode = false")); ++ restrictionMode = RestrictionMode::convertModesFromString(mode); ++ log<level::INFO>( ++ "Read restriction mode", ++ entry("VALUE=%d", static_cast<int>(restrictionMode))); + }, + restrictionModeService, restrictionModeSetting, + "org.freedesktop.DBus.Properties", "Get", restrictionModeIntf, + "RestrictionMode"); ++ ++ bus->async_method_call( ++ [this](boost::system::error_code ec, const ipmi::Value& v) { ++ if (ec) ++ { ++ log<level::ERR>("Error in OperatingSystemState Get"); ++ postCompleted = true; ++ return; ++ } ++ auto value = std::get<std::string>(v); ++ if (value == "Standby") ++ { ++ postCompleted = true; ++ } ++ else ++ { ++ postCompleted = false; ++ } ++ log<level::INFO>("Read POST complete value", ++ entry("VALUE=%d", postCompleted)); ++ }, ++ systemOsStatusService, systemOsStatusPath, ++ "org.freedesktop.DBus.Properties", "Get", systemOsStatusIntf, ++ "OperatingSystemState"); + } + + void WhitelistFilter::handleRestrictedModeChange(sdbusplus::message::message& m) +@@ -112,23 +152,44 @@ void WhitelistFilter::handleRestrictedModeChange(sdbusplus::message::message& m) + { + if (property.first == "RestrictionMode") + { +- RestrictionMode::Modes restrictionMode = +- RestrictionMode::convertModesFromString( +- std::get<std::string>(property.second)); +- restrictedMode = +- (restrictionMode == RestrictionMode::Modes::Whitelist); +- log<level::INFO>((restrictedMode +- ? "Updated restrictedMode = true" +- : "Updated restrictedMode = false")); ++ restrictionMode = RestrictionMode::convertModesFromString( ++ std::get<std::string>(property.second)); ++ log<level::INFO>( ++ "Updated restriction mode", ++ entry("VALUE=%d", static_cast<int>(restrictionMode))); ++ } ++ } ++} ++void WhitelistFilter::handlePostCompleteChange(sdbusplus::message::message& m) ++{ ++ std::string intf; ++ std::vector<std::pair<std::string, ipmi::Value>> propertyList; ++ m.read(intf, propertyList); ++ for (const auto& property : propertyList) ++ { ++ if (property.first == "OperatingSystemState") ++ { ++ std::string value = std::get<std::string>(property.second); ++ if (value == "Standby") ++ { ++ postCompleted = true; ++ } ++ else ++ { ++ postCompleted = false; ++ } ++ log<level::INFO>(postCompleted ? "Updated to POST Complete" ++ : "Updated to !POST Complete"); + } + } + } +- + void WhitelistFilter::postInit() + { + objects = std::make_unique<settings::Objects>( + *bus, std::vector<settings::Interface>({restrictionModeIntf})); +- if (!objects) ++ postCompleteObj = std::make_unique<settings::Objects>( ++ *bus, std::vector<settings::Interface>({systemOsStatusIntf})); ++ if (!objects || !postCompleteObj) + { + log<level::ERR>( + "Failed to create settings object; defaulting to restricted mode"); +@@ -136,37 +197,65 @@ void WhitelistFilter::postInit() + } + + // Initialize restricted mode +- cacheRestrictedMode(); ++ cacheRestrictedAndPostCompleteMode(); + // Wait for changes on Restricted mode +- std::string filterStr; ++ std::string filterStrModeChange; ++ std::string filterStrPostComplete; + try + { +- filterStr = sdbusplus::bus::match::rules::propertiesChanged( ++ filterStrModeChange = sdbusplus::bus::match::rules::propertiesChanged( + objects->map.at(restrictionModeIntf).at(0), restrictionModeIntf); ++ filterStrPostComplete = sdbusplus::bus::match::rules::propertiesChanged( ++ postCompleteObj->map.at(systemOsStatusIntf).at(0), ++ systemOsStatusIntf); + } + catch (const std::out_of_range& e) + { +- log<level::ERR>("Failed to determine restriction mode filter string"); ++ log<level::ERR>("Failed to determine restriction mode / POST complete " ++ "filter string"); + return; + } + modeChangeMatch = std::make_unique<sdbusplus::bus::match::match>( +- *bus, filterStr, [this](sdbusplus::message::message& m) { ++ *bus, filterStrModeChange, [this](sdbusplus::message::message& m) { + handleRestrictedModeChange(m); + }); ++ postCompleteMatch = std::make_unique<sdbusplus::bus::match::match>( ++ *bus, filterStrPostComplete, [this](sdbusplus::message::message& m) { ++ handlePostCompleteChange(m); ++ }); + } + + ipmi::Cc WhitelistFilter::filterMessage(ipmi::message::Request::ptr request) + { +- if (request->ctx->channel == ipmi::channelSystemIface && restrictedMode) ++ using namespace sdbusplus::xyz::openbmc_project::Control::Security::server; ++ ++ if (request->ctx->channel == ipmi::channelSystemIface && ++ (restrictionMode != RestrictionMode::Modes::None && ++ restrictionMode != RestrictionMode::Modes::Provisioning)) + { +- if (!std::binary_search( +- whitelist.cbegin(), whitelist.cend(), +- std::make_pair(request->ctx->netFn, request->ctx->cmd))) ++ if (!postCompleted) + { +- log<level::ERR>("Net function not whitelisted", +- entry("NETFN=0x%X", int(request->ctx->netFn)), +- entry("CMD=0x%X", int(request->ctx->cmd))); +- return ipmi::ccInsufficientPrivilege; ++ // Allow all commands, till POST is not completed ++ return ipmi::ccSuccess; ++ } ++ switch (restrictionMode) ++ { ++ case RestrictionMode::Modes::ProvisionedHostWhitelist: ++ { ++ if (!std::binary_search( ++ whitelist.cbegin(), whitelist.cend(), ++ std::make_pair(request->ctx->netFn, request->ctx->cmd))) ++ { ++ log<level::ERR>( ++ "Net function not whitelisted", ++ entry("NETFN=0x%X", int(request->ctx->netFn)), ++ entry("CMD=0x%X", int(request->ctx->cmd))); ++ return ipmi::ccInsufficientPrivilege; ++ } ++ break; ++ } ++ default: // for whitelist, blacklist & HostDisabled ++ return ipmi::ccInsufficientPrivilege; + } + } + return ipmi::ccSuccess; +-- +2.7.4 + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/host-ipmid-whitelist.conf b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/host-ipmid-whitelist.conf new file mode 100644 index 000000000..deed53b0b --- /dev/null +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/host-ipmid-whitelist.conf @@ -0,0 +1,50 @@ +#<NetFn>:<Command +0x00:0x00 //<Chassis>:<Chassis Capabiliti> +0x00:0x01 //<Chassis>:<Get Chassis Status> +0x00:0x07 //<Chassis>:<Get System Restart Cause> +0x00:0x09 //<Chassis>:<Get System Boot Options> +0x00:0x0F //<Chassis>:<Get POH Counter Command> +0x04:0x02 //<Sensor/Event>:<Platform event> +0x04:0x2D //<Sensor/Event>:<Get Sensor Reading> +0x04:0x2F //<Sensor/Event>:<Get Sensor Type> +0x06:0x01 //<App>:<Get Device ID> +0x06:0x04 //<App>:<Get Self Test Results> +0x06:0x07 //<App>:<Get ACPI Power State> +0x06:0x08 //<App>:<Get Device GUID> +0x06:0x22 //<App>:<Reset Watchdog Timer> +0x06:0x24 //<App>:<Set Watchdog Timer> +0x06:0x25 //<App>:<Get Watchdog Timer> +0x06:0x2F //<App>:<Get BMC Global Enables> +0x06:0x31 //<App>:<Get Message Flags> +0x06:0x35 //<App>:<Read Event Message Buffer> +0x06:0x36 //<App>:<Get BT Interface Capabilities> +0x06:0x37 //<App>:<Get System GUID> +0x06:0x42 //<App>:<Get Channel Info Command> +0x06:0x4E //<App>:<Get Channel Payload Support> +0x06:0x54 //<App>:<Get Channel Cipher Suites> +0x0A:0x10 //<Storage>:<Get FRU Inventory Area Info> +0x0A:0x11 //<Storage>:<Read FRU Data> +0x0A:0x20 //<Storage>:<Get SDR Repository Info> +0x0A:0x22 //<Storage>:<Reserve SDR Repository> +0x0A:0x23 //<Storage>:<Get SDR> +0x0A:0x40 //<Storage>:<Get SEL Info> +0x0A:0x42 //<Storage>:<Reserve SEL> +0x0A:0x44 //<Storage>:<Add SEL Entry> +0x0A:0x48 //<Storage>:<Get SEL Time> +0x0A:0x49 //<Storage>:<Set SEL Time> +0x0C:0x02 //<Transport>:<Get LAN Configuration Parameters> +0x0C:0x22 //<Transport>:<Get SOL Configuration Parameters> +0x2C:0x00 //<Group Extension>:<Group Extension Command> +0x2C:0x01 //<Group Extension>:<Get DCMI Capabilities> +0x2C:0x02 //<Group Extension>:<Get Power Reading> +0x2C:0x03 //<Group Extension>:<Get Power Limit> +0x2C:0x06 //<Group Extension>:<Get Asset Tag> +0x2C:0x07 //<Group Extension>:<Get Sensor Info> +0x2C:0x10 //<Group Extension>:<Get Temperature Readings> +0x30:0x27 //<OEM>:<Get Device Info> +0x30:0x31 //<OEM>:<Get AIC card FRU> +0x30:0x55 //<OEM>:<Get Power Restore Delay> +0x30:0x9A //<OEM>:<Get Processor Error Config> +0x30:0xB0 //<OEM>:<Get LED Status> +0x30:0xE9 //<OEM>:<Get BIOS Post Codes> + diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service index d855eaa5b..b09bbf890 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host/phosphor-ipmi-host.service @@ -7,8 +7,10 @@ Wants=mapper-wait@-xyz-openbmc_project-control-host0-boot-one_time.service After=mapper-wait@-xyz-openbmc_project-control-host0-boot-one_time.service Wants=mapper-wait@-xyz-openbmc_project-control-host0-power_restore_policy.service After=mapper-wait@-xyz-openbmc_project-control-host0-power_restore_policy.service -Wants=mapper-wait@-xyz-openbmc_project-control-host0-restriction_mode.service -After=mapper-wait@-xyz-openbmc_project-control-host0-restriction_mode.service +Wants=mapper-wait@-xyz-openbmc_project-control-security-restriction_mode.service +After=mapper-wait@-xyz-openbmc_project-control-security-restriction_mode.service +Wants=mapper-wait@-xyz-openbmc_project-state-os.service +After=mapper-wait@-xyz-openbmc_project-state-os.service Wants=clear-once.service After=clear-once.service diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend index a6a142ec8..d8f9203c9 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-host_%.bbappend @@ -3,25 +3,24 @@ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" # TODO: This should be removed, once up-stream bump up # issue is resolved #SRC_URI = "git://github.com/openbmc/phosphor-host-ipmid" -SRCREV = "0b979b61c12ffe6ab8a27acf8ad2a0165d687195" +SRCREV = "894d022017215acceafc9e3f21379534f5396d21" SRC_URI += "file://phosphor-ipmi-host.service \ + file://host-ipmid-whitelist.conf \ file://0009-IPv6-Network-changes.patch \ file://0010-fix-get-system-GUID-ipmi-command.patch \ file://0013-ipmi-add-set-bios-id-to-whitelist.patch \ - file://0021-Implement-IPMI-Commmand-Get-Host-Restart-Cause.patch \ file://0039-ipmi-add-oem-command-get-AIC-FRU-to-whitelist.patch \ - file://0049-Fix-Unspecified-error-on-ipmi-restart-cause-command.patch \ file://0050-enable-6-oem-commands.patch \ file://0053-Fix-keep-looping-issue-when-entering-OS.patch \ - file://0055-Implement-set-front-panel-button-enables-command.patch \ file://0056-add-SetInProgress-to-get-set-boot-option-cmd.patch \ file://0057-Add-timer-use-actions-support.patch \ file://0059-Move-Set-SOL-config-parameter-to-host-ipmid.patch \ file://0060-Move-Get-SOL-config-parameter-to-host-ipmid.patch \ - file://0061-Use-xyz.openbmc_project.State.Chassis-for-IPMI-chass.patch \ file://0062-Update-IPMI-Chassis-Control-command.patch \ file://0063-Save-the-pre-timeout-interrupt-in-dbus-property.patch \ + file://0064-Enable-watchdog-to-save-useflag-after-host-power-off.patch \ + file://0064-Update-provisioning-mode-filter-logic.patch \ " # remove the softpoweroff service since we do not need it @@ -35,6 +34,9 @@ FILES_${PN}_remove = " \ ${systemd_unitdir}/system/obmc-host-shutdown@0.target.requires/ \ ${systemd_unitdir}/system/obmc-host-shutdown@0.target.requires/xyz.openbmc_project.Ipmi.Internal.SoftPowerOff.service \ " +do_configure_append(){ + cp -f ${WORKDIR}/host-ipmid-whitelist.conf ${S} +} do_install_append(){ rm -f ${D}/${bindir}/phosphor-softpoweroff diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb_%.bbappend index 13d908ad1..f33be5760 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb_%.bbappend +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-ipmb_%.bbappend @@ -1,2 +1,2 @@ SRC_URI = "git://github.com/openbmc/ipmbbridge.git" -SRCREV = "8188d7651c23502f88f9bf850ab7e549f6463997" +SRCREV = "bbfd00abdbc6d2f7c0389eae91cc055a1d4fe0c3" diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0007-Adding-support-for-GetSessionInfo-command.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0007-Adding-support-for-GetSessionInfo-command.patch deleted file mode 100644 index bbbe6ae4f..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0007-Adding-support-for-GetSessionInfo-command.patch +++ /dev/null @@ -1,418 +0,0 @@ -From b05fb3231810865ef1b6e627bb0452ae7a6c61f8 Mon Sep 17 00:00:00 2001 -From: ssekar <suryakanth.sekar@linux.intel.com> -Date: Wed, 12 Dec 2018 16:04:15 +0530 -Subject: [PATCH 1/2] Adding support for GetSessionInfo command - -Description: user can get all session info (remote ip,port, -session id, priv, etc) using this command. - -Verification :we can get all active and non active session -info by session handle session id. -Updated the Remote IP addr and Port update for sessioninfo. -Unit testing are done. - -Change-Id: I662ef2b9f0c1d6bda331eb6481d7b9f34534541b -Signed-off-by: ssekar <suryakanth.sekar@linux.intel.com> ---- - comm_module.cpp | 8 +++ - command/session_cmds.cpp | 147 +++++++++++++++++++++++++++++++++++++++ - command/session_cmds.hpp | 55 +++++++++++++++ - message_handler.cpp | 1 + - sessions_manager.cpp | 55 +++++++++++++++ - sessions_manager.hpp | 7 ++ - socket_channel.hpp | 17 +++++ - 7 files changed, 290 insertions(+) - -diff --git a/comm_module.cpp b/comm_module.cpp -index acc9089..7a1a17d 100644 ---- a/comm_module.cpp -+++ b/comm_module.cpp -@@ -53,6 +53,14 @@ void sessionSetupCommands() - &closeSession, - session::Privilege::CALLBACK, - false}, -+ // Session Info Command -+ { -+ { -+ (static_cast<uint32_t>(message::PayloadType::IPMI) << 16) | -+ static_cast<uint16_t>(command::NetFns::APP) | 0x3D -+ }, -+ &getSessionInfo, session::Privilege::USER, false -+ }, - }; - - for (auto& iter : commands) -diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp -index 8606ce5..4beeb6e 100644 ---- a/command/session_cmds.cpp -+++ b/command/session_cmds.cpp -@@ -8,6 +8,14 @@ - namespace command - { - -+// Defined as per IPMI sepcification -+static constexpr uint8_t searchCurrentSession = 0x00; -+static constexpr uint8_t searchSessionByHandle = 0xFE; -+static constexpr uint8_t searchSessionByID = 0xFF; -+ -+static constexpr uint8_t ipmi15VerSession = 0x00; -+static constexpr uint8_t ipmi20VerSession = 0x01; -+ - std::vector<uint8_t> - setSessionPrivilegeLevel(const std::vector<uint8_t>& inPayload, - const message::Handler& handler) -@@ -92,4 +100,143 @@ std::vector<uint8_t> closeSession(const std::vector<uint8_t>& inPayload, - return outPayload; - } - -+std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, -+ const message::Handler& handler) -+ -+{ -+ std::vector<uint8_t> outPayload(sizeof(GetSessionInfoResponse)); -+ auto request = -+ reinterpret_cast<const GetSessionInfoRequest*>(inPayload.data()); -+ auto response = -+ reinterpret_cast<GetSessionInfoResponse*>(outPayload.data()); -+ uint32_t reqSessionID = handler.sessionID; -+ response->completionCode = IPMI_CC_OK; -+ if (inPayload.size() == 1 && request->sessionIndex != 0) -+ { -+ if (request->sessionIndex <= session::MAX_SESSION_COUNT) -+ { -+ reqSessionID = std::get<session::Manager&>(singletonPool) -+ .getSessionIDbyHandle(request->sessionIndex); -+ } -+ else -+ { -+ response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ } -+ -+ // Here we look for session info according to session index parameter -+ switch (request->sessionIndex) -+ { -+ // Look for current active session which this cmd is received over -+ case searchCurrentSession: -+ // Request data should only contain session index byte -+ if (inPayload.size() != 1) -+ { -+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ // To look for current active session which the command came over, -+ // the session ID cannot be 0. -+ if (0 == reqSessionID) -+ { -+ response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ break; -+ case searchSessionByHandle: -+ // Request data should only contain session index byte and Session -+ // handle -+ if (inPayload.size() != 2) -+ { -+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ -+ // Retrieve session id based on session handle -+ if (request->sessionHandle <= session::MAX_SESSION_COUNT) -+ { -+ reqSessionID = -+ std::get<session::Manager&>(singletonPool) -+ .getSessionIDbyHandle(request->sessionHandle); -+ } -+ else -+ { -+ response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ break; -+ case searchSessionByID: -+ // Request data should only contain session index byte and Session -+ // handle -+ if (inPayload.size() != sizeof(GetSessionInfoRequest)) -+ { -+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ reqSessionID = endian::from_ipmi(request->sessionID); -+ -+ break; -+ default: -+ if (inPayload.size() != 1) -+ { -+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ } -+ -+ response->totalSessionCount = session::MAX_SESSION_COUNT; -+ response->activeSessioncount = -+ std::get<session::Manager&>(singletonPool).getNoOfActiveSession(); -+ response->sessionHandle = 0; -+ if (reqSessionID != 0) -+ { -+ -+ std::shared_ptr<session::Session> sessionInfo; -+ try -+ { -+ sessionInfo = std::get<session::Manager&>(singletonPool) -+ .getSession(reqSessionID); -+ } -+ catch (std::exception& e) -+ { -+ response->completionCode = IPMI_CC_UNSPECIFIED_ERROR; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ response->sessionHandle = std::get<session::Manager&>(singletonPool) -+ .getSessionHandle(reqSessionID); -+ uint8_t userId = ipmi::ipmiUserGetUserId(sessionInfo->userName); -+ if (userId == ipmi::invalidUserId) -+ { -+ response->completionCode = IPMI_CC_UNSPECIFIED_ERROR; -+ outPayload.resize(sizeof(response->completionCode)); -+ return std::move(outPayload); -+ } -+ response->userID = userId; // userId; -+ response->privLevel = static_cast<uint8_t>(sessionInfo->curPrivLevel); -+ response->chanNum = sessionInfo->chNum; // byte7 3:0 -+ response->ipmiVer = ipmi20VerSession; // byte7 7:4 -+ response->remoteIpAddr = -+ sessionInfo->channelPtr->getRemoteAddressInbytes(); -+ response->remotePort = -+ sessionInfo->channelPtr->getPort(); // remoteSessionPort; -+ -+ std::cerr << "\nSessionInfo:" << (int)reqSessionID; -+ // TODO: Filling the Remote MACAddress -+ } -+ else -+ { -+ outPayload.resize(4); -+ } -+ return std::move(outPayload); -+} -+ - } // namespace command -diff --git a/command/session_cmds.hpp b/command/session_cmds.hpp -index 9737fdb..741de23 100644 ---- a/command/session_cmds.hpp -+++ b/command/session_cmds.hpp -@@ -116,4 +116,59 @@ struct CloseSessionResponse - std::vector<uint8_t> closeSession(const std::vector<uint8_t>& inPayload, - const message::Handler& handler); - -+/** -+ * @struct GetSessionInfoRequest -+ * -+ * IPMI Request data for getSession info command -+ */ -+struct GetSessionInfoRequest -+{ -+ uint8_t sessionIndex; -+ union -+ { -+ uint8_t sessionHandle; -+ uint32_t sessionID; -+ }; -+} __attribute__((packed)); -+ -+/** -+ * @struct getSessionInfoResponse -+ * -+ * IPMI Response data for getSession info command -+ */ -+struct GetSessionInfoResponse -+{ -+ uint8_t completionCode; -+ uint8_t sessionHandle; -+ uint8_t totalSessionCount; -+ uint8_t activeSessioncount; -+ uint8_t userID; -+ uint8_t privLevel; -+#if BYTE_ORDER == LITTLE_ENDIAN -+ uint8_t chanNum : 4; -+ uint8_t ipmiVer : 4; -+#endif -+#if BYTE_ORDER == BIG_ENDIAN -+ uint8_t ipmiVer : 4; -+ uint8_t chanNum : 4; -+#endif -+ uint32_t remoteIpAddr; // for channel private data -+ uint8_t remoteMACAddr[6]; -+ uint16_t remotePort; -+} __attribute__((packed)); -+ -+/** -+ * @brief GetSessionInfo Command -+ * -+ * This command is used to get the session information based on -+ * session handle or session ID. Retreive all session information. -+ -+ * @param[in] inPayload - Request Data for the command -+ * @param[in] handler - Reference to the Message Handler -+ * -+ * @return Response data for the command -+ */ -+std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, -+ const message::Handler& handler); -+ - } // namespace command -diff --git a/message_handler.cpp b/message_handler.cpp -index e2aafb3..b335236 100644 ---- a/message_handler.cpp -+++ b/message_handler.cpp -@@ -43,6 +43,7 @@ bool Handler::receive() - sessionID = inMessage->bmcSessionID; - inMessage->rcSessionID = session->getRCSessionID(); - session->updateLastTransactionTime(); -+ session->channelPtr = channel; - - return true; - } -diff --git a/sessions_manager.cpp b/sessions_manager.cpp -index 95a8a15..9f3210b 100644 ---- a/sessions_manager.cpp -+++ b/sessions_manager.cpp -@@ -88,6 +88,9 @@ std::shared_ptr<Session> - } - sessionID = session->getBMCSessionID(); - sessionsMap.emplace(sessionID, session); -+ storeSessionHandle(sessionID); -+ -+ - return session; - } - -@@ -149,12 +152,15 @@ std::shared_ptr<Session> Manager::getSession(SessionID sessionID, - - void Manager::cleanStaleEntries() - { -+ uint8_t sessionIndex = 0; - for (auto iter = sessionsMap.begin(); iter != sessionsMap.end();) - { - auto session = iter->second; - if ((session->getBMCSessionID() != SESSION_ZERO) && - !(session->isSessionActive())) - { -+ sessionIndex = getSessionHandle(session->getBMCSessionID()); -+ sessionHandleMap[sessionIndex] = 0; - iter = sessionsMap.erase(iter); - } - else -@@ -164,4 +170,53 @@ void Manager::cleanStaleEntries() - } - } - -+uint8_t Manager::storeSessionHandle(SessionID bmcSessionID) -+{ -+ // Zero handler is reserved for invalid session. -+ //index starts with 1, for direct usage. Index 0 reserved -+ for (uint8_t i = 1; i <= MAX_SESSION_COUNT; i++) -+ { -+ if (sessionHandleMap[i] == 0) -+ { -+ sessionHandleMap[i] = bmcSessionID; -+ break; -+ } -+ } -+ return 0; -+} -+ -+uint32_t Manager::getSessionIDbyHandle(uint8_t sessionHandle) const -+{ -+ if (sessionHandle <= MAX_SESSION_COUNT) -+ { -+ return sessionHandleMap[sessionHandle]; -+ } -+ return 0; -+} -+ -+uint8_t Manager::getSessionHandle(SessionID bmcSessionID) const -+{ -+ -+ for (uint8_t i = 1; i <= MAX_SESSION_COUNT; i++) -+ { -+ if (sessionHandleMap[i] == bmcSessionID) -+ { -+ return i; -+ } -+ } -+ return 0; -+} -+uint8_t Manager::getNoOfActiveSession() const -+{ -+ uint8_t count = 0; -+ for (const auto& it : sessionsMap) -+ { -+ const auto& session = it.second; -+ if (session->state == State::ACTIVE) -+ { -+ count++; -+ } -+ } -+ return count; -+} - } // namespace session -diff --git a/sessions_manager.hpp b/sessions_manager.hpp -index 9fd38b1..f6ed1c3 100644 ---- a/sessions_manager.hpp -+++ b/sessions_manager.hpp -@@ -82,8 +82,15 @@ class Manager - std::shared_ptr<Session> - getSession(SessionID sessionID, - RetrieveOption option = RetrieveOption::BMC_SESSION_ID); -+ uint8_t getNoOfActiveSession() const; -+ uint8_t getSessionHandle(SessionID bmcSessionID) const; -+ uint8_t storeSessionHandle(SessionID bmcSessionID); -+ uint32_t getSessionIDbyHandle(uint8_t sessionHandle) const; - - private: -+ //+1 for session, as 0 is reserved for sessionless command -+ std::array<uint32_t, MAX_SESSION_COUNT + 1> sessionHandleMap; -+ - /** - * @brief Session Manager keeps the session objects as a sorted - * associative container with Session ID as the unique key -diff --git a/socket_channel.hpp b/socket_channel.hpp -index ebe0c8f..349701e 100644 ---- a/socket_channel.hpp -+++ b/socket_channel.hpp -@@ -64,6 +64,23 @@ class Channel - return endpoint.port(); - } - -+ /** -+ * @brief Return the binary representation of the remote IPv4 address -+ * -+ * getSessionInfo needs to return the remote IPv4 addresses of each session -+ * -+ * @return A uint32_t representation of the remote IPv4 address -+ */ -+ std::uint32_t getRemoteAddressInbytes() -+ { -+ const boost::asio::ip::address& addr = endpoint.address(); -+ if (addr.is_v4()) -+ { -+ return addr.to_v4().to_uint(); -+ } -+ return 0; -+ } -+ - /** - * @brief Read the incoming packet - * --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0008-Sync-GetSession-Info-cmd-based-on-Upstream-review.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0008-Sync-GetSession-Info-cmd-based-on-Upstream-review.patch deleted file mode 100644 index c6b87bf4f..000000000 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0008-Sync-GetSession-Info-cmd-based-on-Upstream-review.patch +++ /dev/null @@ -1,282 +0,0 @@ -From a413e390563205476656a9005ca447f5b626872f Mon Sep 17 00:00:00 2001 -From: Suryakanth Sekar <suryakanth.sekar@linux.intel.com> -Date: Wed, 6 Mar 2019 10:35:56 +0530 -Subject: [PATCH 2/2] Sync GetSession Info cmd based on Upstream review - -Signed-off-by: Suryakanth Sekar <suryakanth.sekar@linux.intel.com> ---- - comm_module.cpp | 12 +++---- - command/session_cmds.cpp | 71 ++++++++++++++++++---------------------- - sessions_manager.cpp | 10 +++--- - sessions_manager.hpp | 2 +- - socket_channel.hpp | 33 ++++++++++--------- - 5 files changed, 59 insertions(+), 69 deletions(-) - -diff --git a/comm_module.cpp b/comm_module.cpp -index 7a1a17d..2546583 100644 ---- a/comm_module.cpp -+++ b/comm_module.cpp -@@ -54,13 +54,11 @@ void sessionSetupCommands() - session::Privilege::CALLBACK, - false}, - // Session Info Command -- { -- { -- (static_cast<uint32_t>(message::PayloadType::IPMI) << 16) | -- static_cast<uint16_t>(command::NetFns::APP) | 0x3D -- }, -- &getSessionInfo, session::Privilege::USER, false -- }, -+ {{(static_cast<uint32_t>(message::PayloadType::IPMI) << 16) | -+ static_cast<uint16_t>(command::NetFns::APP) | 0x3D}, -+ &getSessionInfo, -+ session::Privilege::USER, -+ false}, - }; - - for (auto& iter : commands) -diff --git a/command/session_cmds.cpp b/command/session_cmds.cpp -index 4beeb6e..0c3a4ed 100644 ---- a/command/session_cmds.cpp -+++ b/command/session_cmds.cpp -@@ -8,7 +8,7 @@ - namespace command - { - --// Defined as per IPMI sepcification -+// Defined as per IPMI specification - static constexpr uint8_t searchCurrentSession = 0x00; - static constexpr uint8_t searchSessionByHandle = 0xFE; - static constexpr uint8_t searchSessionByID = 0xFF; -@@ -111,20 +111,6 @@ std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, - reinterpret_cast<GetSessionInfoResponse*>(outPayload.data()); - uint32_t reqSessionID = handler.sessionID; - response->completionCode = IPMI_CC_OK; -- if (inPayload.size() == 1 && request->sessionIndex != 0) -- { -- if (request->sessionIndex <= session::MAX_SESSION_COUNT) -- { -- reqSessionID = std::get<session::Manager&>(singletonPool) -- .getSessionIDbyHandle(request->sessionIndex); -- } -- else -- { -- response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; -- outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -- } -- } - - // Here we look for session info according to session index parameter - switch (request->sessionIndex) -@@ -132,29 +118,22 @@ std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, - // Look for current active session which this cmd is received over - case searchCurrentSession: - // Request data should only contain session index byte -- if (inPayload.size() != 1) -+ if (inPayload.size() != sizeof(request->sessionIndex)) - { - response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -- } -- // To look for current active session which the command came over, -- // the session ID cannot be 0. -- if (0 == reqSessionID) -- { -- response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; -- outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - break; - case searchSessionByHandle: - // Request data should only contain session index byte and Session - // handle -- if (inPayload.size() != 2) -+ if (inPayload.size() != (sizeof(request->sessionIndex) + -+ sizeof(request->sessionHandle))) - { - response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - - // Retrieve session id based on session handle -@@ -168,7 +147,7 @@ std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, - { - response->completionCode = IPMI_CC_INVALID_FIELD_REQUEST; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - break; - case searchSessionByID: -@@ -178,23 +157,38 @@ std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, - { - response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - reqSessionID = endian::from_ipmi(request->sessionID); - - break; - default: -- if (inPayload.size() != 1) -+ if (inPayload.size() == sizeof(request->sessionIndex)) -+ { -+ if (request->sessionIndex <= session::MAX_SESSION_COUNT) -+ { -+ reqSessionID = -+ std::get<session::Manager&>(singletonPool) -+ .getSessionIDbyHandle(request->sessionIndex); -+ } -+ else -+ { -+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; -+ outPayload.resize(sizeof(response->completionCode)); -+ return outPayload; -+ } -+ } -+ else - { - response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - } - - response->totalSessionCount = session::MAX_SESSION_COUNT; - response->activeSessioncount = -- std::get<session::Manager&>(singletonPool).getNoOfActiveSession(); -+ std::get<session::Manager&>(singletonPool).getActiveSessionCount(); - response->sessionHandle = 0; - if (reqSessionID != 0) - { -@@ -207,9 +201,9 @@ std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, - } - catch (std::exception& e) - { -- response->completionCode = IPMI_CC_UNSPECIFIED_ERROR; -+ response->completionCode = IPMI_CC_REQ_DATA_LEN_INVALID; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - response->sessionHandle = std::get<session::Manager&>(singletonPool) - .getSessionHandle(reqSessionID); -@@ -218,25 +212,24 @@ std::vector<uint8_t> getSessionInfo(const std::vector<uint8_t>& inPayload, - { - response->completionCode = IPMI_CC_UNSPECIFIED_ERROR; - outPayload.resize(sizeof(response->completionCode)); -- return std::move(outPayload); -+ return outPayload; - } - response->userID = userId; // userId; - response->privLevel = static_cast<uint8_t>(sessionInfo->curPrivLevel); - response->chanNum = sessionInfo->chNum; // byte7 3:0 - response->ipmiVer = ipmi20VerSession; // byte7 7:4 -- response->remoteIpAddr = -- sessionInfo->channelPtr->getRemoteAddressInbytes(); - response->remotePort = - sessionInfo->channelPtr->getPort(); // remoteSessionPort; -+ response->remoteIpAddr = -+ sessionInfo->channelPtr->getRemoteAddressInBytes(); - -- std::cerr << "\nSessionInfo:" << (int)reqSessionID; - // TODO: Filling the Remote MACAddress - } - else - { - outPayload.resize(4); - } -- return std::move(outPayload); -+ return outPayload; - } - - } // namespace command -diff --git a/sessions_manager.cpp b/sessions_manager.cpp -index 9f3210b..c6897c6 100644 ---- a/sessions_manager.cpp -+++ b/sessions_manager.cpp -@@ -152,15 +152,13 @@ std::shared_ptr<Session> Manager::getSession(SessionID sessionID, - - void Manager::cleanStaleEntries() - { -- uint8_t sessionIndex = 0; - for (auto iter = sessionsMap.begin(); iter != sessionsMap.end();) - { - auto session = iter->second; - if ((session->getBMCSessionID() != SESSION_ZERO) && - !(session->isSessionActive())) - { -- sessionIndex = getSessionHandle(session->getBMCSessionID()); -- sessionHandleMap[sessionIndex] = 0; -+ sessionHandleMap[getSessionHandle(session->getBMCSessionID())] = 0; - iter = sessionsMap.erase(iter); - } - else -@@ -172,8 +170,8 @@ void Manager::cleanStaleEntries() - - uint8_t Manager::storeSessionHandle(SessionID bmcSessionID) - { -- // Zero handler is reserved for invalid session. -- //index starts with 1, for direct usage. Index 0 reserved -+ // Handler index 0 is reserved for invalid session. -+ // index starts with 1, for direct usage. Index 0 reserved - for (uint8_t i = 1; i <= MAX_SESSION_COUNT; i++) - { - if (sessionHandleMap[i] == 0) -@@ -206,7 +204,7 @@ uint8_t Manager::getSessionHandle(SessionID bmcSessionID) const - } - return 0; - } --uint8_t Manager::getNoOfActiveSession() const -+uint8_t Manager::getActiveSessionCount() const - { - uint8_t count = 0; - for (const auto& it : sessionsMap) -diff --git a/sessions_manager.hpp b/sessions_manager.hpp -index f6ed1c3..3ff213e 100644 ---- a/sessions_manager.hpp -+++ b/sessions_manager.hpp -@@ -82,7 +82,7 @@ class Manager - std::shared_ptr<Session> - getSession(SessionID sessionID, - RetrieveOption option = RetrieveOption::BMC_SESSION_ID); -- uint8_t getNoOfActiveSession() const; -+ uint8_t getActiveSessionCount() const; - uint8_t getSessionHandle(SessionID bmcSessionID) const; - uint8_t storeSessionHandle(SessionID bmcSessionID); - uint32_t getSessionIDbyHandle(uint8_t sessionHandle) const; -diff --git a/socket_channel.hpp b/socket_channel.hpp -index 349701e..8b64740 100644 ---- a/socket_channel.hpp -+++ b/socket_channel.hpp -@@ -107,14 +107,15 @@ class Channel - * - * @return A uint32_t representation of the remote IPv4 address - */ -- std::uint32_t getRemoteAddressInbytes() -+ uint32_t getRemoteAddressInBytes() const - { -- const boost::asio::ip::address& addr = endpoint.address(); -- if (addr.is_v4()) -+ uint32_t v4addr = 0; -+ if (sockAddrSize == sizeof(sockaddr_in)) - { -- return addr.to_v4().to_uint(); -+ auto saddr = reinterpret_cast<const sockaddr_in*>(&remoteSockAddr); -+ v4addr = ntohl(saddr->sin_addr.s_addr); - } -- return 0; -+ return v4addr; - } - - /** --- -2.17.1 - diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0009-Add-dbus-interface-for-sol-commands.patch b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0009-Add-dbus-interface-for-sol-commands.patch index c90cccf34..dc7f7357c 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0009-Add-dbus-interface-for-sol-commands.patch +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net/0009-Add-dbus-interface-for-sol-commands.patch @@ -1,6 +1,6 @@ -From 6b9aaf0304aed06e4b5ac53e7c163089568d4171 Mon Sep 17 00:00:00 2001 +From 97c21a556702a0d65096b30c07ef23f15cb6a7d9 Mon Sep 17 00:00:00 2001 From: Cheng C Yang <cheng.c.yang@intel.com> -Date: Sat, 23 Mar 2019 04:03:07 +0800 +Date: Wed, 3 Jul 2019 07:39:47 +0800 Subject: [PATCH] Add dbus interface for sol commands Add dbus interface for sol config parameters so that after move set/get @@ -25,22 +25,24 @@ to 0 and other properties will not reset to default value. Signed-off-by: Cheng C Yang <cheng.c.yang@intel.com> --- - command/payload_cmds.cpp | 1 + - command/sol_cmds.cpp | 84 --------------------------------- - sol/sol_manager.cpp | 119 +++++++++++++++++++++++++++++++++++++++++++++++ + command/payload_cmds.cpp | 3 ++ + command/sol_cmds.cpp | 84 ------------------------------- + sol/sol_manager.cpp | 125 +++++++++++++++++++++++++++++++++++++++++++++++ sol/sol_manager.hpp | 1 + sol_module.cpp | 6 --- - 5 files changed, 121 insertions(+), 90 deletions(-) + 5 files changed, 129 insertions(+), 90 deletions(-) diff --git a/command/payload_cmds.cpp b/command/payload_cmds.cpp -index 3b5b4f8..570cdff 100644 +index c32a510..17167a7 100644 --- a/command/payload_cmds.cpp +++ b/command/payload_cmds.cpp -@@ -34,6 +34,7 @@ std::vector<uint8_t> activatePayload(const std::vector<uint8_t>& inPayload, +@@ -34,6 +34,9 @@ std::vector<uint8_t> activatePayload(const std::vector<uint8_t>& inPayload, return outPayload; } -+ std::get<sol::Manager&>(singletonPool).updateSOLParameter(); ++ std::get<sol::Manager&>(singletonPool) ++ .updateSOLParameter(ipmi::convertCurrentChannelNum( ++ ipmi::currentChNum, getInterfaceIndex())); if (!std::get<sol::Manager&>(singletonPool).enable) { response->completionCode = IPMI_CC_PAYLOAD_TYPE_DISABLED; @@ -140,7 +142,7 @@ index a8fa410..804b5ea 100644 const message::Handler& handler) { diff --git a/sol/sol_manager.cpp b/sol/sol_manager.cpp -index 2046fe4..de36723 100644 +index 2046fe4..eedd28a 100644 --- a/sol/sol_manager.cpp +++ b/sol/sol_manager.cpp @@ -12,7 +12,13 @@ @@ -152,12 +154,12 @@ index 2046fe4..de36723 100644 +#include <sdbusplus/message/types.hpp> + +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/"; +constexpr const char* PROP_INTF = "org.freedesktop.DBus.Properties"; namespace sol { -@@ -93,6 +99,119 @@ void Manager::stopHostConsole() +@@ -93,6 +99,125 @@ void Manager::stopHostConsole() } } @@ -221,17 +223,19 @@ index 2046fe4..de36723 100644 + return properties; +} + -+void Manager::updateSOLParameter() ++void Manager::updateSOLParameter(uint8_t channelNum) +{ + std::variant<uint8_t, bool> value; + sdbusplus::bus::bus dbus(ipmid_get_sd_bus_connection()); + static std::string solService{}; + ipmi::PropertyMap properties; ++ std::string ethdevice = ipmi::getChannelName(channelNum); ++ std::string solPathWitheEthName = solPath + ethdevice; + if (solService.empty()) + { + try + { -+ solService = getService(dbus, solInterface, solPath); ++ solService = getService(dbus, solInterface, solPathWitheEthName); + } + catch (const std::runtime_error& e) + { @@ -243,8 +247,8 @@ index 2046fe4..de36723 100644 + } + try + { -+ properties = -+ getAllDbusProperties(dbus, solService, solPath, solInterface); ++ properties = getAllDbusProperties(dbus, solService, solPathWitheEthName, ++ solInterface); + } + catch (const std::runtime_error&) + { @@ -257,8 +261,12 @@ index 2046fe4..de36723 100644 + + enable = std::get<bool>(properties["Enable"]); + ++ forceEncrypt = std::get<bool>(properties["ForceEncryption"]); ++ ++ forceAuth = std::get<bool>(properties["ForceAuthentication"]); ++ + solMinPrivilege = static_cast<session::Privilege>( -+ std::get<uint8_t>(properties["Authentication"])); ++ std::get<uint8_t>(properties["Privilege"])); + + accumulateInterval = + std::get<uint8_t>((properties["AccumulateIntervalMS"])) * @@ -278,14 +286,14 @@ index 2046fe4..de36723 100644 session::SessionID sessionID) { diff --git a/sol/sol_manager.hpp b/sol/sol_manager.hpp -index 5d96890..b7eb89e 100644 +index 5d96890..00da9fb 100644 --- a/sol/sol_manager.hpp +++ b/sol/sol_manager.hpp @@ -248,6 +248,7 @@ class Manager * @return 0 on success and errno on failure. */ int writeConsoleSocket(const std::vector<uint8_t>& input) const; -+ void updateSOLParameter(void); ++ void updateSOLParameter(uint8_t channelNum); private: SOLPayloadMap payloadMap; @@ -307,5 +315,5 @@ index 8200e74..2b1fb46 100644 {{(static_cast<uint32_t>(message::PayloadType::IPMI) << 16) | static_cast<uint16_t>(::command::NetFns::TRANSPORT) | 0x22}, -- -2.16.2 +2.7.4 diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend index 214bea189..05f10d980 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-ipmi-net_%.bbappend @@ -2,8 +2,8 @@ inherit useradd # TODO: This should be removed, once up-stream bump up # issue is resolved -#SRC_URI += "git://github.com/openbmc/phosphor-net-ipmid" -#SRCREV = "b31e969504645f653b58b676d56b01d632dc395c" +SRC_URI += "git://github.com/openbmc/phosphor-net-ipmid" +SRCREV = "0a269046d0d9fcd690ccbb129ae58a3c1450b04e" USERADD_PACKAGES = "${PN}" # add a group called ipmi @@ -20,10 +20,7 @@ SYSTEMD_SERVICE_${PN} += " \ FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" SRC_URI += " file://0006-Modify-dbus-namespace-of-chassis-control-for-guid.patch \ - file://0007-Adding-support-for-GetSessionInfo-command.patch \ - file://0008-Sync-GetSession-Info-cmd-based-on-Upstream-review.patch \ file://0009-Add-dbus-interface-for-sol-commands.patch \ - file://00010-Change-Authentication-Parameter.patch \ file://0011-Remove-Get-SOL-Config-Command-from-Netipmid.patch \ " diff --git a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb index af83facf6..b27961109 100644 --- a/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb +++ b/meta-openbmc-mods/meta-common/recipes-phosphor/ipmi/phosphor-node-manager-proxy_git.bb @@ -3,7 +3,7 @@ DESCRIPTION = "The Node Manager Proxy provides a simple interface for communicat with Management Engine via IPMB" SRC_URI = "git://git@github.com/Intel-BMC/node-manager;protocol=ssh" -SRCREV = "2ab90332828614c95e0ce22c0c95285734b55b65" +SRCREV = "06e8a1072b05d42e63cf70e2ceac7390578c051d" PV = "0.1+git${SRCPV}" LICENSE = "Apache-2.0" |