Skip to content

Commit 58d3589

Browse files
hw-isolation: Added HardwareIsolation service (#1256)
- In an OpenPOWER based system, a user or an application (in the error path if the hardware is faulty) can isolate hardware and the respective isolated hardware part will be ignored to init during the next boot of the host. - The isolated hardware details are stored in BMC and a user may need to get that information through an external interface. - In this patch, added a new HardwareIsolation LogService to get or manage the isolated hardware. - This HardwareIsolation feature can be enabled by using the "hw-isolation" compile-time feature flag. It is enabled by default. Other Reference: - Design document for hardware isolation (aka guard) https://github.com/openbmc/docs/blob/master/designs/guard-on-bmc.md Tested: - Checked whether the HardwareIsolation LogService is showing in LogServiceCollection. ``` curl -k -H "X-Auth-Token: $bmc_token" -X GET \ https://${bmc}/redfish/v1/Systems/system/LogServices { "@odata.id": "/redfish/v1/Systems/system/LogServices", "@odata.type": "#LogServiceCollection.LogServiceCollection", "Description": "Collection of LogServices for this Computer System", "Members": [ { "@odata.id": "/redfish/v1/Systems/system/LogServices/EventLog" }, { "@odata.id": "/redfish/v1/Systems/system/LogServices/Dump" }, { "@odata.id": "/redfish/v1/Systems/system/LogServices/PostCodes" }, { "@odata.id": "/redfish/v1/Systems/system/LogServices/HardwareIsolation" } ], "[email protected]": 4, "Name": "System Log Services Collection" } ``` - Checked whether the HardwareIsolation LogService is showing with all required LogService members. ``` curl -k -H "X-Auth-Token: $bmc_token" -X GET \ https://${bmc}/redfish/v1/Systems/system/LogServices/HardwareIsolation { "@odata.id": "/redfish/v1/Systems/system/LogServices/HardwareIsolation", "@odata.type": "#LogService.v1_2_0.LogService", "Actions": { "#LogService.ClearLog": { "target": "/redfish/v1/Systems/system/LogServices/HardwareIsolation/Actions \ /LogService.ClearLog" } }, "Description": "Hardware Isolation LogService for system owned devices", "Entries": { "@odata.id": "/redfish/v1/Systems/system/LogServices/HardwareIsolation/Entries" }, "Id": "HardwareIsolation", "Name": "Hardware Isolation LogService" } ``` Signed-off-by: Ramesh Iyyar <[email protected]> Co-authored-by: Ramesh Iyyar <[email protected]>
1 parent 3784e84 commit 58d3589

File tree

5 files changed

+99
-0
lines changed

5 files changed

+99
-0
lines changed

config/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ feature_options = [
1313
'experimental-redfish-multi-computer-system',
1414
'google-api',
1515
'host-serial-socket',
16+
'hw-isolation',
1617
'hypervisor-computer-system',
1718
'hypervisor-serial-socket',
1819
'ibm-led-extensions',

meson.options

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,3 +578,12 @@ option(
578578
description: '''Enable hypervisor serial console WebSocket. Path is
579579
\'/console1\'.''',
580580
)
581+
582+
# BMCWEB_HW_ISOLATION
583+
option(
584+
'hw-isolation',
585+
type: 'feature',
586+
value: 'enabled',
587+
description: 'Enable the Hardware Isolation feature',
588+
)
589+

redfish-core/lib/log_services.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,6 +1244,18 @@ inline void requestRoutesSystemLogServiceCollection(App& app)
12441244
"/redfish/v1/Systems/system/LogServices/AuditLog";
12451245
logServiceArray.push_back(std::move(auditLog));
12461246
}
1247+
if constexpr (BMCWEB_HW_ISOLATION)
1248+
{
1249+
nlohmann::json& logServiceArrayLocal =
1250+
asyncResp->res.jsonValue["Members"];
1251+
nlohmann::json::object_t member;
1252+
member["@odata.id"] = boost::urls::format(
1253+
"redfish/v1/Systems/{}/LogServices/HardwareIsolation",
1254+
BMCWEB_REDFISH_SYSTEM_URI_NAME);
1255+
logServiceArrayLocal.emplace_back(std::move(member));
1256+
asyncResp->res.jsonValue["[email protected]"] =
1257+
logServiceArrayLocal.size();
1258+
}
12471259
});
12481260
}
12491261

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#pragma once
2+
3+
#include "bmcweb_config.h"
4+
5+
#include "app.hpp"
6+
#include "async_resp.hpp"
7+
#include "http_request.hpp"
8+
#include "registries/privilege_registry.hpp"
9+
10+
#include <boost/beast/http/verb.hpp>
11+
#include <boost/url/format.hpp>
12+
13+
#include <memory>
14+
#include <string>
15+
#include <string_view>
16+
17+
namespace redfish
18+
{
19+
20+
/****************************************************
21+
* Redfish HardwareIsolationLog interfaces
22+
******************************************************/
23+
24+
/**
25+
* @brief API Used to add the supported HardwareIsolation LogServices Members
26+
*
27+
* @param[in] req - The HardwareIsolation redfish request (unused now).
28+
* @param[in] asyncResp - The redfish response to return.
29+
*
30+
* @return The redfish response in the given buffer.
31+
*/
32+
inline void getSystemHardwareIsolationLogService(
33+
const crow::Request& /* req */,
34+
const std::shared_ptr<bmcweb::AsyncResp>& asyncResp)
35+
{
36+
asyncResp->res.jsonValue["@odata.id"] = boost::urls::format(
37+
"/redfish/v1/Systems/{}/LogServices/HardwareIsolation",
38+
BMCWEB_REDFISH_SYSTEM_URI_NAME);
39+
asyncResp->res.jsonValue["@odata.type"] = "#LogService.v1_2_0.LogService";
40+
asyncResp->res.jsonValue["Name"] = "Hardware Isolation LogService";
41+
asyncResp->res.jsonValue["Description"] =
42+
"Hardware Isolation LogService for system owned devices";
43+
asyncResp->res.jsonValue["Id"] = "HardwareIsolation";
44+
45+
asyncResp->res.jsonValue["Entries"]["@odata.id"] = boost::urls::format(
46+
"/redfish/v1/Systems/{}/LogServices/HardwareIsolation/Entries",
47+
BMCWEB_REDFISH_SYSTEM_URI_NAME);
48+
49+
asyncResp->res.jsonValue["Actions"]["#LogService.ClearLog"]
50+
["target"] = boost::urls::format(
51+
"/redfish/v1/Systems/{}/LogServices/HardwareIsolation/Actions/LogService.ClearLog",
52+
BMCWEB_REDFISH_SYSTEM_URI_NAME);
53+
}
54+
55+
/**
56+
* @brief API used to route the handler for HardwareIsolation Redfish
57+
* LogServices URI
58+
*
59+
* @param[in] app - Crow app on which Redfish will initialize
60+
*
61+
* @return The appropriate redfish response for the given redfish request.
62+
*/
63+
inline void requestRoutesSystemHardwareIsolationLogService(App& app)
64+
{
65+
BMCWEB_ROUTE(app,
66+
"/redfish/v1/Systems/system/LogServices/HardwareIsolation/")
67+
.privileges(redfish::privileges::getLogService)
68+
.methods(boost::beast::http::verb::get)(
69+
getSystemHardwareIsolationLogService);
70+
}
71+
72+
} // namespace redfish

redfish-core/src/redfish.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
#include "systems.hpp"
4747
#include "systems_logservices_audit.hpp"
4848
#include "systems_logservices_hostlogger.hpp"
49+
#include "systems_logservices_hwisolation.hpp"
4950
#include "systems_logservices_postcodes.hpp"
5051
#include "task.hpp"
5152
#include "telemetry_service.hpp"
@@ -201,6 +202,10 @@ RedfishService::RedfishService(App& app)
201202
requestRoutesSystemsLogServiceHostlogger(app);
202203
}
203204

205+
if constexpr (BMCWEB_HW_ISOLATION)
206+
{
207+
requestRoutesSystemHardwareIsolationLogService(app);
208+
}
204209
requestRoutesMessageRegistryFileCollection(app);
205210
requestRoutesMessageRegistryFile(app);
206211
requestRoutesMessageRegistry(app);

0 commit comments

Comments
 (0)