From 448e74e811d94a70793df9f036ec4d9a1bdb1501 Mon Sep 17 00:00:00 2001 From: Tom Joseph Date: Mon, 24 Jul 2017 23:08:56 +0530 Subject: Add inventory path metadata to host event log entry The ESEL data contains sensor number to related to the event. The generated code maps sensor number to inventory path. The inventory path is added as metadata to the log entry for the admin to figure out the inventory affected by the system event. The generated header for Host event exception type is generated in the org/open_power/Host/Event/error.hpp. Phosphor repositories should not include open power specific header files. The eventual plan to is to move the code to add ESEL to an OEM repo, till then we would check in the header file in the repo. TODO: openbmc/openbmc#1658 The elog-errors.hpp is checked in for the CI to pass. TODO: openbmc/openbmc#1772 issue would take care, so that CI passes without the checking in elog-errors.hpp. Resolves openbmc/openbmc#1920 Change-Id: I31d68de475ef84b8755c5de6d7ce6d311dd32214 Signed-off-by: Tom Joseph --- elog-errors.hpp | 1935 +++++++++++++++++++++++++++++++++++++++++++++++++++ error-HostEvent.hpp | 37 + storageaddsel.cpp | 53 +- 3 files changed, 2006 insertions(+), 19 deletions(-) create mode 100644 elog-errors.hpp create mode 100644 error-HostEvent.hpp diff --git a/elog-errors.hpp b/elog-errors.hpp new file mode 100644 index 0000000..73e2dc1 --- /dev/null +++ b/elog-errors.hpp @@ -0,0 +1,1935 @@ +// This file was autogenerated. Do not edit! +// See elog-gen.py for more details +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Dump +{ +namespace Create +{ +namespace Error +{ + struct QuotaExceeded; +} // namespace Error +} // namespace Create +} // namespace Dump +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Event +{ +namespace Error +{ + struct Event; +} // namespace Error +} // namespace Event +} // namespace Host +} // namespace open_power +} // namespace org +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace State +{ +namespace Host +{ +namespace Error +{ + struct SoftOffTimeout; +} // namespace Error +} // namespace Host +} // namespace State +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Sensor +{ +namespace Device +{ +namespace Error +{ + struct ReadFailure; +} // namespace Error +} // namespace Device +} // namespace Sensor +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Control +{ +namespace Device +{ +namespace Error +{ + struct WriteFailure; +} // namespace Error +} // namespace Device +} // namespace Control +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace File +{ +namespace Error +{ + struct Seek; +} // namespace Error +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Control +{ +namespace Host +{ +namespace Error +{ + struct CommandNotSupported; +} // namespace Error +} // namespace Host +} // namespace Control +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Error +{ + struct InternalFailure; +} // namespace Error +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace Error +{ + struct Device; +} // namespace Error +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Access +{ +namespace Error +{ + struct WriteCFAM; +} // namespace Error +} // namespace Access +} // namespace Host +} // namespace open_power +} // namespace org +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace File +{ +namespace Error +{ + struct Open; +} // namespace Error +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Error +{ + struct Checkstop; +} // namespace Error +} // namespace Host +} // namespace open_power +} // namespace org +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace File +{ +namespace Error +{ + struct Write; +} // namespace Error +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace Error +{ + struct GPIO; +} // namespace Error +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Error +{ + struct InvalidArgument; +} // namespace Error +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Dump +{ +namespace Create +{ +namespace Error +{ + struct Disabled; +} // namespace Error +} // namespace Create +} // namespace Dump +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace Error +{ + struct IPMISensor; +} // namespace Error +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Error +{ + struct Timeout; +} // namespace Error +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace Error +{ + struct Inventory; +} // namespace Error +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace Error +{ + struct IIC; +} // namespace Error +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Error +{ + struct WatchdogTimedOut; +} // namespace Error +} // namespace Host +} // namespace open_power +} // namespace org +} // namespace sdbusplus + +namespace sdbusplus +{ +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Access +{ +namespace Error +{ + struct ReadCFAM; +} // namespace Error +} // namespace Access +} // namespace Host +} // namespace open_power +} // namespace org +} // namespace sdbusplus + + +namespace phosphor +{ + +namespace logging +{ + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace _Device +{ + +struct CALLOUT_ERRNO +{ + static constexpr auto str = "CALLOUT_ERRNO=%d"; + static constexpr auto str_short = "CALLOUT_ERRNO"; + using type = std::tuple,int32_t>; + explicit constexpr CALLOUT_ERRNO(int32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct CALLOUT_DEVICE_PATH +{ + static constexpr auto str = "CALLOUT_DEVICE_PATH=%s"; + static constexpr auto str_short = "CALLOUT_DEVICE_PATH"; + using type = std::tuple,const char*>; + explicit constexpr CALLOUT_DEVICE_PATH(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Device + +struct Device +{ + 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; + +}; + +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::Callout::Device; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace _GPIO +{ + +struct CALLOUT_GPIO_NUM +{ + static constexpr auto str = "CALLOUT_GPIO_NUM=%u"; + static constexpr auto str_short = "CALLOUT_GPIO_NUM"; + using type = std::tuple,uint32_t>; + explicit constexpr CALLOUT_GPIO_NUM(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _GPIO + +struct GPIO +{ + 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; + +}; + +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::Callout::GPIO; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace _IIC +{ + +struct CALLOUT_IIC_BUS +{ + static constexpr auto str = "CALLOUT_IIC_BUS=%s"; + static constexpr auto str_short = "CALLOUT_IIC_BUS"; + using type = std::tuple,const char*>; + explicit constexpr CALLOUT_IIC_BUS(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct CALLOUT_IIC_ADDR +{ + static constexpr auto str = "CALLOUT_IIC_ADDR=0x%hx"; + static constexpr auto str_short = "CALLOUT_IIC_ADDR"; + using type = std::tuple,uint16_t>; + explicit constexpr CALLOUT_IIC_ADDR(uint16_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _IIC + +struct IIC +{ + 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; + +}; + +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::Callout::IIC; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace _Inventory +{ + +struct CALLOUT_INVENTORY_PATH +{ + static constexpr auto str = "CALLOUT_INVENTORY_PATH=%s"; + static constexpr auto str_short = "CALLOUT_INVENTORY_PATH"; + using type = std::tuple,const char*>; + explicit constexpr CALLOUT_INVENTORY_PATH(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Inventory + +struct Inventory +{ + static constexpr auto L = level::ERR; + using CALLOUT_INVENTORY_PATH = _Inventory::CALLOUT_INVENTORY_PATH; + using metadata_types = std::tuple; + +}; + +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::Callout::Inventory; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace Callout +{ +namespace _IPMISensor +{ + +struct CALLOUT_IPMI_SENSOR_NUM +{ + static constexpr auto str = "CALLOUT_IPMI_SENSOR_NUM=%u"; + static constexpr auto str_short = "CALLOUT_IPMI_SENSOR_NUM"; + using type = std::tuple,uint32_t>; + explicit constexpr CALLOUT_IPMI_SENSOR_NUM(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _IPMISensor + +struct IPMISensor +{ + static constexpr auto L = level::ERR; + using CALLOUT_IPMI_SENSOR_NUM = _IPMISensor::CALLOUT_IPMI_SENSOR_NUM; + using metadata_types = std::tuple; + +}; + +} // namespace Callout +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::Callout::IPMISensor; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace _Timeout +{ + +struct TIMEOUT_IN_MSEC +{ + static constexpr auto str = "TIMEOUT_IN_MSEC=%llu"; + static constexpr auto str_short = "TIMEOUT_IN_MSEC"; + using type = std::tuple,uint64_t>; + explicit constexpr TIMEOUT_IN_MSEC(uint64_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Timeout + +struct Timeout +{ + static constexpr auto L = level::ERR; + using TIMEOUT_IN_MSEC = _Timeout::TIMEOUT_IN_MSEC; + using metadata_types = std::tuple; + +}; + +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::Timeout; +}; + +} + +namespace xyz +{ +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 +{ + using type = xyz::openbmc_project::Common::InternalFailure; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace _InvalidArgument +{ + +struct ARGUMENT_NAME +{ + static constexpr auto str = "ARGUMENT_NAME=%s"; + static constexpr auto str_short = "ARGUMENT_NAME"; + using type = std::tuple,const char*>; + explicit constexpr ARGUMENT_NAME(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; +struct ARGUMENT_VALUE +{ + static constexpr auto str = "ARGUMENT_VALUE=%s"; + static constexpr auto str_short = "ARGUMENT_VALUE"; + using type = std::tuple,const char*>; + explicit constexpr ARGUMENT_VALUE(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _InvalidArgument + +struct InvalidArgument +{ + static constexpr auto L = level::ERR; + using ARGUMENT_NAME = _InvalidArgument::ARGUMENT_NAME; + using ARGUMENT_VALUE = _InvalidArgument::ARGUMENT_VALUE; + using metadata_types = std::tuple; + +}; + +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::InvalidArgument; +}; + +} + +namespace example +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Example +{ +namespace Device +{ +namespace _Callout +{ + +struct CALLOUT_ERRNO_TEST +{ + static constexpr auto str = "CALLOUT_ERRNO_TEST=%d"; + static constexpr auto str_short = "CALLOUT_ERRNO_TEST"; + using type = std::tuple,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,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; + + 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 +{ +namespace openbmc_project +{ +namespace Sensor +{ +namespace Device +{ +namespace _ReadFailure +{ + + +} // namespace _ReadFailure + +struct ReadFailure +{ + 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; + +}; + +} // namespace Device +} // namespace Sensor +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Sensor::Device::ReadFailure; +}; + +} + +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace _Checkstop +{ + + +} // namespace _Checkstop + +struct Checkstop +{ + static constexpr auto L = level::ERR; + using metadata_types = std::tuple<>; + +}; + +} // namespace Host +} // namespace open_power +} // namespace org + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = org::open_power::Host::Checkstop; +}; + +} + +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace _WatchdogTimedOut +{ + + +} // namespace _WatchdogTimedOut + +struct WatchdogTimedOut +{ + static constexpr auto L = level::ERR; + using metadata_types = std::tuple<>; + +}; + +} // namespace Host +} // namespace open_power +} // namespace org + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = org::open_power::Host::WatchdogTimedOut; +}; + +} + +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,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,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,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; + + 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 +{ + static constexpr auto str = "STRING=%s"; + static constexpr auto str_short = "STRING"; + using type = std::tuple,const char*>; + explicit constexpr STRING(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _AutoTestSimple + +struct AutoTestSimple : 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; + + 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 _TestCallout +{ + +struct DEV_ADDR +{ + static constexpr auto str = "DEV_ADDR=0x%.8X"; + static constexpr auto str_short = "DEV_ADDR"; + using type = std::tuple,uint32_t>; + explicit constexpr DEV_ADDR(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _TestCallout + +struct TestCallout : public sdbusplus::exception_t +{ + static constexpr auto errName = "example.xyz.openbmc_project.Example.Elog.TestCallout"; + static constexpr auto errDesc = "This is test error TestCallout"; + static constexpr auto L = level::ERR; + using DEV_ADDR = _TestCallout::DEV_ADDR; + using CALLOUT_ERRNO_TEST = example::xyz::openbmc_project::Example::Device::Callout::CALLOUT_ERRNO_TEST; + using CALLOUT_DEVICE_PATH_TEST = example::xyz::openbmc_project::Example::Device::Callout::CALLOUT_DEVICE_PATH_TEST; + using metadata_types = std::tuple; + + 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 org +{ +namespace open_power +{ +namespace Host +{ +namespace Event +{ +namespace _Event +{ + +struct ESEL +{ + static constexpr auto str = "ESEL=%s"; + static constexpr auto str_short = "ESEL"; + using type = std::tuple,const char*>; + explicit constexpr ESEL(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Event + +struct Event +{ + static constexpr auto L = level::ERR; + using ESEL = _Event::ESEL; + using CALLOUT_INVENTORY_PATH = xyz::openbmc_project::Common::Callout::Inventory::CALLOUT_INVENTORY_PATH; + using metadata_types = std::tuple; + +}; + +} // namespace Event +} // namespace Host +} // namespace open_power +} // namespace org + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = org::open_power::Host::Event::Event; +}; + +} + +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; + +}; + +} // namespace Device +} // namespace Control +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Control::Device::WriteFailure; +}; + +} + +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,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,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; + +}; + +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + 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,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,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,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,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; + +}; + +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::File::Seek; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Common +{ +namespace File +{ +namespace _Write +{ + +struct ERRNO +{ + static constexpr auto str = "ERRNO=%d"; + static constexpr auto str_short = "ERRNO"; + using type = std::tuple,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,const char*>; + explicit constexpr PATH(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Write + +struct Write +{ + static constexpr auto L = level::ERR; + using ERRNO = _Write::ERRNO; + using PATH = _Write::PATH; + using metadata_types = std::tuple; + +}; + +} // namespace File +} // namespace Common +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Common::File::Write; +}; + +} + +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Access +{ +namespace _WriteCFAM +{ + +struct ADDRESS +{ + static constexpr auto str = "ADDRESS=0x%X"; + static constexpr auto str_short = "ADDRESS"; + using type = std::tuple,uint32_t>; + explicit constexpr ADDRESS(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _WriteCFAM + +struct WriteCFAM +{ + static constexpr auto L = level::ERR; + using ADDRESS = _WriteCFAM::ADDRESS; + 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; + +}; + +} // namespace Access +} // namespace Host +} // namespace open_power +} // namespace org + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = org::open_power::Host::Access::WriteCFAM; +}; + +} + +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Access +{ +namespace _ReadCFAM +{ + +struct ADDRESS +{ + static constexpr auto str = "ADDRESS=0x%X"; + static constexpr auto str_short = "ADDRESS"; + using type = std::tuple,uint32_t>; + explicit constexpr ADDRESS(uint32_t a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _ReadCFAM + +struct ReadCFAM +{ + static constexpr auto L = level::ERR; + using ADDRESS = _ReadCFAM::ADDRESS; + 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; + +}; + +} // namespace Access +} // namespace Host +} // namespace open_power +} // namespace org + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = org::open_power::Host::Access::ReadCFAM; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace State +{ +namespace Host +{ +namespace _SoftOffTimeout +{ + + +} // namespace _SoftOffTimeout + +struct SoftOffTimeout +{ + static constexpr auto L = level::ERR; + using TIMEOUT_IN_MSEC = xyz::openbmc_project::Common::Timeout::TIMEOUT_IN_MSEC; + using metadata_types = std::tuple; + +}; + +} // namespace Host +} // namespace State +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::State::Host::SoftOffTimeout; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Dump +{ +namespace Create +{ +namespace _Disabled +{ + + +} // namespace _Disabled + +struct Disabled +{ + static constexpr auto L = level::ERR; + using metadata_types = std::tuple<>; + +}; + +} // namespace Create +} // namespace Dump +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Dump::Create::Disabled; +}; + +} + +namespace xyz +{ +namespace openbmc_project +{ +namespace Dump +{ +namespace Create +{ +namespace _QuotaExceeded +{ + +struct REASON +{ + static constexpr auto str = "REASON = %s"; + static constexpr auto str_short = "REASON "; + using type = std::tuple,const char*>; + explicit constexpr REASON (const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _QuotaExceeded + +struct QuotaExceeded +{ + static constexpr auto L = level::ERR; + using REASON = _QuotaExceeded::REASON ; + using metadata_types = std::tuple; + +}; + +} // namespace Create +} // namespace Dump +} // namespace openbmc_project +} // namespace xyz + + +namespace details +{ + +template <> +struct map_exception_type +{ + using type = xyz::openbmc_project::Dump::Create::QuotaExceeded; +}; + +} + +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 +{ + using type = xyz::openbmc_project::Control::Host::CommandNotSupported; +}; + +} + +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,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,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,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; + + 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 Foo +{ +namespace _Foo +{ + +struct FOO_DATA +{ + static constexpr auto str = "FOO_DATA=%s"; + static constexpr auto str_short = "FOO_DATA"; + using type = std::tuple,const char*>; + explicit constexpr FOO_DATA(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Foo + +struct Foo : public sdbusplus::exception_t +{ + static constexpr auto errName = "example.xyz.openbmc_project.Example.Foo.Foo"; + static constexpr auto errDesc = "this is test error Foo"; + static constexpr auto L = level::INFO; + using FOO_DATA = _Foo::FOO_DATA; + using ERRNUM = example::xyz::openbmc_project::Example::Elog::TestErrorOne::ERRNUM; + using FILE_PATH = example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_PATH; + using FILE_NAME = example::xyz::openbmc_project::Example::Elog::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; + + const char* name() const noexcept + { + return errName; + } + + const char* description() const noexcept + { + return errDesc; + } + + const char* what() const noexcept + { + return errName; + } +}; + +} // namespace Foo +} // namespace Example +} // namespace openbmc_project +} // namespace xyz +} // namespace example + + + +namespace example +{ +namespace xyz +{ +namespace openbmc_project +{ +namespace Example +{ +namespace Bar +{ +namespace _Bar +{ + +struct BAR_DATA +{ + static constexpr auto str = "BAR_DATA=%s"; + static constexpr auto str_short = "BAR_DATA"; + using type = std::tuple,const char*>; + explicit constexpr BAR_DATA(const char* a) : _entry(entry(str, a)) {}; + type _entry; +}; + +} // namespace _Bar + +struct Bar : public sdbusplus::exception_t +{ + static constexpr auto errName = "example.xyz.openbmc_project.Example.Bar.Bar"; + static constexpr auto errDesc = "this is test error Bar"; + static constexpr auto L = level::INFO; + using BAR_DATA = _Bar::BAR_DATA; + using FOO_DATA = example::xyz::openbmc_project::Example::Foo::Foo::FOO_DATA; + using ERRNUM = example::xyz::openbmc_project::Example::Elog::TestErrorOne::ERRNUM; + using FILE_PATH = example::xyz::openbmc_project::Example::Elog::TestErrorOne::FILE_PATH; + using FILE_NAME = example::xyz::openbmc_project::Example::Elog::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; + + const char* name() const noexcept + { + return errName; + } + + const char* description() const noexcept + { + return errDesc; + } + + const char* what() const noexcept + { + return errName; + } +}; + +} // namespace Bar +} // namespace Example +} // namespace openbmc_project +} // namespace xyz +} // namespace example + + + + +} // namespace logging + +} // namespace phosphor diff --git a/error-HostEvent.hpp b/error-HostEvent.hpp new file mode 100644 index 0000000..f8abf21 --- /dev/null +++ b/error-HostEvent.hpp @@ -0,0 +1,37 @@ +#pragma once + +#include + +namespace sdbusplus +{ +namespace org +{ +namespace open_power +{ +namespace Host +{ +namespace Event +{ +namespace Error +{ + +struct Event final : public sdbusplus::exception_t +{ + static constexpr auto errName = "org.open_power.Host.Event.Error.Event"; + static constexpr auto errDesc = + "A host system event was received"; + static constexpr auto errWhat = + "org.open_power.Host.Event.Error.Event: A host system event was received"; + + const char* name() const noexcept override; + const char* description() const noexcept override; + const char* what() const noexcept override; +}; + +} // namespace Error +} // namespace Event +} // namespace Host +} // namespace open_power +} // namespace org +} // namespace sdbusplus + diff --git a/storageaddsel.cpp b/storageaddsel.cpp index 9cebf9e..bd48edc 100644 --- a/storageaddsel.cpp +++ b/storageaddsel.cpp @@ -9,14 +9,17 @@ #include #include #include -#include #include "host-ipmid/ipmid-api.h" +#include "elog-errors.hpp" +#include "error-HostEvent.hpp" #include "sensorhandler.h" #include "storagehandler.h" +#include "types.hpp" using namespace std; using namespace phosphor::logging; +extern const ipmi::sensor::InvObjectIDMap invSensors; ////////////////////////// struct esel_section_headers_t { @@ -130,25 +133,29 @@ const char *create_esel_severity(const uint8_t *buffer) { return sev_lookup(severity); } -int create_esel_association(const uint8_t *buffer, char **m) { - +int create_esel_association(const uint8_t *buffer, std::string& inventoryPath) +{ ipmi_add_sel_request_t *p; - dbus_interface_t dbusint; uint8_t sensor; p = ( ipmi_add_sel_request_t *) buffer; sensor = p->sensornumber; - find_openbmc_path(sensor, &dbusint); - - // Simply no associations if the sensor can not be found - if (strlen(dbusint.path) < 1) { - printf("Sensor 0x%x not found\n", sensor); - memset(dbusint.path,0,sizeof(dbusint.path)); - } + inventoryPath = {}; - *m = strdup(dbusint.path); + /* + * Search the sensor number to inventory path mapping to figure out the + * inventory associated with the ESEL. + */ + for (auto const &iter : invSensors) + { + if (iter.second.sensorID == sensor) + { + inventoryPath = iter.first; + break; + } + } return 0; } @@ -178,7 +185,12 @@ int create_esel_description(const uint8_t *buffer, const char *sev, char **messa } -int send_esel_to_dbus(const char *desc, const char *sev, const char *details, uint8_t *debug, size_t debuglen) { +int send_esel_to_dbus(const char *desc, + const char *sev, + const std::string& inventoryPath, + uint8_t *debug, + size_t debuglen) +{ // Allocate enough space to represent the data in hex separated by spaces, // to mimic how IPMI would display the data. @@ -190,20 +202,24 @@ int send_esel_to_dbus(const char *desc, const char *sev, const char *details, ui } selData[debuglen*3] = '\0'; - using error = org::open_power::Error::Host::Event; - report(error::ESEL(selData.get())); + using error = sdbusplus::org::open_power::Host::Event::Error::Event; + using metadata = org::open_power::Host::Event::Event; + + report(metadata::ESEL(selData.get()), + metadata::CALLOUT_INVENTORY_PATH(inventoryPath.c_str())); return 0; } void send_esel(uint16_t recordid) { - char *desc, *assoc; + char *desc; const char *sev; uint8_t *buffer = NULL; const char *path = "/tmp/esel"; ssize_t sz; int r; + std::string inventoryPath; sz = getfilestream(path, &buffer); if (sz == 0) { @@ -212,15 +228,14 @@ void send_esel(uint16_t recordid) { } sev = create_esel_severity(buffer); - create_esel_association(buffer, &assoc); + create_esel_association(buffer, inventoryPath); create_esel_description(buffer, sev, &desc); - r = send_esel_to_dbus(desc, sev, assoc, buffer, sz); + r = send_esel_to_dbus(desc, sev, inventoryPath, buffer, sz); if (r < 0) { fprintf(stderr, "Failed to send esel to dbus\n"); } - free(assoc); free(desc); delete[] buffer; -- cgit v1.2.1