1 #pragma once 2 3 #include <sdbusplus/message/types.hpp> 4 5 #include <bitset> 6 #include <cstdint> 7 #include <map> 8 #include <memory> 9 #include <set> 10 #include <string> 11 #include <unordered_map> 12 #include <variant> 13 #include <vector> 14 15 namespace pldm 16 { 17 18 using Availability = bool; 19 using eid = uint8_t; 20 using UUID = std::string; 21 using Request = std::vector<uint8_t>; 22 using Response = std::vector<uint8_t>; 23 using MCTPMsgTypes = std::vector<uint8_t>; 24 using Command = uint8_t; 25 26 /** @brief MCTP Endpoint Medium type in string 27 * Reserved for future purpose 28 */ 29 30 using MctpMedium = std::string; 31 /** @brief Type definition of MCTP Network Index. 32 * uint32_t is used as defined in MCTP Endpoint D-Bus Interface 33 */ 34 using NetworkId = uint32_t; 35 36 /** @brief Type definition of MCTP name in string 37 */ 38 using MctpInfoName = std::optional<std::string>; 39 40 /** @brief Type definition of MCTP interface information between two endpoints. 41 * eid : Endpoint EID in byte. Defined to match with MCTP D-Bus 42 * interface 43 * UUID : Endpoint UUID which is used to different the endpoints 44 * MctpMedium: Endpoint MCTP Medium info (Resersed) 45 * NetworkId: MCTP network index 46 * name: Alias name of the endpoint, e.g. BMC, NIC, etc. 47 */ 48 using MctpInfo = std::tuple<eid, UUID, MctpMedium, NetworkId, MctpInfoName>; 49 50 /** @brief Type definition of MCTP endpoint D-Bus properties in 51 * xyz.openbmc_project.MCTP.Endpoint D-Bus interface. 52 * 53 * NetworkId: MCTP network index 54 * eid : Endpoint EID in byte. Defined to match with MCTP D-Bus 55 * interface 56 * MCTPMsgTypes: MCTP message types 57 */ 58 using MctpEndpointProps = std::tuple<NetworkId, eid, MCTPMsgTypes>; 59 60 /** @brief Type defined for list of MCTP interface information 61 */ 62 using MctpInfos = std::vector<MctpInfo>; 63 64 /** 65 * In `Table 2 - Special endpoint IDs` of DSP0236. 66 * EID from 1 to 7 is reserved EID. So the start valid EID is 8 67 */ 68 #define MCTP_START_VALID_EID 8 69 constexpr uint8_t BmcMctpEid = 8; 70 71 #define PLDM_PLATFORM_GETPDR_MAX_RECORD_BYTES 1024 72 /* default the max event message buffer size BMC supported to 4K bytes */ 73 #define PLDM_PLATFORM_EVENT_MSG_MAX_BUFFER_SIZE 4096 74 /* DSP0248 section16.9 EventMessageBufferSize Command, the default message 75 * buffer size is 256 bytes 76 */ 77 #define PLDM_PLATFORM_DEFAULT_MESSAGE_BUFFER_SIZE 256 78 79 namespace dbus 80 { 81 82 using ObjectPath = std::string; 83 using Service = std::string; 84 using Interface = std::string; 85 using Interfaces = std::vector<std::string>; 86 using Property = std::string; 87 using PropertyType = std::string; 88 using Value = std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, 89 int64_t, uint64_t, double, std::string, 90 std::vector<uint8_t>, std::vector<uint64_t>>; 91 92 using PropertyMap = std::map<Property, Value>; 93 using InterfaceMap = std::map<Interface, PropertyMap>; 94 using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>; 95 96 } // namespace dbus 97 98 /** @brief Binding of MCTP endpoint EID to Entity Manager's D-Bus object path 99 */ 100 using Configurations = std::map<dbus::ObjectPath, MctpInfo>; 101 102 namespace fw_update 103 { 104 using InventoryPath = std::string; 105 using SoftwareName = std::string; 106 107 // Descriptor definition 108 using DescriptorType = uint16_t; 109 using DescriptorData = std::vector<uint8_t>; 110 using VendorDefinedDescriptorTitle = std::string; 111 using VendorDefinedDescriptorData = std::vector<uint8_t>; 112 using VendorDefinedDescriptorInfo = 113 std::tuple<VendorDefinedDescriptorTitle, VendorDefinedDescriptorData>; 114 using Descriptors = 115 std::multimap<DescriptorType, 116 std::variant<DescriptorData, VendorDefinedDescriptorInfo>>; 117 using DownstreamDeviceIndex = uint16_t; 118 using DownstreamDeviceInfo = 119 std::unordered_map<DownstreamDeviceIndex, Descriptors>; 120 121 using DescriptorMap = std::unordered_map<eid, Descriptors>; 122 using DownstreamDescriptorMap = std::unordered_map<eid, DownstreamDeviceInfo>; 123 124 // Component information 125 using CompClassification = uint16_t; 126 using CompIdentifier = uint16_t; 127 using SoftwareIdentifier = std::pair<eid, CompIdentifier>; 128 using CompKey = std::pair<CompClassification, CompIdentifier>; 129 using CompClassificationIndex = uint8_t; 130 using ComponentInfo = std::map<CompKey, CompClassificationIndex>; 131 using ComponentInfoMap = std::unordered_map<eid, ComponentInfo>; 132 133 // PackageHeaderInformation 134 using PackageHeaderSize = size_t; 135 using PackageVersion = std::string; 136 using ComponentBitmapBitLength = uint16_t; 137 using PackageHeaderChecksum = uint32_t; 138 139 // FirmwareDeviceIDRecords 140 using DeviceIDRecordCount = uint8_t; 141 using DeviceUpdateOptionFlags = std::bitset<32>; 142 using ApplicableComponents = std::vector<size_t>; 143 using ComponentImageSetVersion = std::string; 144 using FirmwareDevicePackageData = std::vector<uint8_t>; 145 using FirmwareDeviceIDRecord = 146 std::tuple<DeviceUpdateOptionFlags, ApplicableComponents, 147 ComponentImageSetVersion, Descriptors, 148 FirmwareDevicePackageData>; 149 using FirmwareDeviceIDRecords = std::vector<FirmwareDeviceIDRecord>; 150 151 // ComponentImageInformation 152 using ComponentImageCount = uint16_t; 153 using CompComparisonStamp = uint32_t; 154 using CompOptions = std::bitset<16>; 155 using ReqCompActivationMethod = std::bitset<16>; 156 using CompLocationOffset = uint32_t; 157 using CompSize = uint32_t; 158 using CompVersion = std::string; 159 using ComponentImageInfo = 160 std::tuple<CompClassification, CompIdentifier, CompComparisonStamp, 161 CompOptions, ReqCompActivationMethod, CompLocationOffset, 162 CompSize, CompVersion>; 163 using ComponentImageInfos = std::vector<ComponentImageInfo>; 164 165 enum class ComponentImageInfoPos : size_t 166 { 167 CompClassificationPos = 0, 168 CompIdentifierPos = 1, 169 CompComparisonStampPos = 2, 170 CompOptionsPos = 3, 171 ReqCompActivationMethodPos = 4, 172 CompLocationOffsetPos = 5, 173 CompSizePos = 6, 174 CompVersionPos = 7, 175 }; 176 177 } // namespace fw_update 178 179 namespace pdr 180 { 181 182 using EID = uint8_t; 183 using TerminusHandle = uint16_t; 184 using TerminusID = uint8_t; 185 using SensorID = uint16_t; 186 using EntityType = uint16_t; 187 using EntityInstance = uint16_t; 188 using ContainerID = uint16_t; 189 using StateSetId = uint16_t; 190 using CompositeCount = uint8_t; 191 using SensorOffset = uint8_t; 192 using EventState = uint8_t; 193 using TerminusValidity = uint8_t; 194 using EffecterID = uint16_t; 195 using EntityName = std::string; 196 using SensorCount = uint8_t; 197 using NameLanguageTag = std::string; 198 using SensorName = std::string; 199 using SensorAuxiliaryNames = std::tuple< 200 SensorID, SensorCount, 201 std::vector<std::vector<std::pair<NameLanguageTag, SensorName>>>>; 202 using AuxiliaryNames = std::vector<std::pair<NameLanguageTag, std::string>>; 203 204 /** @struct EntityKey 205 * 206 * EntityKey uniquely identifies the PLDM entity and a combination of Entity 207 * Type, Entity Instance Number, Entity Container ID 208 * 209 */ 210 struct EntityKey 211 { 212 EntityType type; //!< Entity type 213 EntityInstance instanceIdx; //!< Entity instance number 214 ContainerID containerId; //!< Entity container ID 215 operator ==pldm::pdr::EntityKey216 bool operator==(const EntityKey& e) const 217 { 218 return ((type == e.type) && (instanceIdx == e.instanceIdx) && 219 (containerId == e.containerId)); 220 } 221 }; 222 223 using EntityKey = struct EntityKey; 224 using EntityAuxiliaryNames = std::tuple<EntityKey, AuxiliaryNames>; 225 226 //!< Subset of the State Set that is supported by a effecter/sensor 227 using PossibleStates = std::set<uint8_t>; 228 //!< Subset of the State Set that is supported by each effecter/sensor in a 229 //!< composite efffecter/sensor 230 using CompositeSensorStates = std::vector<PossibleStates>; 231 using EntityInfo = std::tuple<ContainerID, EntityType, EntityInstance>; 232 using SensorInfo = 233 std::tuple<EntityInfo, CompositeSensorStates, std::vector<StateSetId>>; 234 235 } // namespace pdr 236 237 } // namespace pldm 238