Make Terminus ID & Terminus Handle configurable
The current pldm code hardcoded the terminus id and the
terminus handles, making it configurable so that the
oem vendors can set them as per thier need in the
bitbake meta data.
Also,in the current state the FRU record set PDR's and
the Sensor/Effecter PDR's are generated with terminus
handle 0, but the terminus locator PDR is hardcoded with
handle 1. This commit also fixes that behaviour.
Tested :
1. Terminus locator PDR
{
"nextRecordHandle": 89,
"responseCount": 19,
"recordHandle": 88,
"PDRHeaderVersion": 1,
"PDRType": "Terminus Locator PDR",
"recordChangeNumber": 0,
"dataLength": 9,
"PLDMTerminusHandle": 1,
"validity": "valid",
"TID": 1,
"containerID": 0,
"terminusLocatorType": "MCTP_EID",
"terminusLocatorValueSize": 1,
"EID": 8
}
2. FRU record set PDR
{
"nextRecordHandle": 77,
"responseCount": 20,
"recordHandle": 76,
"PDRHeaderVersion": 1,
"PDRType": "FRU Record Set PDR",
"recordChangeNumber": 0,
"dataLength": 10,
"PLDMTerminusHandle": 1,
"FRURecordSetIdentifier": 76,
"entityType": "[Physical] Slot",
"entityInstanceNumber": 12,
"containerID": 3
}
3. Sensor PDR
{
"nextRecordHandle": 208,
"responseCount": 28,
"recordHandle": 207,
"PDRHeaderVersion": 1,
"PDRType": "State Sensor PDR",
"recordChangeNumber": 0,
"dataLength": 18,
"PLDMTerminusHandle": 1,
"sensorID": 2,
"entityType": "[Physical] External Environment",
"entityInstanceNumber": 0,
"containerID": 1,
"sensorInit": "noInit",
"sensorAuxiliaryNamesPDR": false,
"compositeSensorCount": 1,
"stateSetID[0]": "Health State(1)",
"possibleStatesSize[0]": 2,
"possibleStates[0]": [
"Normal(1)",
"Upper Fatal(9)"
]
}
4. Effecter PDR
{
"nextRecordHandle": 142,
"responseCount": 29,
"recordHandle": 141,
"PDRHeaderVersion": 1,
"PDRType": "State Effecter PDR",
"recordChangeNumber": 0,
"dataLength": 19,
"PLDMTerminusHandle": 1,
"effecterID": 53,
"entityType": "[Physical] Fan",
"entityInstanceNumber": 1,
"containerID": 3,
"effecterSemanticID": 0,
"effecterInit": "noInit",
"effecterDescriptionPDR": false,
"compositeEffecterCount": 1,
"stateSetID[0]": "Identify State(17)",
"possibleStatesSize[0]": 1,
"possibleStates[0]": [
"Identify State Unasserted(1)",
"Identify State Asserted(2)"
]
}
Signed-off-by: Manojkiran Eda <manojkiran.eda@gmail.com>
Change-Id: I68d1c5c121b9389cc9b89dde9f1a8d8679b068f1
diff --git a/libpldmresponder/fru.cpp b/libpldmresponder/fru.cpp
index 74dd8a2..3ec5d92 100644
--- a/libpldmresponder/fru.cpp
+++ b/libpldmresponder/fru.cpp
@@ -5,6 +5,7 @@
#include "common/utils.hpp"
+#include <config.h>
#include <systemd/sd-journal.h>
#include <sdbusplus/bus.hpp>
@@ -224,9 +225,9 @@
recordSetIdentifier = nextRSI();
bmc_record_handle = nextRecordHandle();
pldm_pdr_add_fru_record_set(
- pdrRepo, 0, recordSetIdentifier, entity.entity_type,
- entity.entity_instance_num, entity.entity_container_id,
- bmc_record_handle);
+ pdrRepo, TERMINUS_HANDLE, recordSetIdentifier,
+ entity.entity_type, entity.entity_instance_num,
+ entity.entity_container_id, bmc_record_handle);
}
auto curSize = table.size();
table.resize(curSize + recHeaderSize + tlvs.size());
diff --git a/libpldmresponder/pdr.hpp b/libpldmresponder/pdr.hpp
index 4870c4a..f9ebf52 100644
--- a/libpldmresponder/pdr.hpp
+++ b/libpldmresponder/pdr.hpp
@@ -3,6 +3,7 @@
#include "common/utils.hpp"
#include "libpldmresponder/pdr_utils.hpp"
+#include <config.h>
#include <stdint.h>
namespace pldm
@@ -15,8 +16,6 @@
{
constexpr uint8_t BmcMctpEid = 8;
-constexpr uint8_t BmcPldmTerminusHandle = 1;
-constexpr uint8_t BmcTerminusId = 1;
/** @brief Build (if not built already) and retrieve PDR by the PDR types
*
diff --git a/libpldmresponder/pdr_state_effecter.hpp b/libpldmresponder/pdr_state_effecter.hpp
index 7307898..85fb011 100644
--- a/libpldmresponder/pdr_state_effecter.hpp
+++ b/libpldmresponder/pdr_state_effecter.hpp
@@ -5,6 +5,8 @@
#include "pdr.hpp"
#include "pdr_utils.hpp"
+#include <config.h>
+
namespace pldm
{
@@ -68,7 +70,7 @@
pdr->hdr.record_change_num = 0;
pdr->hdr.length = pdrSize - sizeof(pldm_pdr_hdr);
- pdr->terminus_handle = pdr::BmcPldmTerminusHandle;
+ pdr->terminus_handle = TERMINUS_HANDLE;
pdr->effecter_id = handler.getNextEffecterId();
try
diff --git a/libpldmresponder/pdr_state_sensor.hpp b/libpldmresponder/pdr_state_sensor.hpp
index a7842df..c80f533 100644
--- a/libpldmresponder/pdr_state_sensor.hpp
+++ b/libpldmresponder/pdr_state_sensor.hpp
@@ -71,7 +71,7 @@
HTOLE16(pdr->hdr.record_change_num);
HTOLE16(pdr->hdr.length);
- pdr->terminus_handle = 0;
+ pdr->terminus_handle = TERMINUS_HANDLE;
pdr->sensor_id = handler.getNextSensorId();
try
diff --git a/libpldmresponder/platform.cpp b/libpldmresponder/platform.cpp
index 1b4c8f5..7c011fa 100644
--- a/libpldmresponder/platform.cpp
+++ b/libpldmresponder/platform.cpp
@@ -1,4 +1,3 @@
-
#include "platform.hpp"
#include "libpldm/entity.h"
@@ -16,6 +15,8 @@
#include "platform_state_effecter.hpp"
#include "platform_state_sensor.hpp"
+#include <config.h>
+
using namespace pldm::utils;
using namespace pldm::responder::pdr;
using namespace pldm::responder::pdr_utils;
@@ -596,9 +597,9 @@
pdr->hdr.type = PLDM_TERMINUS_LOCATOR_PDR;
pdr->hdr.record_change_num = 0;
pdr->hdr.length = sizeof(pldm_terminus_locator_pdr) - sizeof(pldm_pdr_hdr);
- pdr->terminus_handle = BmcPldmTerminusHandle;
+ pdr->terminus_handle = TERMINUS_HANDLE;
pdr->validity = PLDM_TL_PDR_VALID;
- pdr->tid = BmcTerminusId;
+ pdr->tid = TERMINUS_ID;
pdr->container_id = 0x0;
pdr->terminus_locator_type = PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID;
pdr->terminus_locator_value_size =
diff --git a/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp b/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp
index cefda3a..3b13ab0 100644
--- a/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_pdr_effecter_test.cpp
@@ -51,7 +51,7 @@
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 23);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->effecter_id, 1);
ASSERT_EQ(pdr->entity_type, 33);
ASSERT_EQ(pdr->entity_instance, 0);
@@ -83,7 +83,7 @@
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 24);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->effecter_id, 2);
ASSERT_EQ(pdr->entity_type, 100);
ASSERT_EQ(pdr->entity_instance, 0);
diff --git a/libpldmresponder/test/libpldmresponder_platform_test.cpp b/libpldmresponder/test/libpldmresponder_platform_test.cpp
index 0fb88a1..10082a6 100644
--- a/libpldmresponder/test/libpldmresponder_platform_test.cpp
+++ b/libpldmresponder/test/libpldmresponder_platform_test.cpp
@@ -566,9 +566,9 @@
EXPECT_EQ(pdr->hdr.record_change_num, 0);
EXPECT_EQ(pdr->hdr.length,
sizeof(pldm_terminus_locator_pdr) - sizeof(pldm_pdr_hdr));
- EXPECT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ EXPECT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
EXPECT_EQ(pdr->validity, PLDM_TL_PDR_VALID);
- EXPECT_EQ(pdr->tid, BmcTerminusId);
+ EXPECT_EQ(pdr->tid, TERMINUS_ID);
EXPECT_EQ(pdr->container_id, 0);
EXPECT_EQ(pdr->terminus_locator_type, PLDM_TERMINUS_LOCATOR_TYPE_MCTP_EID);
EXPECT_EQ(pdr->terminus_locator_value_size,
diff --git a/meson.build b/meson.build
index b06a082..4757fe6 100644
--- a/meson.build
+++ b/meson.build
@@ -34,6 +34,8 @@
conf_data.set_quoted('HOST_JSONS_DIR', join_paths(package_datadir, 'host'))
conf_data.set_quoted('EVENTS_JSONS_DIR', join_paths(package_datadir, 'events'))
conf_data.set('HEARTBEAT_TIMEOUT', get_option('heartbeat-timeout-seconds'))
+conf_data.set('TERMINUS_ID', get_option('terminus-id'))
+conf_data.set('TERMINUS_HANDLE',get_option('terminus-handle'))
add_project_arguments('-DLIBPLDMRESPONDER', language : ['c','cpp'])
endif
if get_option('softoff').enabled()
diff --git a/meson_options.txt b/meson_options.txt
index 5462403..a535fee 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -20,3 +20,8 @@
option('response-time-out', type: 'integer', min: 300, max: 4800, description: 'The amount of time a requester has to wait for a response message in milliseconds', value: 2000)
option('heartbeat-timeout-seconds', type: 'integer', description: ' The amount of time host waits for BMC to respond to pings from host, as part of host-bmc surveillance', value: 120)
+
+# PLDM Terminus options
+option('terminus-id', type:'integer', min:0, max: 255, description: 'The terminus id value of the device that is running this pldm stack', value:1)
+option('terminus-handle',type:'integer',min:0, max:65535, description: 'The terminus handle value of the device that is running this pldm stack', value:1)
+
diff --git a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
index 4a0c8c6..582a3df 100644
--- a/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
+++ b/oem/ibm/libpldmresponder/oem_ibm_handler.cpp
@@ -172,7 +172,7 @@
pdr->hdr.type = PLDM_STATE_EFFECTER_PDR;
pdr->hdr.record_change_num = 0;
pdr->hdr.length = sizeof(pldm_state_effecter_pdr) - sizeof(pldm_pdr_hdr);
- pdr->terminus_handle = pdr::BmcPldmTerminusHandle;
+ pdr->terminus_handle = TERMINUS_HANDLE;
pdr->effecter_id = platformHandler->getNextEffecterId();
pdr->entity_type = entityType;
pdr->entity_instance = entityInstance;
@@ -223,7 +223,7 @@
pdr->hdr.type = PLDM_STATE_SENSOR_PDR;
pdr->hdr.record_change_num = 0;
pdr->hdr.length = sizeof(pldm_state_sensor_pdr) - sizeof(pldm_pdr_hdr);
- pdr->terminus_handle = pdr::BmcPldmTerminusHandle;
+ pdr->terminus_handle = TERMINUS_HANDLE;
pdr->sensor_id = platformHandler->getNextSensorId();
pdr->entity_type = entityType;
pdr->entity_instance = entityInstance;
diff --git a/oem/ibm/test/libpldmresponder_oem_platform_test.cpp b/oem/ibm/test/libpldmresponder_oem_platform_test.cpp
index b2eec24..d124a39 100644
--- a/oem/ibm/test/libpldmresponder_oem_platform_test.cpp
+++ b/oem/ibm/test/libpldmresponder_oem_platform_test.cpp
@@ -213,7 +213,7 @@
ASSERT_EQ(pdr->hdr.type, PLDM_STATE_EFFECTER_PDR);
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 16);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->entity_type, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE);
ASSERT_EQ(pdr->entity_instance, 0);
ASSERT_EQ(pdr->container_id, 0);
@@ -240,7 +240,7 @@
ASSERT_EQ(pdr->hdr.type, PLDM_STATE_EFFECTER_PDR);
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 16);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->entity_type, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE);
ASSERT_EQ(pdr->entity_instance, 1);
ASSERT_EQ(pdr->container_id, 0);
@@ -267,7 +267,7 @@
ASSERT_EQ(pdr->hdr.type, PLDM_STATE_EFFECTER_PDR);
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 16);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->entity_type, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE);
ASSERT_EQ(pdr->entity_instance, 0);
ASSERT_EQ(pdr->container_id, 0);
@@ -318,7 +318,7 @@
ASSERT_EQ(pdr->hdr.type, PLDM_STATE_SENSOR_PDR);
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 14);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->entity_type, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE);
ASSERT_EQ(pdr->entity_instance, 0);
ASSERT_EQ(pdr->container_id, 0);
@@ -344,7 +344,7 @@
ASSERT_EQ(pdr->hdr.type, PLDM_STATE_SENSOR_PDR);
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 14);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->entity_type, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE);
ASSERT_EQ(pdr->entity_instance, 1);
ASSERT_EQ(pdr->container_id, 0);
@@ -370,7 +370,7 @@
ASSERT_EQ(pdr->hdr.type, PLDM_STATE_SENSOR_PDR);
ASSERT_EQ(pdr->hdr.record_change_num, 0);
ASSERT_EQ(pdr->hdr.length, 14);
- ASSERT_EQ(pdr->terminus_handle, BmcPldmTerminusHandle);
+ ASSERT_EQ(pdr->terminus_handle, TERMINUS_HANDLE);
ASSERT_EQ(pdr->entity_type, PLDM_OEM_IBM_ENTITY_FIRMWARE_UPDATE);
ASSERT_EQ(pdr->entity_instance, 0);
ASSERT_EQ(pdr->container_id, 0);