platform-mc: Added Terminus/TerminusManager class
Added requester::sendRecvPldmMsg awaiter type to be able to send and
receive PLDM message by coroutine.
Added TerminusManager to discover terminus from EID list updated by
MCTPDiscovery class. The TerminusManager will initialize TID.
Signed-off-by: Gilbert Chen <gilbert.chen@arm.com>
Signed-off-by: Thu Nguyen <thu@os.amperecomputing.com>
Change-Id: Ifa5bdfff50648f1d7fba8710e160de662e8f9e06
diff --git a/common/test/pldm_utils_test.cpp b/common/test/pldm_utils_test.cpp
index 295d364..86704c4 100644
--- a/common/test/pldm_utils_test.cpp
+++ b/common/test/pldm_utils_test.cpp
@@ -2,6 +2,7 @@
#include "mocked_utils.hpp"
#include <libpldm/platform.h>
+#include <linux/mctp.h>
#include <gtest/gtest.h>
@@ -1067,3 +1068,29 @@
auto results5 = split(s5, "\\");
EXPECT_EQ(results5[0], "aa");
}
+
+TEST(ValidEID, allTestCases)
+{
+ auto rc = isValidEID(MCTP_ADDR_NULL);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(MCTP_ADDR_ANY);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(1);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(2);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(3);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(4);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(5);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(6);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(7);
+ EXPECT_EQ(rc, false);
+ rc = isValidEID(MCTP_START_VALID_EID);
+ EXPECT_EQ(rc, true);
+ rc = isValidEID(254);
+ EXPECT_EQ(rc, true);
+}
diff --git a/common/types.hpp b/common/types.hpp
index 90c94c6..52f06ab 100644
--- a/common/types.hpp
+++ b/common/types.hpp
@@ -21,11 +21,34 @@
using Response = std::vector<uint8_t>;
using Command = uint8_t;
+/** @brief MCTP Endpoint Medium type in string
+ * Reseverd for future puspose
+ */
+
using MctpMedium = std::string;
+/** @brief Type definition of MCTP Network Index.
+ * uint32_t is used as defined in MCTP Endpoint D-Bus Interface
+ */
using NetworkId = uint32_t;
+
+/** @brief Type definition of MCTP interface information between two endpoints.
+ * eid : Endpoint EID in byte. Defind to match with MCTP D-Bus Interface
+ * UUID : Endpoint UUID which is used to different the endpoints
+ * MctpMedium: Endpoint MCTP Medium info (Resersed)
+ * NetworkId: MCTP network index
+ */
using MctpInfo = std::tuple<eid, UUID, MctpMedium, NetworkId>;
+
+/** @brief Type defind of list of MCTP interface information
+ */
using MctpInfos = std::vector<MctpInfo>;
+/**
+ * In `Table 2 - Special endpoint IDs` of DSP0236.
+ * EID from 1 to 7 is reserved EID. So the start valid EID is 8
+ */
+#define MCTP_START_VALID_EID 8
+
namespace dbus
{
diff --git a/common/utils.cpp b/common/utils.cpp
index f7a0ae0..60154be 100644
--- a/common/utils.cpp
+++ b/common/utils.cpp
@@ -2,6 +2,7 @@
#include <libpldm/pdr.h>
#include <libpldm/pldm_types.h>
+#include <linux/mctp.h>
#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
@@ -160,6 +161,17 @@
return eid;
}
+bool isValidEID(eid mctpEid)
+{
+ if (mctpEid == MCTP_ADDR_NULL || mctpEid < MCTP_START_VALID_EID ||
+ mctpEid == MCTP_ADDR_ANY)
+ {
+ return false;
+ }
+
+ return true;
+}
+
uint8_t getNumPadBytes(uint32_t data)
{
uint8_t pad;
diff --git a/common/utils.hpp b/common/utils.hpp
index ef7b085..103783d 100644
--- a/common/utils.hpp
+++ b/common/utils.hpp
@@ -375,6 +375,17 @@
*/
uint8_t readHostEID();
+/** @brief Validate the MCTP EID of MCTP endpoint
+ * In `Table 2 - Special endpoint IDs` of DSP0236. EID 0 is NULL_EID.
+ * EID from 1 to 7 is reserved EID. EID 0xFF is broadcast EID.
+ * Those are invalid EID of one MCTP Endpoint.
+ *
+ * @param[in] eid - MCTP EID
+ *
+ * @return true if the MCTP EID is valid otherwise return false.
+ */
+bool isValidEID(eid mctpEid);
+
/** @brief Convert a value in the JSON to a D-Bus property value
*
* @param[in] type - type of the D-Bus property