summaryrefslogtreecommitdiffstats
path: root/include/ipmid/types.hpp
diff options
context:
space:
mode:
authorVernon Mauery <vernon.mauery@linux.intel.com>2019-03-12 16:49:26 -0700
committerVernon Mauery <vernon.mauery@linux.intel.com>2019-03-25 16:18:21 +0000
commit3325024067487320abddbf0ffb5a528b1743122a (patch)
tree715748d4da0eda64181464e215c749e6f15c90a0 /include/ipmid/types.hpp
parent6a98fe7fd233813f3875d4a8c565234418a41f33 (diff)
downloadphosphor-host-ipmid-3325024067487320abddbf0ffb5a528b1743122a.tar.gz
phosphor-host-ipmid-3325024067487320abddbf0ffb5a528b1743122a.zip
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 <vernon.mauery@linux.intel.com>
Diffstat (limited to 'include/ipmid/types.hpp')
-rw-r--r--include/ipmid/types.hpp247
1 files changed, 247 insertions, 0 deletions
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 <stdint.h>
+
+#include <map>
+#include <sdbusplus/server.hpp>
+#include <string>
+
+namespace ipmi
+{
+
+using DbusObjectPath = std::string;
+using DbusService = std::string;
+using DbusInterface = std::string;
+using DbusObjectInfo = std::pair<DbusObjectPath, DbusService>;
+using DbusProperty = std::string;
+
+using Value = sdbusplus::message::variant<bool, uint8_t, int16_t, uint16_t,
+ int32_t, uint32_t, int64_t, uint64_t,
+ double, std::string>;
+
+using PropertyMap = std::map<DbusProperty, Value>;
+
+using ObjectTree =
+ std::map<DbusObjectPath, std::map<DbusService, std::vector<DbusInterface>>>;
+
+using InterfaceList = std::vector<std::string>;
+
+using DbusInterfaceMap = std::map<DbusInterface, PropertyMap>;
+
+using ObjectValueTree =
+ std::map<sdbusplus::message::object_path, DbusInterfaceMap>;
+
+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<Offset, PreReqValues>;
+
+/**
+ * @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<uint8_t, sizeof(GetReadingResponse)>;
+
+using OffsetValueMap = std::map<Offset, Values>;
+
+using DbusPropertyValues = std::pair<PreReqOffsetValueMap, OffsetValueMap>;
+
+using DbusPropertyMap = std::map<DbusProperty, DbusPropertyValues>;
+
+using DbusInterfaceMap = std::map<DbusInterface, DbusPropertyMap>;
+
+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<Mutability>(static_cast<uint8_t>(lhs) |
+ static_cast<uint8_t>(rhs));
+}
+
+inline Mutability operator&(Mutability lhs, Mutability rhs)
+{
+ return static_cast<Mutability>(static_cast<uint8_t>(lhs) &
+ static_cast<uint8_t>(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<uint8_t(SetSensorReadingReq&, const Info&)> updateFunc;
+ std::function<GetSensorResponse(const Info&)> getFunc;
+ Mutability mutability;
+ std::function<SensorName(const Info&)> sensorNameFunc;
+ DbusInterfaceMap propertyInterfaces;
+};
+
+using Id = uint8_t;
+using IdInfoMap = std::map<Id, Info>;
+
+using PropertyMap = ipmi::PropertyMap;
+
+using InterfaceMap = std::map<DbusInterface, PropertyMap>;
+
+using Object = sdbusplus::message::object_path;
+using ObjectMap = std::map<Object, InterfaceMap>;
+
+using IpmiUpdateData = sdbusplus::message::message;
+
+struct SelData
+{
+ Id sensorID;
+ Type sensorType;
+ ReadingType eventReadingType;
+ Offset eventOffset;
+};
+
+using InventoryPath = std::string;
+
+using InvObjectIDMap = std::map<InventoryPath, SelData>;
+
+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<std::pair<uint8_t, uint8_t>, maxContainedEntities>;
+
+struct EntityInfo
+{
+ uint8_t containerEntityId;
+ uint8_t containerEntityInstance;
+ bool isList;
+ bool isLinked;
+ ContainedEntitiesArray containedEntities;
+};
+
+using EntityInfoMap = std::map<Id, EntityInfo>;
+
+} // namespace sensor
+
+namespace network
+{
+using ChannelEthMap = std::map<int, std::string>;
+
+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
OpenPOWER on IntegriCloud