xref: /openbmc/pldm/common/types.hpp (revision 9027497f94340a20234313f57827a0e7fc553542)
1d130e1a3SDeepak Kodihalli #pragma once
2d130e1a3SDeepak Kodihalli 
3fb3bc06fSTom Joseph #include <sdbusplus/message/types.hpp>
4fb3bc06fSTom Joseph 
575356c1aSTom Joseph #include <bitset>
6b3b84b49SPavithra Barithaya #include <cstdint>
775356c1aSTom Joseph #include <map>
8d130e1a3SDeepak Kodihalli #include <set>
9d130e1a3SDeepak Kodihalli #include <string>
1075356c1aSTom Joseph #include <unordered_map>
11d130e1a3SDeepak Kodihalli #include <variant>
12d130e1a3SDeepak Kodihalli #include <vector>
13d130e1a3SDeepak Kodihalli 
14d130e1a3SDeepak Kodihalli namespace pldm
15d130e1a3SDeepak Kodihalli {
16d130e1a3SDeepak Kodihalli 
17eac61a4bSGilbert Chen using Availability = bool;
1875356c1aSTom Joseph using eid = uint8_t;
1944524a5fSGilbert Chen using UUID = std::string;
2074f27c73STom Joseph using Request = std::vector<uint8_t>;
2174f27c73STom Joseph using Response = std::vector<uint8_t>;
22*9027497fSThu Nguyen using MCTPMsgTypes = std::vector<uint8_t>;
23fb3bc06fSTom Joseph using Command = uint8_t;
2474f27c73STom Joseph 
256c7fed4cSGilbert Chen /** @brief MCTP Endpoint Medium type in string
26079e7769SManojkiran Eda  *         Reserved for future purpose
276c7fed4cSGilbert Chen  */
286c7fed4cSGilbert Chen 
2944524a5fSGilbert Chen using MctpMedium = std::string;
306c7fed4cSGilbert Chen /** @brief Type definition of MCTP Network Index.
316c7fed4cSGilbert Chen  *         uint32_t is used as defined in MCTP Endpoint D-Bus Interface
326c7fed4cSGilbert Chen  */
3344524a5fSGilbert Chen using NetworkId = uint32_t;
346c7fed4cSGilbert Chen 
356c7fed4cSGilbert Chen /** @brief Type definition of MCTP interface information between two endpoints.
36079e7769SManojkiran Eda  *         eid : Endpoint EID in byte. Defined to match with MCTP D-Bus
37079e7769SManojkiran Eda  *               interface
386c7fed4cSGilbert Chen  *         UUID : Endpoint UUID which is used to different the endpoints
396c7fed4cSGilbert Chen  *         MctpMedium: Endpoint MCTP Medium info (Resersed)
406c7fed4cSGilbert Chen  *         NetworkId: MCTP network index
416c7fed4cSGilbert Chen  */
4244524a5fSGilbert Chen using MctpInfo = std::tuple<eid, UUID, MctpMedium, NetworkId>;
436c7fed4cSGilbert Chen 
44*9027497fSThu Nguyen /** @brief Type definition of MCTP endpoint D-Bus properties in
45*9027497fSThu Nguyen  *         xyz.openbmc_project.MCTP.Endpoint D-Bus interface.
46*9027497fSThu Nguyen  *
47*9027497fSThu Nguyen  *         NetworkId: MCTP network index
48*9027497fSThu Nguyen  *         eid : Endpoint EID in byte. Defined to match with MCTP D-Bus
49*9027497fSThu Nguyen  *               interface
50*9027497fSThu Nguyen  *         MCTPMsgTypes: MCTP message types
51*9027497fSThu Nguyen  */
52*9027497fSThu Nguyen using MctpEndpointProps = std::tuple<NetworkId, eid, MCTPMsgTypes>;
53*9027497fSThu Nguyen 
54079e7769SManojkiran Eda /** @brief Type defined for list of MCTP interface information
556c7fed4cSGilbert Chen  */
5644524a5fSGilbert Chen using MctpInfos = std::vector<MctpInfo>;
5744524a5fSGilbert Chen 
586c7fed4cSGilbert Chen /**
596c7fed4cSGilbert Chen  * In `Table 2 - Special endpoint IDs` of DSP0236.
606c7fed4cSGilbert Chen  * EID from 1 to 7 is reserved EID. So the start valid EID is 8
616c7fed4cSGilbert Chen  */
626c7fed4cSGilbert Chen #define MCTP_START_VALID_EID 8
6351d66b59SThu Nguyen constexpr uint8_t BmcMctpEid = 8;
646c7fed4cSGilbert Chen 
65de2a132aSGilbert Chen #define PLDM_PLATFORM_GETPDR_MAX_RECORD_BYTES 1024
6677e6fe7aSGilbert Chen /* default the max event message buffer size BMC supported to 4K bytes */
6777e6fe7aSGilbert Chen #define PLDM_PLATFORM_EVENT_MSG_MAX_BUFFER_SIZE 4096
6877e6fe7aSGilbert Chen /* DSP0248 section16.9 EventMessageBufferSize Command, the default message
6977e6fe7aSGilbert Chen  * buffer size is 256 bytes
7077e6fe7aSGilbert Chen  */
7177e6fe7aSGilbert Chen #define PLDM_PLATFORM_DEFAULT_MESSAGE_BUFFER_SIZE 256
72de2a132aSGilbert Chen 
73d130e1a3SDeepak Kodihalli namespace dbus
74d130e1a3SDeepak Kodihalli {
75d130e1a3SDeepak Kodihalli 
76d130e1a3SDeepak Kodihalli using ObjectPath = std::string;
77d130e1a3SDeepak Kodihalli using Service = std::string;
78d130e1a3SDeepak Kodihalli using Interface = std::string;
79d130e1a3SDeepak Kodihalli using Interfaces = std::vector<std::string>;
80d130e1a3SDeepak Kodihalli using Property = std::string;
81d130e1a3SDeepak Kodihalli using PropertyType = std::string;
82fb3bc06fSTom Joseph using Value =
83fb3bc06fSTom Joseph     std::variant<bool, uint8_t, int16_t, uint16_t, int32_t, uint32_t, int64_t,
84fb3bc06fSTom Joseph                  uint64_t, double, std::string, std::vector<uint8_t>>;
85fb3bc06fSTom Joseph 
86fb3bc06fSTom Joseph using PropertyMap = std::map<Property, Value>;
87fb3bc06fSTom Joseph using InterfaceMap = std::map<Interface, PropertyMap>;
88fb3bc06fSTom Joseph using ObjectValueTree = std::map<sdbusplus::message::object_path, InterfaceMap>;
89d130e1a3SDeepak Kodihalli 
90d130e1a3SDeepak Kodihalli } // namespace dbus
91d130e1a3SDeepak Kodihalli 
9275356c1aSTom Joseph namespace fw_update
9375356c1aSTom Joseph {
9475356c1aSTom Joseph 
9575356c1aSTom Joseph // Descriptor definition
9675356c1aSTom Joseph using DescriptorType = uint16_t;
9775356c1aSTom Joseph using DescriptorData = std::vector<uint8_t>;
9875356c1aSTom Joseph using VendorDefinedDescriptorTitle = std::string;
9975356c1aSTom Joseph using VendorDefinedDescriptorData = std::vector<uint8_t>;
10075356c1aSTom Joseph using VendorDefinedDescriptorInfo =
10175356c1aSTom Joseph     std::tuple<VendorDefinedDescriptorTitle, VendorDefinedDescriptorData>;
10275356c1aSTom Joseph using Descriptors =
10375356c1aSTom Joseph     std::map<DescriptorType,
10475356c1aSTom Joseph              std::variant<DescriptorData, VendorDefinedDescriptorInfo>>;
10575356c1aSTom Joseph 
10675356c1aSTom Joseph using DescriptorMap = std::unordered_map<eid, Descriptors>;
10775356c1aSTom Joseph 
10875356c1aSTom Joseph // Component information
10975356c1aSTom Joseph using CompClassification = uint16_t;
11075356c1aSTom Joseph using CompIdentifier = uint16_t;
11175356c1aSTom Joseph using CompKey = std::pair<CompClassification, CompIdentifier>;
11275356c1aSTom Joseph using CompClassificationIndex = uint8_t;
11375356c1aSTom Joseph using ComponentInfo = std::map<CompKey, CompClassificationIndex>;
11475356c1aSTom Joseph using ComponentInfoMap = std::unordered_map<eid, ComponentInfo>;
11575356c1aSTom Joseph 
1161630f399STom Joseph // PackageHeaderInformation
1171630f399STom Joseph using PackageHeaderSize = size_t;
1181630f399STom Joseph using PackageVersion = std::string;
1191630f399STom Joseph using ComponentBitmapBitLength = uint16_t;
1201630f399STom Joseph using PackageHeaderChecksum = uint32_t;
1211630f399STom Joseph 
1221630f399STom Joseph // FirmwareDeviceIDRecords
1231630f399STom Joseph using DeviceIDRecordCount = uint8_t;
1241630f399STom Joseph using DeviceUpdateOptionFlags = std::bitset<32>;
1251630f399STom Joseph using ApplicableComponents = std::vector<size_t>;
1261630f399STom Joseph using ComponentImageSetVersion = std::string;
1271630f399STom Joseph using FirmwareDevicePackageData = std::vector<uint8_t>;
1281630f399STom Joseph using FirmwareDeviceIDRecord =
1291630f399STom Joseph     std::tuple<DeviceUpdateOptionFlags, ApplicableComponents,
1301630f399STom Joseph                ComponentImageSetVersion, Descriptors,
1311630f399STom Joseph                FirmwareDevicePackageData>;
1321630f399STom Joseph using FirmwareDeviceIDRecords = std::vector<FirmwareDeviceIDRecord>;
1331630f399STom Joseph 
1341630f399STom Joseph // ComponentImageInformation
1351630f399STom Joseph using ComponentImageCount = uint16_t;
1361630f399STom Joseph using CompComparisonStamp = uint32_t;
1371630f399STom Joseph using CompOptions = std::bitset<16>;
1381630f399STom Joseph using ReqCompActivationMethod = std::bitset<16>;
1391630f399STom Joseph using CompLocationOffset = uint32_t;
1401630f399STom Joseph using CompSize = uint32_t;
1411630f399STom Joseph using CompVersion = std::string;
1421630f399STom Joseph using ComponentImageInfo =
1431630f399STom Joseph     std::tuple<CompClassification, CompIdentifier, CompComparisonStamp,
1441630f399STom Joseph                CompOptions, ReqCompActivationMethod, CompLocationOffset,
1451630f399STom Joseph                CompSize, CompVersion>;
1461630f399STom Joseph using ComponentImageInfos = std::vector<ComponentImageInfo>;
1471630f399STom Joseph 
1481630f399STom Joseph enum class ComponentImageInfoPos : size_t
1491630f399STom Joseph {
1501630f399STom Joseph     CompClassificationPos = 0,
1511630f399STom Joseph     CompIdentifierPos = 1,
1521630f399STom Joseph     CompComparisonStampPos = 2,
1531630f399STom Joseph     CompOptionsPos = 3,
1541630f399STom Joseph     ReqCompActivationMethodPos = 4,
1551630f399STom Joseph     CompLocationOffsetPos = 5,
1561630f399STom Joseph     CompSizePos = 6,
1571630f399STom Joseph     CompVersionPos = 7,
1581630f399STom Joseph };
1591630f399STom Joseph 
16075356c1aSTom Joseph } // namespace fw_update
16175356c1aSTom Joseph 
162d130e1a3SDeepak Kodihalli namespace pdr
163d130e1a3SDeepak Kodihalli {
164d130e1a3SDeepak Kodihalli 
165868c879aSSampa Misra using EID = uint8_t;
166d130e1a3SDeepak Kodihalli using TerminusHandle = uint16_t;
167868c879aSSampa Misra using TerminusID = uint8_t;
168d130e1a3SDeepak Kodihalli using SensorID = uint16_t;
169d130e1a3SDeepak Kodihalli using EntityType = uint16_t;
170d130e1a3SDeepak Kodihalli using EntityInstance = uint16_t;
171d130e1a3SDeepak Kodihalli using ContainerID = uint16_t;
172aea5dde1SSampa Misra using StateSetId = uint16_t;
173d130e1a3SDeepak Kodihalli using CompositeCount = uint8_t;
174d130e1a3SDeepak Kodihalli using SensorOffset = uint8_t;
175d130e1a3SDeepak Kodihalli using EventState = uint8_t;
17660e1fe91SManojkiran Eda using TerminusValidity = uint8_t;
177d130e1a3SDeepak Kodihalli 
178d130e1a3SDeepak Kodihalli //!< Subset of the State Set that is supported by a effecter/sensor
179d130e1a3SDeepak Kodihalli using PossibleStates = std::set<uint8_t>;
180d130e1a3SDeepak Kodihalli //!< Subset of the State Set that is supported by each effecter/sensor in a
181d130e1a3SDeepak Kodihalli //!< composite efffecter/sensor
182d130e1a3SDeepak Kodihalli using CompositeSensorStates = std::vector<PossibleStates>;
183d130e1a3SDeepak Kodihalli using EntityInfo = std::tuple<ContainerID, EntityType, EntityInstance>;
184e3607a3cSSagar Srinivas using SensorInfo =
185e3607a3cSSagar Srinivas     std::tuple<EntityInfo, CompositeSensorStates, std::vector<StateSetId>>;
186d130e1a3SDeepak Kodihalli 
187d130e1a3SDeepak Kodihalli } // namespace pdr
188d130e1a3SDeepak Kodihalli 
189d130e1a3SDeepak Kodihalli } // namespace pldm
190