summaryrefslogtreecommitdiff
path: root/meta-quanta/meta-gbs/recipes-phosphor/ipmi/phosphor-ipmi-host/0001-Add-Chassis-State-Transition-interface.patch
blob: 74f982b33ecfba1e03a8bc4f24d0a32a6659c159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From a1f9d797753e32b36e08e7d611ff88b10e9bbad2 Mon Sep 17 00:00:00 2001
From: "Jason M. Bills" <jason.m.bills@linux.intel.com>
Date: Thu, 30 Jan 2020 16:18:33 -0800
Subject: [PATCH 1/3] Add Chassis State Transition interface

This adds the Chassis State Transition interface in preparation
to support the mapping defined in the design document below.

ref: https://gerrit.openbmc-project.xyz/c/openbmc/docs/+/22358

Tested:
Ran each IPMI chassis control command to confirm the expected
behavior:
ipmitool power on: system is powered-on
ipmitool power off: system is forced off
ipmitool power cycle: system is forced off then powered-on
ipmitool power reset: system is hard reset
ipmitool power soft: soft power-off requested from system software

Change-Id: I6acfb795a9a33ff5227a5d6e1830774ab732ac0c
Signed-off-by: Jason M. Bills <jason.m.bills@linux.intel.com>
---
 chassishandler.cpp | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/chassishandler.cpp b/chassishandler.cpp
index 0d318647..fdbb9fa5 100644
--- a/chassishandler.cpp
+++ b/chassishandler.cpp
@@ -31,6 +31,7 @@
 #include <xyz/openbmc_project/Control/Boot/Mode/server.hpp>
 #include <xyz/openbmc_project/Control/Boot/Source/server.hpp>
 #include <xyz/openbmc_project/Control/Power/RestorePolicy/server.hpp>
+#include <xyz/openbmc_project/State/Chassis/server.hpp>
 #include <xyz/openbmc_project/State/Host/server.hpp>
 #include <xyz/openbmc_project/State/PowerOnHours/server.hpp>
 
@@ -865,6 +866,38 @@ int initiate_state_transition(State::Host::Transition transition)
     return rc;
 }
 
+//------------------------------------------
+// Calls into Chassis State Manager Dbus object
+//------------------------------------------
+int initiateChassisStateTransition(State::Chassis::Transition transition)
+{
+    // OpenBMC Chassis State Manager dbus framework
+    constexpr auto chassisStatePath = "/xyz/openbmc_project/state/chassis0";
+    constexpr auto chassisStateIntf = "xyz.openbmc_project.State.Chassis";
+
+    auto service =
+        ipmi::getService(*getSdBus(), chassisStateIntf, chassisStatePath);
+
+    // Convert to string equivalent of the passed in transition enum.
+    auto request = State::convertForMessage(transition);
+
+    try
+    {
+        ipmi::setDbusProperty(*getSdBus(), service, chassisStatePath,
+                              chassisStateIntf, "RequestedPowerTransition",
+                              request);
+    }
+    catch (std::exception& e)
+    {
+        log<level::ERR>(
+            "Failed to initiate transition",
+            entry("EXCEPTION=%s, REQUEST=%s", e.what(), request.c_str()));
+        return -1;
+    }
+
+    return 0;
+}
+
 //------------------------------------------
 // Set Enabled property to inform NMI source
 // handling to trigger a NMI_OUT BSOD.
-- 
2.21.0