platform-mc: use MCTP target name as the default terminus name

The pldmd service typically derives the Terminus Name from the
ENTITY_AUXILIARY_NAMES_PDR, which is then used to construct the
inventory path for PLDM sensors described in PDRs.

However, certain MCTP devices such as NVMe and CXL do not support
this PDR, despite exposing sensor-related PDRs. In these cases,
pldmd is unable to create inventory paths for the sensors due to the
lack of a Terminus Name.

Patch [3], along with supporting changes in [1] and [2], introduces the
ability to associate Entity Manager configurations with MCTP endpoints.
This enables assigning a target name to each MCTP target via the EM
configuration. When the ENTITY_AUXILIARY_NAMES_PDR is missing, this
MCTP target name can be used as a fallback Terminus Name.

This patch updates pldmd to use the MCTP target name from EM as the
default Terminus Name in such cases. As a result, inventory path
construction and sensor creation can proceed correctly even for MCTP
devices that do not implement ENTITY_AUXILIARY_NAMES_PDR.

The terminus name is determined as follows:
- If neither EM nor PDRs provide a terminus name, it will be empty.
- If only the EM provides a terminus name, the EM-defined name is used.
- If both EM and PDRs provide a terminus name, the PDRs-defined name
  will override the EM-defined name.

[1] https://gerrit.openbmc.org/c/openbmc/dbus-sensors/+/69111
[2] https://gerrit.openbmc.org/c/openbmc/entity-manager/+/69600
[3] https://gerrit.openbmc.org/c/openbmc/pldm/+/78417

Change-Id: Idd24dbc3ae04af74b1d88fc213d77a5b058a8339
Signed-off-by: Kevin Tung <kevin.tung.openbmc@gmail.com>
diff --git a/platform-mc/terminus.hpp b/platform-mc/terminus.hpp
index 8ea5a57..fd878b5 100644
--- a/platform-mc/terminus.hpp
+++ b/platform-mc/terminus.hpp
@@ -139,6 +139,12 @@
         return tid;
     }
 
+    /** @brief The setter to set terminus's mctp medium */
+    void setTerminusName(const EntityName& tName)
+    {
+        terminusName = tName;
+    }
+
     /** @brief The getter to get terminus's mctp medium */
     std::optional<std::string_view> getTerminusName()
     {
diff --git a/platform-mc/terminus_manager.cpp b/platform-mc/terminus_manager.cpp
index d90b6cf..0de6ce9 100644
--- a/platform-mc/terminus_manager.cpp
+++ b/platform-mc/terminus_manager.cpp
@@ -431,6 +431,15 @@
     }
     termini[tid]->setSupportedCommands(pldmCmds);
 
+    /* Use the MCTP target name as the default terminus name */
+    MctpInfoName mctpInfoName = std::get<4>(mctpInfo);
+    if (mctpInfoName.has_value())
+    {
+        lg2::info("Terminus {TID} has default Terminus Name {NAME}", "NAME",
+                  mctpInfoName.value(), "TID", tid);
+        termini[tid]->setTerminusName(mctpInfoName.value());
+    }
+
     co_return PLDM_SUCCESS;
 }