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