From 3325024067487320abddbf0ffb5a528b1743122a Mon Sep 17 00:00:00 2001 From: Vernon Mauery Date: Tue, 12 Mar 2019 16:49:26 -0700 Subject: move types.hpp to ipmid/types.hpp for export types.hpp is required by utility.hpp, which is exported, so it needs to be exported as well. This moves it to the include/libipmid directory, changes the Makefile to export it, and changes all the files that include it so it can be found in the right place. Change-Id: I30ec365446e4de466c266ec4faa327478460ec05 Signed-off-by: Vernon Mauery --- include/ipmid/types.hpp | 247 ++++++++++++++++++++++++++++++++++++++++++++++++ include/ipmid/utils.hpp | 2 +- 2 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 include/ipmid/types.hpp (limited to 'include/ipmid') diff --git a/include/ipmid/types.hpp b/include/ipmid/types.hpp new file mode 100644 index 0000000..57c5873 --- /dev/null +++ b/include/ipmid/types.hpp @@ -0,0 +1,247 @@ +#pragma once + +#include + +#include +#include +#include + +namespace ipmi +{ + +using DbusObjectPath = std::string; +using DbusService = std::string; +using DbusInterface = std::string; +using DbusObjectInfo = std::pair; +using DbusProperty = std::string; + +using Value = sdbusplus::message::variant; + +using PropertyMap = std::map; + +using ObjectTree = + std::map>>; + +using InterfaceList = std::vector; + +using DbusInterfaceMap = std::map; + +using ObjectValueTree = + std::map; + +namespace sensor +{ + +using Offset = uint8_t; + +/** + * @enum SkipAssertion + * Matching value for skipping the update + */ +enum class SkipAssertion +{ + NONE, // No skip defined + ASSERT, // Skip on Assert + DEASSERT, // Skip on Deassert +}; + +struct Values +{ + SkipAssertion skip; + Value assert; + Value deassert; +}; + +/** + * @enum PreReqValues + * Pre-req conditions for a property. + */ +struct PreReqValues +{ + Value assert; // Value in case of assert. + Value deassert; // Value in case of deassert. +}; + +using PreReqOffsetValueMap = std::map; + +/** + * @struct SetSensorReadingReq + * + * IPMI Request data for Set Sensor Reading and Event Status Command + */ +struct SetSensorReadingReq +{ + uint8_t number; + uint8_t operation; + uint8_t reading; + uint8_t assertOffset0_7; + uint8_t assertOffset8_14; + uint8_t deassertOffset0_7; + uint8_t deassertOffset8_14; + uint8_t eventData1; + uint8_t eventData2; + uint8_t eventData3; +} __attribute__((packed)); + +/** + * @struct GetReadingResponse + * + * IPMI response data for Get Sensor Reading command. + */ +struct GetReadingResponse +{ + uint8_t reading; //!< Sensor reading. + uint8_t operation; //!< Sensor scanning status / reading state. + uint8_t assertOffset0_7; //!< Discrete assertion states(0-7). + uint8_t assertOffset8_14; //!< Discrete assertion states(8-14). +} __attribute__((packed)); + +constexpr auto inventoryRoot = "/xyz/openbmc_project/inventory"; + +using GetSensorResponse = std::array; + +using OffsetValueMap = std::map; + +using DbusPropertyValues = std::pair; + +using DbusPropertyMap = std::map; + +using DbusInterfaceMap = std::map; + +using InstancePath = std::string; +using Type = uint8_t; +using ReadingType = uint8_t; +using Multiplier = uint16_t; +using OffsetB = int16_t; +using Exponent = int8_t; +using ScaledOffset = double; +using Scale = int16_t; +using Unit = std::string; +using EntityType = uint8_t; +using EntityInst = uint8_t; +using SensorName = std::string; + +enum class Mutability +{ + Read = 1 << 0, + Write = 1 << 1, +}; + +inline Mutability operator|(Mutability lhs, Mutability rhs) +{ + return static_cast(static_cast(lhs) | + static_cast(rhs)); +} + +inline Mutability operator&(Mutability lhs, Mutability rhs) +{ + return static_cast(static_cast(lhs) & + static_cast(rhs)); +} + +struct Info +{ + EntityType entityType; + EntityInst instance; + Type sensorType; + InstancePath sensorPath; + DbusInterface sensorInterface; + ReadingType sensorReadingType; + Multiplier coefficientM; + OffsetB coefficientB; + Exponent exponentB; + ScaledOffset scaledOffset; + Exponent exponentR; + bool hasScale; + Scale scale; + Unit unit; + std::function updateFunc; + std::function getFunc; + Mutability mutability; + std::function sensorNameFunc; + DbusInterfaceMap propertyInterfaces; +}; + +using Id = uint8_t; +using IdInfoMap = std::map; + +using PropertyMap = ipmi::PropertyMap; + +using InterfaceMap = std::map; + +using Object = sdbusplus::message::object_path; +using ObjectMap = std::map; + +using IpmiUpdateData = sdbusplus::message::message; + +struct SelData +{ + Id sensorID; + Type sensorType; + ReadingType eventReadingType; + Offset eventOffset; +}; + +using InventoryPath = std::string; + +using InvObjectIDMap = std::map; + +enum class ThresholdMask +{ + NON_CRITICAL_LOW_MASK = 0x01, + CRITICAL_LOW_MASK = 0x02, + NON_CRITICAL_HIGH_MASK = 0x08, + CRITICAL_HIGH_MASK = 0x10, +}; + +static constexpr uint8_t maxContainedEntities = 4; +using ContainedEntitiesArray = + std::array, maxContainedEntities>; + +struct EntityInfo +{ + uint8_t containerEntityId; + uint8_t containerEntityInstance; + bool isList; + bool isLinked; + ContainedEntitiesArray containedEntities; +}; + +using EntityInfoMap = std::map; + +} // namespace sensor + +namespace network +{ +using ChannelEthMap = std::map; + +constexpr auto MAC_ADDRESS_FORMAT = "%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx"; +constexpr auto IP_ADDRESS_FORMAT = "%u.%u.%u.%u"; +constexpr auto PREFIX_FORMAT = "%hhd"; +constexpr auto ADDR_TYPE_FORMAT = "%hhx"; + +constexpr auto IPV4_ADDRESS_SIZE_BYTE = 4; +constexpr auto IPV6_ADDRESS_SIZE_BYTE = 16; + +constexpr auto DEFAULT_MAC_ADDRESS = "00:00:00:00:00:00"; +constexpr auto DEFAULT_ADDRESS = "0.0.0.0"; + +constexpr auto MAC_ADDRESS_SIZE_BYTE = 6; +constexpr auto VLAN_SIZE_BYTE = 2; +constexpr auto IPSRC_SIZE_BYTE = 1; +constexpr auto BITS_32 = 32; +constexpr auto MASK_32_BIT = 0xFFFFFFFF; +constexpr auto VLAN_ID_MASK = 0x00000FFF; +constexpr auto VLAN_ENABLE_MASK = 0x8000; + +enum class IPOrigin : uint8_t +{ + UNSPECIFIED = 0, + STATIC = 1, + DHCP = 2, +}; + +} // namespace network +} // namespace ipmi diff --git a/include/ipmid/utils.hpp b/include/ipmid/utils.hpp index 09bb1b4..9ef1488 100644 --- a/include/ipmid/utils.hpp +++ b/include/ipmid/utils.hpp @@ -1,7 +1,7 @@ #pragma once -#include "types.hpp" #include +#include #include #include -- cgit v1.2.1