Skip to content

Commit

Permalink
Create D-Bus object path and config interface
Browse files Browse the repository at this point in the history
1. Added RAS configuration class which creates the
RAS configuration interface to set and get the config values.

2. The setAttribute and getAttribute methods are overridden
in the class to update the ras_config.json with the latest values.

Tested:
1. Service is working well.
2. All the dbus methods and properties are shown correctly.
   Able to get and update the ras_config.json file using D-Bus methods.
3. Unit test done.

root@xxxx:~# busctl tree com.amd.RAS
`- /com
  `- /com/amd
    `- /com/amd/RAS

Signed-off-by: Abinaya Dhandapani <abinaya.dhandapani@amd.com>
  • Loading branch information
Abinaya Dhandapani committed Dec 19, 2024
1 parent fb5477f commit 78a1c09
Show file tree
Hide file tree
Showing 7 changed files with 610 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ APML and generates the CPER record. On user demand, these CPER files will be
available for download via redfish. The CPER records will be rotated after
reaching maximum limit of 10 CPER records in the BMC.

assertion by the SMU. If the SBRMI register indicates if the assertion is due to
the fatal error, BMC harvests MCA and MSR dump via APML and generates the CPER
record. On user demand, these CPER files will be available for download via
redfish. The CPER records will be rotated after reaching maximum limit of 10
CPER records in the BMC.

Once the CPER record is created, BMC triggers system recovery either by cold
reset or warm reset or no reset depending on user configuration.

Expand Down
72 changes: 72 additions & 0 deletions config/ras_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{
"Configuration": [
{
"ApmlRetries": {
"Description": "Number of APML retry count",
"Value": 10,
"MaxBoundLimit": "50"
}
},
{
"SystemRecoveryMode": {
"Description": "System recovery mode",
"Value": "NO_RESET",
"ValidOptions": ["COLD_RESET", "WARM_RESET", "NO_RESET"]
}
},
{
"ResetSignalType": {
"Description": "Reset Signal Type",
"Value": "SYS_RST",
"ValidOptions": ["SYS_RST", "RSMRST"]
}
},
{
"HarvestMicrocode": {
"Description": "Harvest microcode version",
"Value": true
}
},
{
"HarvestPPIN": {
"Description": "Harvest Protected Processor Identification Number",
"Value": true
}
},
{
"SigIdOffset": {
"Description": "List of Signature ID offsets",
"Value": [
"0x30",
"0x34",
"0x28",
"0x2c",
"0x08",
"0x0c",
"null",
"null"
]
}
},
{
"AifsArmed": {
"Description": "If this field is true, AIFS flow is triggered",
"Value": false
}
},
{
"AifsSignatureIdList": {
"Description": "List of signature Id which has AIFS flow enabled",
"Value": {
"EX-WDT": "0xaea0000000000108000500b020009a00000000004d000000"
}
}
},
{
"DisableAifsResetOnSyncfloodCounter": {
"Description": "Disable AIFS Reset on syncflood counter",
"Value": true
}
}
]
}
115 changes: 115 additions & 0 deletions include/config_manager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http:www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#include <com/amd/RAS/Configuration/common.hpp>
#include <com/amd/RAS/Configuration/server.hpp>
#include <sdbusplus/asio/object_server.hpp>
#include <sdbusplus/server.hpp>

#include <fstream>

namespace amd
{
namespace ras
{
namespace config
{
static constexpr auto service = "com.amd.RAS";
static constexpr auto objectPath = "/com/amd/RAS";

using Configuration = sdbusplus::com::amd::RAS::server::Configuration;

/**
* @brief Manager class which adds the RAS configuration
* parameter values to the D-Bus interface.
*
* @details The class pulls the default values of ras_config.json file
* into the D-Bus interface and overrides the getAttribute()
* and setAttribute() of the RAS configuration interface.
*/
class Manager : public Configuration
{
public:
using AttributeName = std::string;
using AttributeValue =
std::variant<bool, std::string, int64_t, std::vector<std::string>,
std::map<std::string, std::string>>;
using ConfigTable =
std::map<std::string,
std::tuple<AttributeType, std::string,
std::variant<bool, std::string, int64_t,
std::vector<std::string>,
std::map<std::string, std::string>>,
int64_t>>;

Manager() = delete;
Manager(const Manager&) = delete;
Manager& operator=(const Manager&) = delete;
Manager(Manager&&) = delete;
Manager& operator=(Manager&&) = delete;
~Manager() = default;

/** @brief Constructs Manager object.
*
* @param[in] objectServer - object server
* @param[in] systemBus - bus connection
*/
Manager(sdbusplus::asio::object_server& objectServer,
std::shared_ptr<sdbusplus::asio::connection>& systemBus);

/** @brief Updates the rasConfigTable with the user input.
*
* @details Updates the Attribute value in the rasConfigTable and
* ras_config.json with user input and the ras_config.json.
*
* @param[in] attribute - attribute name
* @param[in] value - new value for the attribute
*
* @return On failure of accessing the config file, log InvalidArgument
* D-Bus error.
*/
void setAttribute(AttributeName attribute, AttributeValue value) override;

/** @brief Get the values of the Ras Config attribute
*
* @details The API reads the value from the RasConfigTable
* and returns the value of the attribute.
*
* @param[in] attribute - attribute name
*
* @return returns the current value of the attribute.
* On failure , throw ResourceNotFound D-Bus error.
*/
AttributeValue getAttribute(AttributeName attribute) override;

/** @brief Update RAS configuration parameters to D-Bus interface
*
* @details Creates Config File in /var/lib/amd-bmc-ras and the
* config file values are uploaded to the D-Bus interface.
*
* @return On failure of accessing the config file, throw
* std::runtime_error exception.
*/
void updateConfigToDbus();

private:
sdbusplus::asio::object_server& objServer;
std::shared_ptr<sdbusplus::asio::connection>& systemBus;
};

} // namespace config
} // namespace ras
} // namespace amd
64 changes: 64 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
project(
'amd-ras-manager',
'cpp',
default_options: [
'warning_level=3',
'werror=true',
'cpp_std=c++23'
],
license: 'Apache-2.0',
version: '1.0',
)

config_file = '/var/lib/amd-bmc-ras/ras_config.json'
src_config_file = '/usr/share/amd-bmc-ras/ras_config.json'
cpp_args = [
'-DCONFIG_FILE="' + config_file + '"',
'-DSRC_CONFIG_FILE="' + src_config_file + '"'
]

boost_args = [
'-DBOOST_ALL_NO_LIB',
'-DBOOST_ASIO_DISABLE_THREADS',
'-DBOOST_ERROR_CODE_HEADER_ONLY',
'-DBOOST_NO_RTTI',
'-DBOOST_NO_TYPEID',
'-DBOOST_SYSTEM_NO_DEPRECATED',
]

deps = [
dependency('boost'),
dependency('phosphor-dbus-interfaces'),
dependency('phosphor-logging'),
dependency('sdbusplus'),
dependency('libsystemd'),
dependency('nlohmann_json', include_type: 'system'),
]

sources = [
'src/config_manager.cpp',
'src/main.cpp',
]

executable(
'amd-ras-manager',
sources,
include_directories: include_directories('include'),
dependencies: deps,
cpp_args: cpp_args + boost_args,
install: true,
install_dir: get_option('bindir'))

ras_config_dir = join_paths(get_option('datadir'), 'amd-bmc-ras')
install_data(
join_paths(meson.current_source_dir(), 'config', 'ras_config.json'),
install_dir: ras_config_dir,
rename: 'ras_config.json'
)

systemd = dependency('systemd')

install_data(
['service_files/com.amd.RAS.service'],
install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir')
)
10 changes: 10 additions & 0 deletions service_files/com.amd.RAS.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Unit]
Description=AMD RAS Manager
After=xyz.openbmc_project.Chassis.Control.Power.service

[Service]
Restart=always
ExecStart=/usr/bin/amd-ras-manager

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 78a1c09

Please sign in to comment.