Skip to content

Commit

Permalink
Create D-Bus object path and configuration interface
Browse files Browse the repository at this point in the history
Created RAS configuration interface to get and set the
RAS configuration parameters.

Tested:
1. Service is working well.
2. All the dbus methods and properties are shown correctly.
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 Nov 29, 2024
1 parent bf04998 commit 980f9a6
Show file tree
Hide file tree
Showing 6 changed files with 496 additions and 0 deletions.
70 changes: 70 additions & 0 deletions config/ras_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"Configuration": [
{
"ApmlRetries": {
"Description": "Number of APML retry count",
"Value": 10,
"MaxBoundLimit": "50"
}
},
{
"SystemRecovery": {
"Description": "System recovery mode",
"Value": "NO_RESET"
}
},
{
"HarvestMicrocode": {
"Description": "Harvest microcode version",
"Value": true
}
},
{
"HarvestPPIN": {
"Description": "Harvest PPIN",
"Value": true
}
},
{
"ResetSignal": {
"Description": "Reset Signal Type",
"Value": "SYS_RST"
}
},
{
"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
}
},
{
"AifsSignatureId": {
"Description": "List of signature Id to check if Aifs is triggered",
"Value": {
"EX-WDT": "0xaea0000000000108000500b020009a00000000004d000000"
}
}
},
{
"DisableAifsResetOnSyncfloodCounter": {
"Description": "Disable AIFS Reset on syncfloow counter ",
"Value": true
}
}
]
}
96 changes: 96 additions & 0 deletions include/config_manager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
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 ras_config
{

static constexpr auto service = "com.amd.RAS";
static constexpr auto objectPath = "/com/amd/RAS";

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

/**
* @brief RasConfiguration class which maintains RAS configuration
* parameters in the D-Bus interface.
*
*/
class RasConfigManager : public Base
{
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>>;

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

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

/** @brief Set the Ras Config attribute with a new value.
*
* @param[in] attribute - attribute name
* @param[in] value - new value for the attribute
*
* @return On error, throw exception
*/
void setAttribute(AttributeName attribute, AttributeValue value) override;

/** @brief Get the details of the Ras Config attribute
*
* @param[in] attribute - attribute name
*
* @return On success, return the attribute details: attribute type,
* current value. On error, throw exception
*/
AttributeValue getAttribute(AttributeName attribute) override;

/** @brief Creates Config File in /var/lib/amd-ras and the
* config file values are uploaded to the D-Bus interface
*
*/
void createRasConfigFile();

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

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

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

executable(
'amd-bmc-ras',
'src/config_manager.cpp',
'src/main.cpp',
include_directories: include_directories('include'),
dependencies: deps,
install: true,
install_dir: get_option('bindir'))

ras_config_dir = join_paths(get_option('datadir'), 'ras-config')
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=Crash dump manager
After=xyz.openbmc_project.Chassis.Control.Power.service

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

[Install]
WantedBy=multi-user.target
Loading

0 comments on commit 980f9a6

Please sign in to comment.