diff options
author | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-06-29 18:35:00 +0530 |
---|---|---|
committer | Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com> | 2017-07-29 23:57:59 +0530 |
commit | ee4d83dfc7b6cf3b5979541ab5b1918b68e6bbdb (patch) | |
tree | 4d186ddf133d77880e857fccdddb71fcc155a6bf | |
parent | 554d60059e7d0b699b3cdcbe8de2c341613e9931 (diff) | |
download | openpower-occ-control-ee4d83dfc7b6cf3b5979541ab5b1918b68e6bbdb.tar.gz openpower-occ-control-ee4d83dfc7b6cf3b5979541ab5b1918b68e6bbdb.zip |
Add support to watch for OCC errors
Change-Id: I98d95020a2d01e281e5c8efa825d6b4bd4c6c160
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r-- | Makefile.am | 27 | ||||
-rw-r--r-- | app.cpp | 50 | ||||
-rw-r--r-- | configure.ac | 6 | ||||
-rw-r--r-- | elog-errors.hpp | 1290 | ||||
-rw-r--r-- | occ_device.hpp | 37 | ||||
-rw-r--r-- | occ_errors.cpp | 145 | ||||
-rw-r--r-- | occ_errors.hpp | 107 | ||||
-rw-r--r-- | occ_events.hpp | 30 | ||||
-rw-r--r-- | occ_manager.hpp | 16 | ||||
-rw-r--r-- | occ_pass_through.cpp | 18 | ||||
-rw-r--r-- | occ_status.cpp | 15 | ||||
-rw-r--r-- | occ_status.hpp | 13 | ||||
-rw-r--r-- | org/open_power/OCC/Device.errors.yaml | 15 | ||||
-rw-r--r-- | org/open_power/OCC/Device.metadata.yaml (renamed from org/open_power/OCC/PassThrough.metadata.yaml) | 4 | ||||
-rw-r--r-- | org/open_power/OCC/PassThrough.errors.yaml | 11 | ||||
-rw-r--r-- | test/Makefile.am | 5 | ||||
-rw-r--r-- | test/utest.cpp | 14 |
17 files changed, 987 insertions, 816 deletions
diff --git a/Makefile.am b/Makefile.am index 25e1358..5042ec5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,19 +2,22 @@ noinst_HEADERS = \ occ_pass_through.hpp \ occ_status.hpp \ - powercap.hpp + powercap.hpp \ + occ_errors.hpp \ + occ_events.hpp sbin_PROGRAMS = openpower-occ-control openpower_occ_control_SOURCES = \ occ_pass_through.cpp \ occ_status.cpp \ occ_device.cpp \ + occ_errors.cpp \ app.cpp \ - org/open_power/OCC/PassThrough/error.cpp \ - powercap.cpp + powercap.cpp \ + org/open_power/OCC/Device/error.cpp -BUILT_SOURCES = org/open_power/OCC/PassThrough/error.hpp \ - org/open_power/OCC/PassThrough/error.cpp +BUILT_SOURCES = org/open_power/OCC/Device/error.hpp \ + org/open_power/OCC/Device/error.cpp CLEANFILES = ${BUILT_SOURCES} @@ -22,19 +25,21 @@ openpower_occ_control_LDFLAGS = \ $(SDBUSPLUS_LIBS) \ $(PHOSPHOR_LOGGING_LIBS) \ $(OPENPOWER_DBUS_INTERFACES_LIBS) \ + $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ -lstdc++fs openpower_occ_control_CXXFLAGS = $(SDBUSPLUS_CFLAGS) \ $(PHOSPHOR_LOGGING_CFLAGS) \ - $(OPENPOWER_DBUS_INTERFACES_CFLAGS) + $(OPENPOWER_DBUS_INTERFACES_CFLAGS) \ + $(PHOSPHOR_DBUS_INTERFACES_CFLAGS) -org/open_power/OCC/PassThrough/error.hpp: ${top_srcdir}/org/open_power/OCC/PassThrough.errors.yaml +org/open_power/OCC/Device/error.hpp: ${top_srcdir}/org/open_power/OCC/Device.errors.yaml @mkdir -p `dirname $@` - $(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-header org.open_power.OCC.PassThrough > $@ + $(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-header org.open_power.OCC.Device > $@ -org/open_power/OCC/PassThrough/error.cpp: ${top_srcdir}/org/open_power/OCC/PassThrough.errors.yaml +org/open_power/OCC/Device/error.cpp: ${top_srcdir}/org/open_power/OCC/Device.errors.yaml @mkdir -p `dirname $@` - $(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-cpp org.open_power.OCC.PassThrough > $@ + $(SDBUSPLUSPLUS) -r $(top_srcdir) error exception-cpp org.open_power.OCC.Device > $@ -SUBDIRS = . test
\ No newline at end of file +SUBDIRS = . test @@ -1,32 +1,44 @@ #include <phosphor-logging/log.hpp> -#include <exception> +#include <phosphor-logging/elog.hpp> +#include <xyz/openbmc_project/Common/error.hpp> +#include <org/open_power/OCC/Device/error.hpp> #include "occ_manager.hpp" +#include "occ_events.hpp" +#include "elog-errors.hpp" #include "config.h" +using namespace phosphor::logging; + +using namespace sdbusplus::org::open_power::OCC::Device::Error; +using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: + Error::InternalFailure; + int main(int argc, char* argv[]) { - try + auto bus = sdbusplus::bus::new_default(); + + // Need sd_event to watch for OCC device errors + sd_event* event = nullptr; + auto r = sd_event_default(&event); + if (r < 0) { - auto bus = sdbusplus::bus::new_default(); - bus.request_name(OCC_CONTROL_BUSNAME); + log<level::ERR>("Error creating a default sd_event handler"); + return r; + } + open_power::occ::EventPtr eventP{event}; + event = nullptr; - sdbusplus::server::manager::manager objManager(bus, - OCC_CONTROL_ROOT); + // Attach the bus to sd_event to service user requests + bus.attach_event(eventP.get(), SD_EVENT_PRIORITY_NORMAL); - open_power::occ::Manager mgr(bus); + sdbusplus::server::manager::manager objManager(bus, OCC_CONTROL_ROOT); + open_power::occ::Manager mgr(bus, eventP); - while (true) - { - bus.process_discard(); - bus.wait(); - } - } - catch (const std::exception& e) - { - using namespace phosphor::logging; - log<level::ERR>(e.what()); - return -1; - } + // Claim the bus since all the house keeping is done now + bus.request_name(OCC_CONTROL_BUSNAME); + + // Wait for requests + sd_event_loop(eventP.get()); return 0; } diff --git a/configure.ac b/configure.ac index e20fe7f..dadc118 100644 --- a/configure.ac +++ b/configure.ac @@ -43,6 +43,8 @@ PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],,\ AC_MSG_ERROR(["Requires phosphor-logging package."])) PKG_CHECK_MODULES([OPENPOWER_DBUS_INTERFACES], [openpower-dbus-interfaces],,\ AC_MSG_ERROR(["Requires openpower-dbus-interfaces package."])) +PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],,\ + AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."])) # Check for sdbusplus PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, [AC_MSG_ERROR(["sdbusplus packaged required and not found"])]) @@ -91,6 +93,10 @@ AC_ARG_VAR(OCC_HWMON_PATH, [The OCC hwmon path]) AS_IF([test "x$OCC_HWMON_PATH" == "x"], [OCC_HWMON_PATH="/sys/bus/platform/drivers/occ-hwmon/"]) AC_DEFINE_UNQUOTED([OCC_HWMON_PATH], ["$OCC_HWMON_PATH"], [The OCC hwmon path]) +AC_ARG_VAR(DEV_PATH, [The device path]) +AS_IF([test "x$DEV_PATH" == "x"], [DEV_PATH="/sys/bus/platform/devices/"]) +AC_DEFINE_UNQUOTED([DEV_PATH], ["$DEV_PATH"], [The device path]) + AC_ARG_VAR(PS_DERATING_FACTOR, [The power supply derating factor]) AS_IF([test "x$PS_DERATING_FACTOR" == "x"], [PS_DERATING_FACTOR=90]) AC_DEFINE_UNQUOTED([PS_DERATING_FACTOR], [$PS_DERATING_FACTOR], [The power supply derating factor]) diff --git a/elog-errors.hpp b/elog-errors.hpp index c9abdfa..823ffdb 100644 --- a/elog-errors.hpp +++ b/elog-errors.hpp @@ -65,6 +65,26 @@ namespace Error namespace sdbusplus { +namespace org +{ +namespace open_power +{ +namespace OCC +{ +namespace Device +{ +namespace Error +{ + struct WriteFailure; +} // namespace Error +} // namespace Device +} // namespace OCC +} // namespace open_power +} // namespace org +} // namespace sdbusplus + +namespace sdbusplus +{ namespace xyz { namespace openbmc_project @@ -206,58 +226,58 @@ namespace xyz { namespace openbmc_project { -namespace Common +namespace Sensor { -namespace File +namespace Device { namespace Error { - struct Seek; + struct ReadFailure; } // namespace Error -} // namespace File -} // namespace Common +} // namespace Device +} // namespace Sensor } // namespace openbmc_project } // namespace xyz } // namespace sdbusplus namespace sdbusplus { -namespace org +namespace xyz { -namespace open_power +namespace openbmc_project { -namespace OCC +namespace Common { -namespace PassThrough +namespace File { namespace Error { - struct OpenFailure; + struct Seek; } // namespace Error -} // namespace PassThrough -} // namespace OCC -} // namespace open_power -} // namespace org +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz } // namespace sdbusplus namespace sdbusplus { -namespace xyz +namespace org { -namespace openbmc_project +namespace open_power { -namespace Sensor +namespace OCC { namespace Device { namespace Error { - struct ReadFailure; + struct ConfigFailure; } // namespace Error } // namespace Device -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz +} // namespace OCC +} // namespace open_power +} // namespace org } // namespace sdbusplus namespace sdbusplus @@ -268,13 +288,13 @@ namespace open_power { namespace OCC { -namespace PassThrough +namespace Device { namespace Error { - struct ReadFailure; + struct OpenFailure; } // namespace Error -} // namespace PassThrough +} // namespace Device } // namespace OCC } // namespace open_power } // namespace org @@ -308,13 +328,13 @@ namespace open_power { namespace OCC { -namespace PassThrough +namespace Device { namespace Error { - struct WriteFailure; + struct ReadFailure; } // namespace Error -} // namespace PassThrough +} // namespace Device } // namespace OCC } // namespace open_power } // namespace org @@ -351,6 +371,44 @@ namespace xyz { namespace openbmc_project { +namespace Control +{ +namespace Host +{ +namespace _CommandNotSupported +{ + + +} // namespace _CommandNotSupported + +struct CommandNotSupported +{ + static constexpr auto L = level::ERR; + using metadata_types = std::tuple<>; + +}; + +} // namespace Host +} // namespace Control +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Control::Host::Error::CommandNotSupported> +{ + using type = xyz::openbmc_project::Control::Host::CommandNotSupported; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ namespace Common { namespace _Timeout @@ -367,28 +425,12 @@ struct TIMEOUT_IN_MSEC } // namespace _Timeout -struct Timeout : public sdbusplus::exception_t +struct Timeout { - static constexpr auto errName = "xyz.openbmc_project.Common.Timeout"; - static constexpr auto errDesc = "Operation timed out."; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using TIMEOUT_IN_MSEC = _Timeout::TIMEOUT_IN_MSEC; using metadata_types = std::tuple<TIMEOUT_IN_MSEC>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Common @@ -413,6 +455,41 @@ namespace openbmc_project { namespace Common { +namespace _InternalFailure +{ + + +} // namespace _InternalFailure + +struct InternalFailure +{ + static constexpr auto L = level::ERR; + using metadata_types = std::tuple<>; + +}; + +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure> +{ + using type = xyz::openbmc_project::Common::InternalFailure; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ namespace _InvalidArgument { @@ -435,15 +512,211 @@ struct ARGUMENT_VALUE } // namespace _InvalidArgument -struct InvalidArgument : public sdbusplus::exception_t +struct InvalidArgument { - static constexpr auto errName = "xyz.openbmc_project.Common.InvalidArgument"; - static constexpr auto errDesc = "Invalid argument was given."; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using ARGUMENT_NAME = _InvalidArgument::ARGUMENT_NAME; using ARGUMENT_VALUE = _InvalidArgument::ARGUMENT_VALUE; using metadata_types = std::tuple<ARGUMENT_NAME, ARGUMENT_VALUE>; +}; + +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument> +{ + using type = xyz::openbmc_project::Common::InvalidArgument; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace File +{ +namespace _Open +{ + +struct ERRNO +{ + static constexpr auto str = "ERRNO=%d"; + static constexpr auto str_short = "ERRNO"; + using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; + explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct PATH +{ + static constexpr auto str = "PATH=%s"; + static constexpr auto str_short = "PATH"; + using type = std::tuple<std::decay_t<decltype(str)>,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Open + +struct Open +{ + static constexpr auto L = level::ERR; + using ERRNO = _Open::ERRNO; + using PATH = _Open::PATH; + using metadata_types = std::tuple<ERRNO, PATH>; + +}; + +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::File::Error::Open> +{ + using type = xyz::openbmc_project::Common::File::Open; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace File +{ +namespace _Seek +{ + +struct OFFSET +{ + static constexpr auto str = "OFFSET=%ll"; + static constexpr auto str_short = "OFFSET"; + using type = std::tuple<std::decay_t<decltype(str)>,int64_t>; + explicit constexpr OFFSET(int64_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct WHENCE +{ + static constexpr auto str = "WHENCE=%d"; + static constexpr auto str_short = "WHENCE"; + using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; + explicit constexpr WHENCE(int32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct ERRNO +{ + static constexpr auto str = "ERRNO=%d"; + static constexpr auto str_short = "ERRNO"; + using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; + explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct PATH +{ + static constexpr auto str = "PATH=%s"; + static constexpr auto str_short = "PATH"; + using type = std::tuple<std::decay_t<decltype(str)>,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Seek + +struct Seek +{ + static constexpr auto L = level::ERR; + using OFFSET = _Seek::OFFSET; + using WHENCE = _Seek::WHENCE; + using ERRNO = _Seek::ERRNO; + using PATH = _Seek::PATH; + using metadata_types = std::tuple<OFFSET, WHENCE, ERRNO, PATH>; + +}; + +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::File::Error::Seek> +{ + using type = xyz::openbmc_project::Common::File::Seek; +}; + +} + +namespace example +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Example +{ +namespace Elog +{ +namespace _TestErrorTwo +{ + +struct DEV_ADDR +{ + static constexpr auto str = "DEV_ADDR=0x%.8X"; + static constexpr auto str_short = "DEV_ADDR"; + using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>; + explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct DEV_ID +{ + static constexpr auto str = "DEV_ID=%u"; + static constexpr auto str_short = "DEV_ID"; + using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>; + explicit constexpr DEV_ID(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct DEV_NAME +{ + static constexpr auto str = "DEV_NAME=%s"; + static constexpr auto str_short = "DEV_NAME"; + using type = std::tuple<std::decay_t<decltype(str)>,const char*>; + explicit constexpr DEV_NAME(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _TestErrorTwo + +struct TestErrorTwo : public sdbusplus::exception_t +{ + static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestErrorTwo"; + static constexpr auto errDesc = "This is test error two"; + static constexpr auto L = level::ERR; + using DEV_ADDR = _TestErrorTwo::DEV_ADDR; + using DEV_ID = _TestErrorTwo::DEV_ID; + using DEV_NAME = _TestErrorTwo::DEV_NAME; + using metadata_types = std::tuple<DEV_ADDR, DEV_ID, DEV_NAME>; + const char* name() const noexcept { return errName; @@ -460,40 +733,45 @@ struct InvalidArgument : public sdbusplus::exception_t } }; -} // namespace Common +} // namespace Elog +} // namespace Example } // namespace openbmc_project } // namespace xyz +} // namespace example -namespace details -{ -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument> +namespace example { - using type = xyz::openbmc_project::Common::InvalidArgument; -}; - -} - namespace xyz { namespace openbmc_project { -namespace Common +namespace Example { -namespace _InternalFailure +namespace Elog +{ +namespace _AutoTestSimple { +struct STRING +{ + static constexpr auto str = "STRING=%s"; + static constexpr auto str_short = "STRING"; + using type = std::tuple<std::decay_t<decltype(str)>,const char*>; + explicit constexpr STRING(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; -} // namespace _InternalFailure +} // namespace _AutoTestSimple -struct InternalFailure : public sdbusplus::exception_t +struct AutoTestSimple : public sdbusplus::exception_t { - static constexpr auto errName = "xyz.openbmc_project.Common.InternalFailure"; - static constexpr auto errDesc = "The operation failed internally."; + static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.AutoTestSimple"; + static constexpr auto errDesc = "This is a simple test error."; static constexpr auto L = level::ERR; - using metadata_types = std::tuple<>; + using STRING = _AutoTestSimple::STRING; + using metadata_types = std::tuple<STRING>; const char* name() const noexcept { @@ -511,21 +789,78 @@ struct InternalFailure : public sdbusplus::exception_t } }; -} // namespace Common +} // namespace Elog +} // namespace Example } // namespace openbmc_project } // namespace xyz +} // namespace example -namespace details + +namespace example +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Example +{ +namespace Device +{ +namespace _Callout { -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure> +struct CALLOUT_ERRNO_TEST { - using type = xyz::openbmc_project::Common::InternalFailure; + static constexpr auto str = "CALLOUT_ERRNO_TEST=%d"; + static constexpr auto str_short = "CALLOUT_ERRNO_TEST"; + using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; + explicit constexpr CALLOUT_ERRNO_TEST(int32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct CALLOUT_DEVICE_PATH_TEST +{ + static constexpr auto str = "CALLOUT_DEVICE_PATH_TEST=%s"; + static constexpr auto str_short = "CALLOUT_DEVICE_PATH_TEST"; + using type = std::tuple<std::decay_t<decltype(str)>,const char*>; + explicit constexpr CALLOUT_DEVICE_PATH_TEST(const char* a) : _entry(entry(str, a)) {}; + type _entry; }; -} +} // namespace _Callout + +struct Callout : public sdbusplus::exception_t +{ + static constexpr auto errName = "example.xyz.openbmc_project.Example.Device.Callout"; + static constexpr auto errDesc = "Generic device callout"; + static constexpr auto L = level::ERR; + using CALLOUT_ERRNO_TEST = _Callout::CALLOUT_ERRNO_TEST; + using CALLOUT_DEVICE_PATH_TEST = _Callout::CALLOUT_DEVICE_PATH_TEST; + using metadata_types = std::tuple<CALLOUT_ERRNO_TEST, CALLOUT_DEVICE_PATH_TEST>; + + const char* name() const noexcept + { + return errName; + } + + const char* description() const noexcept + { + return errDesc; + } + + const char* what() const noexcept + { + return errName; + } +}; + +} // namespace Device +} // namespace Example +} // namespace openbmc_project +} // namespace xyz +} // namespace example + + namespace xyz { @@ -557,29 +892,13 @@ struct CALLOUT_DEVICE_PATH } // namespace _Device -struct Device : public sdbusplus::exception_t +struct Device { - static constexpr auto errName = "xyz.openbmc_project.Common.Callout.Device"; - static constexpr auto errDesc = "Generic device callout"; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_ERRNO = _Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = _Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Callout @@ -621,30 +940,14 @@ struct CALLOUT_GPIO_NUM } // namespace _GPIO -struct GPIO : public sdbusplus::exception_t +struct GPIO { - static constexpr auto errName = "xyz.openbmc_project.Common.Callout.GPIO"; - static constexpr auto errDesc = "Callout GPIO pin"; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_GPIO_NUM = _GPIO::CALLOUT_GPIO_NUM; using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_GPIO_NUM, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Callout @@ -694,31 +997,15 @@ struct CALLOUT_IIC_ADDR } // namespace _IIC -struct IIC : public sdbusplus::exception_t +struct IIC { - static constexpr auto errName = "xyz.openbmc_project.Common.Callout.IIC"; - static constexpr auto errDesc = "Callout IIC device"; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_IIC_BUS = _IIC::CALLOUT_IIC_BUS; using CALLOUT_IIC_ADDR = _IIC::CALLOUT_IIC_ADDR; using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_IIC_BUS, CALLOUT_IIC_ADDR, CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Callout @@ -760,28 +1047,12 @@ struct CALLOUT_INVENTORY_PATH } // namespace _Inventory -struct Inventory : public sdbusplus::exception_t +struct Inventory { - static constexpr auto errName = "xyz.openbmc_project.Common.Callout.Inventory"; - static constexpr auto errDesc = "Inventory item callout"; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_INVENTORY_PATH = _Inventory::CALLOUT_INVENTORY_PATH; using metadata_types = std::tuple<CALLOUT_INVENTORY_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Callout @@ -823,28 +1094,12 @@ struct CALLOUT_IPMI_SENSOR_NUM } // namespace _IPMISensor -struct IPMISensor : public sdbusplus::exception_t +struct IPMISensor { - static constexpr auto errName = "xyz.openbmc_project.Common.Callout.IPMISensor"; - static constexpr auto errDesc = "Callout IPMI sensor"; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_IPMI_SENSOR_NUM = _IPMISensor::CALLOUT_IPMI_SENSOR_NUM; using metadata_types = std::tuple<CALLOUT_IPMI_SENSOR_NUM>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Callout @@ -868,40 +1123,65 @@ namespace xyz { namespace openbmc_project { -namespace Control +namespace State { namespace Host { -namespace _CommandNotSupported +namespace _SoftOffTimeout { -} // namespace _CommandNotSupported +} // namespace _SoftOffTimeout -struct CommandNotSupported : public sdbusplus::exception_t +struct SoftOffTimeout { - static constexpr auto errName = "xyz.openbmc_project.Control.Host.CommandNotSupported"; - static constexpr auto errDesc = "Command is not supported"; static constexpr auto L = level::ERR; - using metadata_types = std::tuple<>; + using TIMEOUT_IN_MSEC = xyz::openbmc_project::Common::Timeout::TIMEOUT_IN_MSEC; + using metadata_types = std::tuple<TIMEOUT_IN_MSEC>; - const char* name() const noexcept - { - return errName; - } +}; - const char* description() const noexcept - { - return errDesc; - } +} // namespace Host +} // namespace State +} // namespace openbmc_project +} // namespace xyz - const char* what() const noexcept - { - return errName; - } + +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::State::Host::Error::SoftOffTimeout> +{ + using type = xyz::openbmc_project::State::Host::SoftOffTimeout; }; -} // namespace Host +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Control +{ +namespace Device +{ +namespace _WriteFailure +{ + + +} // namespace _WriteFailure + +struct WriteFailure +{ + static constexpr auto L = level::ERR; + using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; + using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; + using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; + +}; + +} // namespace Device } // namespace Control } // namespace openbmc_project } // namespace xyz @@ -911,9 +1191,9 @@ namespace details { template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Control::Host::Error::CommandNotSupported> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Control::Device::Error::WriteFailure> { - using type = xyz::openbmc_project::Control::Host::CommandNotSupported; + using type = xyz::openbmc_project::Control::Device::WriteFailure; }; } @@ -924,7 +1204,7 @@ namespace open_power { namespace OCC { -namespace PassThrough +namespace Device { namespace _OpenFailure { @@ -932,32 +1212,16 @@ namespace _OpenFailure } // namespace _OpenFailure -struct OpenFailure : public sdbusplus::exception_t +struct OpenFailure { - static constexpr auto errName = "org.open_power.OCC.PassThrough.OpenFailure"; - static constexpr auto errDesc = "Opening OCC device failed."; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; -} // namespace PassThrough +} // namespace Device } // namespace OCC } // namespace open_power } // namespace org @@ -967,9 +1231,9 @@ namespace details { template <> -struct map_exception_type<sdbusplus::org::open_power::OCC::PassThrough::Error::OpenFailure> +struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::OpenFailure> { - using type = org::open_power::OCC::PassThrough::OpenFailure; + using type = org::open_power::OCC::Device::OpenFailure; }; } @@ -980,7 +1244,7 @@ namespace open_power { namespace OCC { -namespace PassThrough +namespace Device { namespace _ReadFailure { @@ -988,32 +1252,16 @@ namespace _ReadFailure } // namespace _ReadFailure -struct ReadFailure : public sdbusplus::exception_t +struct ReadFailure { - static constexpr auto errName = "org.open_power.OCC.PassThrough.ReadFailure"; - static constexpr auto errDesc = "Reading from OCC failed."; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; -} // namespace PassThrough +} // namespace Device } // namespace OCC } // namespace open_power } // namespace org @@ -1023,9 +1271,9 @@ namespace details { template <> -struct map_exception_type<sdbusplus::org::open_power::OCC::PassThrough::Error::ReadFailure> +struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::ReadFailure> { - using type = org::open_power::OCC::PassThrough::ReadFailure; + using type = org::open_power::OCC::Device::ReadFailure; }; } @@ -1036,7 +1284,7 @@ namespace open_power { namespace OCC { -namespace PassThrough +namespace Device { namespace _WriteFailure { @@ -1044,32 +1292,16 @@ namespace _WriteFailure } // namespace _WriteFailure -struct WriteFailure : public sdbusplus::exception_t +struct WriteFailure { - static constexpr auto errName = "org.open_power.OCC.PassThrough.WriteFailure"; - static constexpr auto errDesc = "Writing to OCC failed."; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; -} // namespace PassThrough +} // namespace Device } // namespace OCC } // namespace open_power } // namespace org @@ -1079,133 +1311,92 @@ namespace details { template <> -struct map_exception_type<sdbusplus::org::open_power::OCC::PassThrough::Error::WriteFailure> +struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::WriteFailure> { - using type = org::open_power::OCC::PassThrough::WriteFailure; + using type = org::open_power::OCC::Device::WriteFailure; }; } -namespace xyz +namespace org { -namespace openbmc_project +namespace open_power { -namespace Control +namespace OCC { namespace Device { -namespace _WriteFailure +namespace _ConfigFailure { -} // namespace _WriteFailure +} // namespace _ConfigFailure -struct WriteFailure : public sdbusplus::exception_t +struct ConfigFailure { - static constexpr auto errName = "xyz.openbmc_project.Control.Device.WriteFailure"; - static constexpr auto errDesc = "Failed to write to device."; - static constexpr auto L = level::INFO; + static constexpr auto L = level::ERR; using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } }; } // namespace Device -} // namespace Control -} // namespace openbmc_project -} // namespace xyz +} // namespace OCC +} // namespace open_power +} // namespace org namespace details { template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Control::Device::Error::WriteFailure> +struct map_exception_type<sdbusplus::org::open_power::OCC::Device::Error::ConfigFailure> { - using type = xyz::openbmc_project::Control::Device::WriteFailure; + using type = org::open_power::OCC::Device::ConfigFailure; }; } -namespace example -{ namespace xyz { namespace openbmc_project { -namespace Example +namespace Sensor { namespace Device { -namespace _Callout +namespace _ReadFailure { -struct CALLOUT_ERRNO_TEST -{ - static constexpr auto str = "CALLOUT_ERRNO_TEST=%d"; - static constexpr auto str_short = "CALLOUT_ERRNO_TEST"; - using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; - explicit constexpr CALLOUT_ERRNO_TEST(int32_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct CALLOUT_DEVICE_PATH_TEST -{ - static constexpr auto str = "CALLOUT_DEVICE_PATH_TEST=%s"; - static constexpr auto str_short = "CALLOUT_DEVICE_PATH_TEST"; - using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr CALLOUT_DEVICE_PATH_TEST(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; -} // namespace _Callout +} // namespace _ReadFailure -struct Callout : public sdbusplus::exception_t +struct ReadFailure { - static constexpr auto errName = "example.xyz.openbmc_project.Example.Device.Callout"; - static constexpr auto errDesc = "Generic device callout"; - static constexpr auto L = level::INFO; - using CALLOUT_ERRNO_TEST = _Callout::CALLOUT_ERRNO_TEST; - using CALLOUT_DEVICE_PATH_TEST = _Callout::CALLOUT_DEVICE_PATH_TEST; - using metadata_types = std::tuple<CALLOUT_ERRNO_TEST, CALLOUT_DEVICE_PATH_TEST>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } + static constexpr auto L = level::ERR; + using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; + using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; + using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - const char* what() const noexcept - { - return errName; - } }; } // namespace Device -} // namespace Example +} // namespace Sensor } // namespace openbmc_project } // namespace xyz -} // namespace example +namespace details +{ + +template <> +struct map_exception_type<sdbusplus::xyz::openbmc_project::Sensor::Device::Error::ReadFailure> +{ + using type = xyz::openbmc_project::Sensor::Device::ReadFailure; +}; + +} namespace example { @@ -1217,101 +1408,48 @@ namespace Example { namespace Elog { -namespace _TestErrorTwo +namespace _TestErrorOne { -struct DEV_ADDR -{ - static constexpr auto str = "DEV_ADDR=0x%.8X"; - static constexpr auto str_short = "DEV_ADDR"; - using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>; - explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct DEV_ID +struct ERRNUM { - static constexpr auto str = "DEV_ID=%u"; - static constexpr auto str_short = "DEV_ID"; - using type = std::tuple<std::decay_t<decltype(str)>,uint32_t>; - explicit constexpr DEV_ID(uint32_t a) : _entry(entry(str, a)) {}; + static constexpr auto str = "ERRNUM=0x%.4X"; + static constexpr auto str_short = "ERRNUM"; + using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>; + explicit constexpr ERRNUM(uint16_t a) : _entry(entry(str, a)) {}; type _entry; }; -struct DEV_NAME +struct FILE_PATH { - static constexpr auto str = "DEV_NAME=%s"; - static constexpr auto str_short = "DEV_NAME"; + static constexpr auto str = "FILE_PATH=%s"; + static constexpr auto str_short = "FILE_PATH"; using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr DEV_NAME(const char* a) : _entry(entry(str, a)) {}; + explicit constexpr FILE_PATH(const char* a) : _entry(entry(str, a)) {}; type _entry; }; - -} // namespace _TestErrorTwo - -struct TestErrorTwo : public sdbusplus::exception_t -{ - static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestErrorTwo"; - static constexpr auto errDesc = "This is test error two"; - static constexpr auto L = level::ERR; - using DEV_ADDR = _TestErrorTwo::DEV_ADDR; - using DEV_ID = _TestErrorTwo::DEV_ID; - using DEV_NAME = _TestErrorTwo::DEV_NAME; - using metadata_types = std::tuple<DEV_ADDR, DEV_ID, DEV_NAME>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace Elog -} // namespace Example -} // namespace openbmc_project -} // namespace xyz -} // namespace example - - - -namespace example -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Example -{ -namespace Elog -{ -namespace _AutoTestSimple -{ - -struct STRING +struct FILE_NAME { - static constexpr auto str = "STRING=%s"; - static constexpr auto str_short = "STRING"; + static constexpr auto str = "FILE_NAME=%s"; + static constexpr auto str_short = "FILE_NAME"; using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr STRING(const char* a) : _entry(entry(str, a)) {}; + explicit constexpr FILE_NAME(const char* a) : _entry(entry(str, a)) {}; type _entry; }; -} // namespace _AutoTestSimple +} // namespace _TestErrorOne -struct AutoTestSimple : public sdbusplus::exception_t +struct TestErrorOne : public sdbusplus::exception_t { - static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.AutoTestSimple"; - static constexpr auto errDesc = "This is a simple test error."; - static constexpr auto L = level::ERR; - using STRING = _AutoTestSimple::STRING; - using metadata_types = std::tuple<STRING>; + static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestErrorOne"; + static constexpr auto errDesc = "this is test error one"; + static constexpr auto L = level::INFO; + using ERRNUM = _TestErrorOne::ERRNUM; + using FILE_PATH = _TestErrorOne::FILE_PATH; + using FILE_NAME = _TestErrorOne::FILE_NAME; + using DEV_ADDR = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR; + using DEV_ID = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID; + using DEV_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME; + using metadata_types = std::tuple<ERRNUM, FILE_PATH, FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>; const char* name() const noexcept { @@ -1395,356 +1533,6 @@ struct TestCallout : public sdbusplus::exception_t -namespace xyz -{ -namespace openbmc_project -{ -namespace Common -{ -namespace File -{ -namespace _Open -{ - -struct ERRNO -{ - static constexpr auto str = "ERRNO=%d"; - static constexpr auto str_short = "ERRNO"; - using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; - explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct PATH -{ - static constexpr auto str = "PATH=%s"; - static constexpr auto str_short = "PATH"; - using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; - -} // namespace _Open - -struct Open : public sdbusplus::exception_t -{ - static constexpr auto errName = "xyz.openbmc_project.Common.File.Open"; - static constexpr auto errDesc = "Failed to open a file"; - static constexpr auto L = level::INFO; - using ERRNO = _Open::ERRNO; - using PATH = _Open::PATH; - using metadata_types = std::tuple<ERRNO, PATH>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace File -} // namespace Common -} // namespace openbmc_project -} // namespace xyz - - -namespace details -{ - -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::File::Error::Open> -{ - using type = xyz::openbmc_project::Common::File::Open; -}; - -} - -namespace xyz -{ -namespace openbmc_project -{ -namespace Common -{ -namespace File -{ -namespace _Seek -{ - -struct OFFSET -{ - static constexpr auto str = "OFFSET=%ll"; - static constexpr auto str_short = "OFFSET"; - using type = std::tuple<std::decay_t<decltype(str)>,int64_t>; - explicit constexpr OFFSET(int64_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct WHENCE -{ - static constexpr auto str = "WHENCE=%d"; - static constexpr auto str_short = "WHENCE"; - using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; - explicit constexpr WHENCE(int32_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct ERRNO -{ - static constexpr auto str = "ERRNO=%d"; - static constexpr auto str_short = "ERRNO"; - using type = std::tuple<std::decay_t<decltype(str)>,int32_t>; - explicit constexpr ERRNO(int32_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct PATH -{ - static constexpr auto str = "PATH=%s"; - static constexpr auto str_short = "PATH"; - using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; - -} // namespace _Seek - -struct Seek : public sdbusplus::exception_t -{ - static constexpr auto errName = "xyz.openbmc_project.Common.File.Seek"; - static constexpr auto errDesc = "Failed to seek a file"; - static constexpr auto L = level::INFO; - using OFFSET = _Seek::OFFSET; - using WHENCE = _Seek::WHENCE; - using ERRNO = _Seek::ERRNO; - using PATH = _Seek::PATH; - using metadata_types = std::tuple<OFFSET, WHENCE, ERRNO, PATH>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace File -} // namespace Common -} // namespace openbmc_project -} // namespace xyz - - -namespace details -{ - -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Common::File::Error::Seek> -{ - using type = xyz::openbmc_project::Common::File::Seek; -}; - -} - -namespace xyz -{ -namespace openbmc_project -{ -namespace State -{ -namespace Host -{ -namespace _SoftOffTimeout -{ - - -} // namespace _SoftOffTimeout - -struct SoftOffTimeout : public sdbusplus::exception_t -{ - static constexpr auto errName = "xyz.openbmc_project.State.Host.SoftOffTimeout"; - static constexpr auto errDesc = "Host did not shutdown within configured time."; - static constexpr auto L = level::INFO; - using TIMEOUT_IN_MSEC = xyz::openbmc_project::Common::Timeout::TIMEOUT_IN_MSEC; - using metadata_types = std::tuple<TIMEOUT_IN_MSEC>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace Host -} // namespace State -} // namespace openbmc_project -} // namespace xyz - - -namespace details -{ - -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::State::Host::Error::SoftOffTimeout> -{ - using type = xyz::openbmc_project::State::Host::SoftOffTimeout; -}; - -} - -namespace xyz -{ -namespace openbmc_project -{ -namespace Sensor -{ -namespace Device -{ -namespace _ReadFailure -{ - - -} // namespace _ReadFailure - -struct ReadFailure : public sdbusplus::exception_t -{ - static constexpr auto errName = "xyz.openbmc_project.Sensor.Device.ReadFailure"; - static constexpr auto errDesc = "Failed to read from device."; - static constexpr auto L = level::INFO; - using CALLOUT_ERRNO = xyz::openbmc_project::Common::Callout::Device::CALLOUT_ERRNO; - using CALLOUT_DEVICE_PATH = xyz::openbmc_project::Common::Callout::Device::CALLOUT_DEVICE_PATH; - using metadata_types = std::tuple<CALLOUT_ERRNO, CALLOUT_DEVICE_PATH>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace Device -} // namespace Sensor -} // namespace openbmc_project -} // namespace xyz - - -namespace details -{ - -template <> -struct map_exception_type<sdbusplus::xyz::openbmc_project::Sensor::Device::Error::ReadFailure> -{ - using type = xyz::openbmc_project::Sensor::Device::ReadFailure; -}; - -} - -namespace example -{ -namespace xyz -{ -namespace openbmc_project -{ -namespace Example -{ -namespace Elog -{ -namespace _TestErrorOne -{ - -struct ERRNUM -{ - static constexpr auto str = "ERRNUM=0x%.4X"; - static constexpr auto str_short = "ERRNUM"; - using type = std::tuple<std::decay_t<decltype(str)>,uint16_t>; - explicit constexpr ERRNUM(uint16_t a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct FILE_PATH -{ - static constexpr auto str = "FILE_PATH=%s"; - static constexpr auto str_short = "FILE_PATH"; - using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr FILE_PATH(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; -struct FILE_NAME -{ - static constexpr auto str = "FILE_NAME=%s"; - static constexpr auto str_short = "FILE_NAME"; - using type = std::tuple<std::decay_t<decltype(str)>,const char*>; - explicit constexpr FILE_NAME(const char* a) : _entry(entry(str, a)) {}; - type _entry; -}; - -} // namespace _TestErrorOne - -struct TestErrorOne : public sdbusplus::exception_t -{ - static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestErrorOne"; - static constexpr auto errDesc = "this is test error one"; - static constexpr auto L = level::INFO; - using ERRNUM = _TestErrorOne::ERRNUM; - using FILE_PATH = _TestErrorOne::FILE_PATH; - using FILE_NAME = _TestErrorOne::FILE_NAME; - using DEV_ADDR = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ADDR; - using DEV_ID = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_ID; - using DEV_NAME = example::xyz::openbmc_project::Example::Elog::TestErrorTwo::DEV_NAME; - using metadata_types = std::tuple<ERRNUM, FILE_PATH, FILE_NAME, DEV_ADDR, DEV_ID, DEV_NAME>; - - const char* name() const noexcept - { - return errName; - } - - const char* description() const noexcept - { - return errDesc; - } - - const char* what() const noexcept - { - return errName; - } -}; - -} // namespace Elog -} // namespace Example -} // namespace openbmc_project -} // namespace xyz -} // namespace example - - - namespace example { namespace xyz diff --git a/occ_device.hpp b/occ_device.hpp index dc057be..6538597 100644 --- a/occ_device.hpp +++ b/occ_device.hpp @@ -2,6 +2,8 @@ #include <fstream> #include <experimental/filesystem> +#include "occ_events.hpp" +#include "occ_errors.hpp" #include "config.h" namespace open_power { @@ -25,10 +27,16 @@ class Device /** @brief Constructs the Device object * - * @param[in] name - OCC instance name + * @param[in] event - Unique ptr reference to sd_event + * @param[in] name - OCC instance name + * @param[in] callback - Optional callback on errors */ - Device(const std::string& name) : - config(name + '-' + "dev0") + Device(EventPtr& event, + const std::string& name, + std::function<void()> callBack = nullptr) : + config(name + '-' + "dev0"), + errorFile(fs::path(config) / "occ_error"), + error(event, errorFile, callBack) { // Nothing to do here } @@ -36,20 +44,38 @@ class Device /** @brief Binds device to the OCC driver */ inline void bind() { + // Bind the device return write(bindPath, config); } /** @brief Un-binds device from the OCC driver */ inline void unBind() { - return write(unBindPath, config); + // Unbind the device + return write(unBindPath, config); + } + + /** @brief Starts to monitor for errors */ + inline void addErrorWatch() + { + return error.addWatch(); + } + + /** @brief stops monitoring for errors */ + inline void removeErrorWatch() + { + return error.removeWatch(); } private: /** @brief Config value to be used to do bind and unbind */ const std::string config; + /** @brief This file contains 0 for success, non-zero for errors */ + const fs::path errorFile; + /** @brief To bind the device to the OCC driver, do: + * * Write occ<#>-dev0 to: /sys/bus/platform/drivers/occ-hwmon/bind */ static fs::path bindPath; @@ -59,6 +85,9 @@ class Device */ static fs::path unBindPath; + /** Abstraction of error monitoring */ + Error error; + /** @brief file writer to achieve bind and unbind * * @param[in] filename - Name of file to be written diff --git a/occ_errors.cpp b/occ_errors.cpp new file mode 100644 index 0000000..f2da49f --- /dev/null +++ b/occ_errors.cpp @@ -0,0 +1,145 @@ +#include <fcntl.h> +#include <unistd.h> +#include <sys/ioctl.h> +#include <errno.h> +#include <phosphor-logging/log.hpp> +#include <phosphor-logging/elog.hpp> +#include <xyz/openbmc_project/Common/error.hpp> +#include <org/open_power/OCC/Device/error.hpp> +#include "occ_errors.hpp" +#include "elog-errors.hpp" +namespace open_power +{ +namespace occ +{ + +// Value in error file indicating success +constexpr auto NO_ERROR = '0'; + +using namespace phosphor::logging; +using namespace sdbusplus::org::open_power::OCC::Device::Error; +using InternalFailure = sdbusplus::xyz::openbmc_project::Common:: + Error::InternalFailure; + +// Populate the file descriptor on the error file +void Error::openFile() +{ + using namespace phosphor::logging; + + fd = open(file.c_str(), O_RDONLY | O_NONBLOCK); + if (fd < 0) + { + elog<OpenFailure>( + phosphor::logging::org::open_power::OCC::Device:: + OpenFailure::CALLOUT_ERRNO(errno), + phosphor::logging::org::open_power::OCC::Device:: + OpenFailure::CALLOUT_DEVICE_PATH(file.c_str())); + } +} + +// Attaches the FD to event loop and registers the callback handler +void Error::registerCallBack() +{ + decltype(eventSource.get()) sourcePtr = nullptr; + auto r = sd_event_add_io(event.get(), &sourcePtr, fd, + EPOLLIN, processEvents, this); + eventSource.reset(sourcePtr); + + if (r < 0) + { + log<level::ERR>("Failed to register callback handler", + entry("ERROR=%s", strerror(-r))); + elog<InternalFailure>(); + } +} + +// Starts to watch for errors +void Error::addWatch() +{ + // Open the file + openFile(); + + // register the callback handler + registerCallBack(); +} + +// Stops watching for errors +void Error::removeWatch() +{ + // Close the file + if (fd >= 0) + { + close(fd); + } + + // Reduce the reference count. Since there is only one instances + // of add_io, this will result empty loop + eventSource.reset(); +} + +// Callback handler when there is an activity on the FD +int Error::processEvents(sd_event_source* es, int fd, + uint32_t revents, void* userData) +{ + log<level::INFO>("Error file updated"); + auto error = static_cast<Error*>(userData); + + error->analyzeEvent(); + return 0; +} + +// Reads the error file and analyzes the data +void Error::analyzeEvent() +{ + // Get the number of bytes to read + int len = -1; + auto r = ioctl(fd, FIONREAD, &len); + if (r < 0) + { + elog<ConfigFailure>( + phosphor::logging::org::open_power::OCC::Device:: + ConfigFailure::CALLOUT_ERRNO(errno), + phosphor::logging::org::open_power::OCC::Device:: + ConfigFailure::CALLOUT_DEVICE_PATH(file.c_str())); + } + + // A non-zero data indicates an error condition + // Let the caller take appropriate action on this + auto data = readFile(len); + if (data.empty() || + data.front() == NO_ERROR) + { + return; + } + + // This must be an error + if (callBack) + { + callBack(); + } + return; +} + +// Reads so many bytes as passed in +std::string Error::readFile(int len) const +{ + auto data = std::make_unique<char[]>(len+1); + + // This file get created soon after binding. A value of 0 is + // deemed success and anything else is a Failure + // Since all the sysfs files would have size of 4096, if we read 0 + // bytes -or- value '0', then it just means we are fine + auto r = read(fd, data.get(), len); + if (r < 0) + { + elog<ReadFailure>( + phosphor::logging::org::open_power::OCC::Device:: + ReadFailure::CALLOUT_ERRNO(errno), + phosphor::logging::org::open_power::OCC::Device:: + ReadFailure::CALLOUT_DEVICE_PATH(file.c_str())); + } + return std::string(data.get()); +} + +} // namespace occ +} // namespace open_power diff --git a/occ_errors.hpp b/occ_errors.hpp new file mode 100644 index 0000000..1e66ffc --- /dev/null +++ b/occ_errors.hpp @@ -0,0 +1,107 @@ +#pragma once + +#include <unistd.h> +#include <functional> +#include <experimental/filesystem> +#include "occ_events.hpp" +#include "config.h" +namespace open_power +{ +namespace occ +{ + +namespace fs = std::experimental::filesystem; + +/** @class Error + * @brief Monitors for OCC device error condition + */ +class Error +{ + public: + Error() = delete; + Error(const Error&) = delete; + Error& operator=(const Error&) = delete; + Error(Error&&) = default; + Error& operator=(Error&&) = default; + + /** @brief Constructs the Error object + * + * @param[in] event - reference to sd_event unique_ptr + * @param[in] file - File used by driver to communicate errors + * @param[in] callBack - Optional function callback on error condition + */ + Error(EventPtr& event, + const fs::path& file, + std::function<void()> callBack = nullptr) : + event(event), + file(fs::path(DEV_PATH) / file), + callBack(callBack) + { + // Nothing to do here. + } + + ~Error() + { + if (fd>= 0) + { + close(fd); + } + } + + /** @brief Starts to monitor for error conditions */ + void addWatch(); + + /** @brief Removes error watch */ + void removeWatch(); + + private: + /** @brief sd_event wrapped in unique_ptr */ + EventPtr& event; + + /** @brief event source wrapped in unique_ptr */ + EventSourcePtr eventSource; + + /** Error file */ + const fs::path file; + + /** @brief Optional function to call on error scenario */ + std::function<void()> callBack; + + /** @brief File descriptor to watch for errors */ + int fd = -1; + + /** @brief attaches FD to events and sets up callback handler */ + void registerCallBack(); + + /** @brief Opens the file and populates fd */ + void openFile(); + + /** @brief Reads file data + * + * @return data read. Since its a /sysfs entry, + * it would be a string + */ + std::string readFile(int) const; + + /** @brief Callback handler when the FD has some activity on it + * + * @param[in] es - Populated event source + * @param[in] fd - Associated File descriptor + * @param[in] revents - Type of event + * @param[in] userData - User data that was passed during registration + * + * @return - 0 or positive number on success and negative + * errno otherwise + */ + static int processEvents(sd_event_source* es, int fd, + uint32_t revents, void* userData); + + /** @brief When the error event is received, analyzes it + * and makes a callback to error handler if the + * content denotes an error condition + */ + void analyzeEvent(); +}; + +} // namespace occ +} // namespace open_power diff --git a/occ_events.hpp b/occ_events.hpp new file mode 100644 index 0000000..cc6f616 --- /dev/null +++ b/occ_events.hpp @@ -0,0 +1,30 @@ +#pragma once + +#include <systemd/sd-event.h> +namespace open_power +{ +namespace occ +{ + +/* Need a custom deleter for freeing up sd_event */ +struct EventDeleter +{ + void operator()(sd_event* event) const + { + event = sd_event_unref(event); + } +}; +using EventPtr = std::unique_ptr<sd_event, EventDeleter>; + +/* Need a custom deleter for freeing up sd_event_source */ +struct EventSourceDeleter +{ + void operator()(sd_event_source* eventSource) const + { + eventSource = sd_event_source_unref(eventSource); + } +}; +using EventSourcePtr = std::unique_ptr<sd_event_source, EventSourceDeleter>; + +} // namespace occ +} // namespace open_power diff --git a/occ_manager.hpp b/occ_manager.hpp index 48cd9c8..4430d74 100644 --- a/occ_manager.hpp +++ b/occ_manager.hpp @@ -32,10 +32,14 @@ struct Manager /** @brief Adds OCC pass-through and status objects on the bus * when corresponding CPU inventory is created. - * @param[in] bus - handle to the bus + * + * @param[in] bus - handle to the bus + * @param[in] event - Unique ptr reference to sd_event */ - Manager(sdbusplus::bus::bus& bus): - bus(bus) + Manager(sdbusplus::bus::bus& bus, + EventPtr& event) : + bus(bus), + event(event) { for (auto id = 0; id < MAX_CPUS; ++id) { @@ -50,7 +54,7 @@ struct Manager } /** @brief Callback that responds to cpu creation in the inventory - - * by creating the occ passthrough and status objects. + * by creating the needed objects. * * @param[in] msg - bus message * @@ -78,6 +82,7 @@ struct Manager statusObjects.emplace_back( std::make_unique<Status>( bus, + event, path.c_str())); // Create the power cap monitor object for master occ (0) @@ -94,6 +99,9 @@ struct Manager /** @brief reference to the bus */ sdbusplus::bus::bus& bus; + /** @brief reference to sd_event wrapped in unique_ptr */ + EventPtr& event; + /** @brief OCC pass-through objects */ std::vector<std::unique_ptr<PassThrough>> passThroughObjects; diff --git a/occ_pass_through.cpp b/occ_pass_through.cpp index fbb98c2..2846dda 100644 --- a/occ_pass_through.cpp +++ b/occ_pass_through.cpp @@ -4,7 +4,7 @@ #include <errno.h> #include <phosphor-logging/log.hpp> #include <phosphor-logging/elog.hpp> -#include <org/open_power/OCC/PassThrough/error.hpp> +#include <org/open_power/OCC/Device/error.hpp> #include "occ_pass_through.hpp" #include "elog-errors.hpp" namespace open_power @@ -25,7 +25,7 @@ PassThrough::PassThrough( int PassThrough::openDevice() { using namespace phosphor::logging; - using namespace sdbusplus::org::open_power::OCC::PassThrough::Error; + using namespace sdbusplus::org::open_power::OCC::Device::Error; // Device instance number starts from 1. devicePath.append(std::to_string((this->path.back() - '0') + 1)); @@ -35,9 +35,9 @@ int PassThrough::openDevice() { // This would log and terminate since its not handled. elog<OpenFailure>( - phosphor::logging::org::open_power::OCC::PassThrough:: + phosphor::logging::org::open_power::OCC::Device:: OpenFailure::CALLOUT_ERRNO(errno), - phosphor::logging::org::open_power::OCC::PassThrough:: + phosphor::logging::org::open_power::OCC::Device:: OpenFailure::CALLOUT_DEVICE_PATH(devicePath.c_str())); } return fd; @@ -46,7 +46,7 @@ int PassThrough::openDevice() std::vector<int32_t> PassThrough::send(std::vector<int32_t> command) { using namespace phosphor::logging; - using namespace sdbusplus::org::open_power::OCC::PassThrough::Error; + using namespace sdbusplus::org::open_power::OCC::Device::Error; std::vector<int32_t> response {}; @@ -65,9 +65,9 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command) { // This would log and terminate since its not handled. elog<WriteFailure>( - phosphor::logging::org::open_power::OCC::PassThrough:: + phosphor::logging::org::open_power::OCC::Device:: WriteFailure::CALLOUT_ERRNO(errno), - phosphor::logging::org::open_power::OCC::PassThrough:: + phosphor::logging::org::open_power::OCC::Device:: WriteFailure::CALLOUT_DEVICE_PATH(devicePath.c_str())); } @@ -95,9 +95,9 @@ std::vector<int32_t> PassThrough::send(std::vector<int32_t> command) { // This would log and terminate since its not handled. elog<ReadFailure>( - phosphor::logging::org::open_power::OCC::PassThrough:: + phosphor::logging::org::open_power::OCC::Device:: ReadFailure::CALLOUT_ERRNO(errno), - phosphor::logging::org::open_power::OCC::PassThrough:: + phosphor::logging::org::open_power::OCC::Device:: ReadFailure::CALLOUT_DEVICE_PATH(devicePath.c_str())); } } diff --git a/occ_status.cpp b/occ_status.cpp index ca8a1f9..83825c5 100644 --- a/occ_status.cpp +++ b/occ_status.cpp @@ -13,15 +13,28 @@ bool Status::occActive(bool value) { // Bind the device device.bind(); + + // And watch for errors + device.addErrorWatch(); } else { - // Do the unbind + // Stop watching for errors + device.removeErrorWatch(); + + // Do the unbind. device.unBind(); } } return Base::Status::occActive(value); } +// Callback handler when a device error is reported. +void Status::deviceErrorHandler() +{ + // This would deem OCC inactive + this->occActive(false); +} + } // namespace occ } // namespace open_power diff --git a/occ_status.hpp b/occ_status.hpp index 5d092b7..f426048 100644 --- a/occ_status.hpp +++ b/occ_status.hpp @@ -3,6 +3,7 @@ #include <sdbusplus/bus.hpp> #include <sdbusplus/server/object.hpp> #include <org/open_power/OCC/Status/server.hpp> +#include "occ_events.hpp" #include "occ_device.hpp" namespace open_power { @@ -25,15 +26,18 @@ class Status : public Interface Status(Status&&) = default; Status& operator=(Status&&) = default; - /** @brief Constructs the Status object + /** @brief Constructs the Status object and + * the underlying device object * * @param[in] bus - DBus bus to attach to * @param[in] path - DBus object path */ - Status(sdbusplus::bus::bus& bus, const char* path) + Status(sdbusplus::bus::bus& bus, EventPtr& event, const char* path) : Interface(bus, path), path(path), - device(name + std::to_string((this->path.back() - '0') + 1)) + device(event, + name + std::to_string((this->path.back() - '0') + 1), + std::bind(&Status::deviceErrorHandler, this)) { // Nothing to do here } @@ -61,6 +65,9 @@ class Status : public Interface /** @brief OCC device object to do bind and unbind */ Device device; + + /** @brief Callback handler when device errors are detected */ + void deviceErrorHandler(); }; } // namespace occ diff --git a/org/open_power/OCC/Device.errors.yaml b/org/open_power/OCC/Device.errors.yaml new file mode 100644 index 0000000..9e8d09a --- /dev/null +++ b/org/open_power/OCC/Device.errors.yaml @@ -0,0 +1,15 @@ +# org.open_power.OCC.Device.OpenFailure +- name: OpenFailure + description: Opening OCC device failed. + +# org.open_power.OCC.Device.ReadFailure +- name: ReadFailure + description: Reading from OCC failed. + +# org.open_power.OCC.Device.WriteFailure +- name: WriteFailure + description: Writing to OCC failed. + +# org.open_power.OCC.Device.ConfigFailure +- name: ConfigFailure + description: Configuring device failed. diff --git a/org/open_power/OCC/PassThrough.metadata.yaml b/org/open_power/OCC/Device.metadata.yaml index 0b1c4f5..ee79e2d 100644 --- a/org/open_power/OCC/PassThrough.metadata.yaml +++ b/org/open_power/OCC/Device.metadata.yaml @@ -9,3 +9,7 @@ - name: WriteFailure inherits: - xyz.openbmc_project.Common.Callout.Device + +- name: ConfigFailure + inherits: + - xyz.openbmc_project.Common.Callout.Device diff --git a/org/open_power/OCC/PassThrough.errors.yaml b/org/open_power/OCC/PassThrough.errors.yaml deleted file mode 100644 index 4be6325..0000000 --- a/org/open_power/OCC/PassThrough.errors.yaml +++ /dev/null @@ -1,11 +0,0 @@ -# org.open_power.OCC.PassThrough.OpenFailure -- name: OpenFailure - description: Opening OCC device failed. - -# org.open_power.OCC.PassThrough.ReadFailure -- name: ReadFailure - description: Reading from OCC failed. - -# org.open_power.OCC.PassThrough.WriteFailure -- name: WriteFailure - description: Writing to OCC failed. diff --git a/test/Makefile.am b/test/Makefile.am index 6022c65..a680245 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -13,8 +13,11 @@ utest_LDFLAGS = -lgtest_main -lgtest \ $(SYSTEMD_LIBS) \ ${SDBUSPLUS_LIBS} \ $(OPENPOWER_DBUS_INTERFACES_LIBS) \ + $(PHOSPHOR_DBUS_INTERFACES_LIBS) \ -lstdc++fs utest_SOURCES = utest.cpp utest_LDADD = $(top_builddir)/powercap.o \ $(top_builddir)/occ_status.o \ - $(top_builddir)/occ_device.o + $(top_builddir)/occ_device.o \ + $(top_builddir)/occ_errors.o \ + $(top_builddir)/org/open_power/OCC/Device/error.o diff --git a/test/utest.cpp b/test/utest.cpp index e99d996..44691c2 100644 --- a/test/utest.cpp +++ b/test/utest.cpp @@ -1,4 +1,5 @@ #include <gtest/gtest.h> +#include <occ_events.hpp> #include "powercap.hpp" using namespace open_power::occ; @@ -8,13 +9,22 @@ class VerifyOccInput : public ::testing::Test public: VerifyOccInput() : bus(sdbusplus::bus::new_default()), - occStatus(bus,"/test/path"), + rc(sd_event_default(&event)), + eventP(event), + occStatus(bus, eventP, "/test/path"), pcap(bus,occStatus) - {} + { + EXPECT_GE(rc, 0); + event = nullptr; + } ~VerifyOccInput() {} sdbusplus::bus::bus bus; + sd_event* event; + int rc; + open_power::occ::EventPtr eventP; + Status occStatus; powercap::PowerCap pcap; }; |