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 --- app/channel.cpp | 2 +- apphandler.cpp | 2 +- chassishandler.cpp | 2 +- include/Makefile.am | 1 + include/ipmid/types.hpp | 247 +++++++++++++++++++++++++++++++++++++++ include/ipmid/utils.hpp | 2 +- ipmid-new.cpp | 2 +- read_fru_data.cpp | 2 +- scripts/inventorysensor.mako.cpp | 2 +- scripts/writechannel.mako.cpp | 2 +- scripts/writeentity.mako.cpp | 2 +- scripts/writesensor.mako.cpp | 2 +- selutility.cpp | 3 +- selutility.hpp | 3 +- sensordatahandler.cpp | 2 +- sensordatahandler.hpp | 2 +- sensorhandler.cpp | 2 +- sensorhandler.hpp | 4 +- storageaddsel.cpp | 2 +- transporthandler.hpp | 3 +- types.hpp | 247 --------------------------------------- 21 files changed, 267 insertions(+), 269 deletions(-) create mode 100644 include/ipmid/types.hpp delete mode 100644 types.hpp diff --git a/app/channel.cpp b/app/channel.cpp index e4532c5..085464b 100644 --- a/app/channel.cpp +++ b/app/channel.cpp @@ -1,13 +1,13 @@ #include "channel.hpp" #include "transporthandler.hpp" -#include "types.hpp" #include "user_channel/channel_layer.hpp" #include #include #include +#include #include #include #include diff --git a/apphandler.cpp b/apphandler.cpp index 0993139..bb7e192 100644 --- a/apphandler.cpp +++ b/apphandler.cpp @@ -5,7 +5,6 @@ #include "ipmid.hpp" #include "sys_info_param.hpp" #include "transporthandler.hpp" -#include "types.hpp" #include #include @@ -18,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/chassishandler.cpp b/chassishandler.cpp index 2a9057d..072a021 100644 --- a/chassishandler.cpp +++ b/chassishandler.cpp @@ -4,7 +4,6 @@ #include "ipmid.hpp" #include "settings.hpp" -#include "types.hpp" #include #include @@ -18,6 +17,7 @@ #include #include #include +#include #include #include #include diff --git a/include/Makefile.am b/include/Makefile.am index f51e7d7..a3051dd 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -11,6 +11,7 @@ nobase_include_HEADERS = \ ipmid/iana.hpp \ ipmid/oemopenbmc.hpp \ ipmid/oemrouter.hpp \ + ipmid/types.hpp \ ipmid/utility.hpp \ ipmid/utils.hpp \ ipmid-host/cmd.hpp \ 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 diff --git a/ipmid-new.cpp b/ipmid-new.cpp index a92d4c4..26c9de4 100644 --- a/ipmid-new.cpp +++ b/ipmid-new.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include #include -#include #include #include #include diff --git a/read_fru_data.cpp b/read_fru_data.cpp index 05b1b6e..17bcfe4 100644 --- a/read_fru_data.cpp +++ b/read_fru_data.cpp @@ -1,11 +1,11 @@ #include "read_fru_data.hpp" #include "fruread.hpp" -#include "types.hpp" #include #include +#include #include #include #include diff --git a/scripts/inventorysensor.mako.cpp b/scripts/inventorysensor.mako.cpp index 000f758..f1ea8cd 100644 --- a/scripts/inventorysensor.mako.cpp +++ b/scripts/inventorysensor.mako.cpp @@ -3,7 +3,7 @@ // !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!! -#include "types.hpp" +#include using namespace ipmi::sensor; extern const InvObjectIDMap invSensors = { diff --git a/scripts/writechannel.mako.cpp b/scripts/writechannel.mako.cpp index 922611a..83ee5cd 100644 --- a/scripts/writechannel.mako.cpp +++ b/scripts/writechannel.mako.cpp @@ -2,7 +2,7 @@ ## into the rendered file; feel free to edit this file. // !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!! -#include "types.hpp" +#include namespace ipmi { diff --git a/scripts/writeentity.mako.cpp b/scripts/writeentity.mako.cpp index 9de11a0..4cfc82b 100644 --- a/scripts/writeentity.mako.cpp +++ b/scripts/writeentity.mako.cpp @@ -2,7 +2,7 @@ ## into the rendered file; feel free to edit this file. // !!! WARNING: This is a GENERATED Code..Please do NOT Edit !!! -#include "types.hpp" +#include using namespace ipmi::sensor; extern const EntityInfoMap entities = { diff --git a/scripts/writesensor.mako.cpp b/scripts/writesensor.mako.cpp index bbc80e3..559f0f9 100644 --- a/scripts/writesensor.mako.cpp +++ b/scripts/writesensor.mako.cpp @@ -24,9 +24,9 @@ interfaceDict = {} %>\ % endfor -#include "types.hpp" #include "sensordatahandler.hpp" +#include using namespace ipmi::sensor; extern const IdInfoMap sensors = { diff --git a/selutility.cpp b/selutility.cpp index b85bc40..9edc1b8 100644 --- a/selutility.cpp +++ b/selutility.cpp @@ -2,11 +2,10 @@ #include "selutility.hpp" -#include "types.hpp" - #include #include +#include #include #include #include diff --git a/selutility.hpp b/selutility.hpp index 4e2855a..806f937 100644 --- a/selutility.hpp +++ b/selutility.hpp @@ -1,9 +1,8 @@ #pragma once -#include "types.hpp" - #include #include +#include #include namespace ipmi diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp index 87c82b9..7903138 100644 --- a/sensordatahandler.cpp +++ b/sensordatahandler.cpp @@ -1,9 +1,9 @@ #include "sensordatahandler.hpp" #include "sensorhandler.hpp" -#include "types.hpp" #include +#include #include #include #include diff --git a/sensordatahandler.hpp b/sensordatahandler.hpp index 82ed002..8403a8d 100644 --- a/sensordatahandler.hpp +++ b/sensordatahandler.hpp @@ -1,11 +1,11 @@ #pragma once #include "sensorhandler.hpp" -#include "types.hpp" #include #include +#include #include #include diff --git a/sensorhandler.cpp b/sensorhandler.cpp index cb73e71..4da40af 100644 --- a/sensorhandler.cpp +++ b/sensorhandler.cpp @@ -2,7 +2,6 @@ #include "fruread.hpp" #include "ipmid.hpp" -#include "types.hpp" #include #include @@ -11,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/sensorhandler.hpp b/sensorhandler.hpp index 8fcf2b1..21d2317 100644 --- a/sensorhandler.hpp +++ b/sensorhandler.hpp @@ -1,10 +1,10 @@ #pragma once -#include "types.hpp" - #include #include +#include + // IPMI commands for net functions. enum ipmi_netfn_sen_cmds { diff --git a/storageaddsel.cpp b/storageaddsel.cpp index f0f0fc7..5adb673 100644 --- a/storageaddsel.cpp +++ b/storageaddsel.cpp @@ -2,7 +2,6 @@ #include "error-HostEvent.hpp" #include "sensorhandler.hpp" #include "storagehandler.hpp" -#include "types.hpp" #include #include @@ -13,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/transporthandler.hpp b/transporthandler.hpp index f1ed8bc..04d4673 100644 --- a/transporthandler.hpp +++ b/transporthandler.hpp @@ -1,7 +1,6 @@ #pragma once -#include "types.hpp" - +#include #include // IPMI commands for Transport net functions. enum ipmi_netfn_storage_cmds diff --git a/types.hpp b/types.hpp deleted file mode 100644 index 57c5873..0000000 --- a/types.hpp +++ /dev/null @@ -1,247 +0,0 @@ -#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 -- cgit v1.2.1