Adding support for GetFruRecordTableMetadata FRU command type in pldmtool.
./pldmtool -h
PLDM requester tool for OpenBMC
Usage: ./pldmtool [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
Subcommands:
raw send a raw request and print response
base base type command
fru fru type command
root@wspooncap07a-Y110UF8B9009:/tmp# ./pldmtool fru -h
fru type command
Usage: ./pldmtool fru [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
Subcommands:
GetFruRecordTableMetadata get fru record table metadata
./pldmtool fru -h
fru type command
Usage: ./pldmtool fru [OPTIONS] SUBCOMMAND
Options:
-h,--help Print this help message and exit
Subcommands:
GetFruRecordTableMetadata get fru record table metadata
./pldmtool fru GetFruRecordTableMetadata
Encode request successfully
Request Message:
08 01 80 04 01
Success in creating the socket : RC = 3
Success in connecting to socket : RC = 0
Success in sending message type as pldm to mctp : RC = 0
Write to socket successful : RC = 5
Total length:5
Loopback response message:
08 01 80 04 01
On first recv(),response == request : RC = 0
Total length: 24
Shutdown Socket successful : RC = 0
Response Message:
08 01 00 04 01 00 01 00 ff ff ff ff 3c 00 00 00 01 00 01 00 a7 c3 c7 98
Parsed Response Msg :
FRUDATAMajorVersion : 1
FRUDATAMinorVersion : 0
FRUTableMaximumSize : 4294967295
FRUTableLength : 60
Total number of Record Set Identifiers in table : 1
Total number of records in table : 1
FRU DATAStructureTableIntegrityChecksum : 2563228583
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
Change-Id: I4396ff72418730bb8c0920f5f20688a28544b4cc
diff --git a/tool/meson.build b/tool/meson.build
index 254585c..978d057 100644
--- a/tool/meson.build
+++ b/tool/meson.build
@@ -3,6 +3,7 @@
'pldm_base_cmd.cpp',
'pldm_platform_cmd.cpp',
'pldm_bios_cmd.cpp',
+ 'pldm_fru_cmd.cpp',
'pldmtool.cpp'
]
diff --git a/tool/pldm_cmd_helper.hpp b/tool/pldm_cmd_helper.hpp
index d7beec9..2c736ec 100644
--- a/tool/pldm_cmd_helper.hpp
+++ b/tool/pldm_cmd_helper.hpp
@@ -15,6 +15,7 @@
#include "libpldm/base.h"
#include "libpldm/bios.h"
+#include "libpldm/fru.h"
#include "libpldm/platform.h"
namespace pldmtool
diff --git a/tool/pldm_fru_cmd.cpp b/tool/pldm_fru_cmd.cpp
new file mode 100644
index 0000000..e1cf800
--- /dev/null
+++ b/tool/pldm_fru_cmd.cpp
@@ -0,0 +1,90 @@
+#include "pldm_fru_cmd.hpp"
+
+#include "pldm_cmd_helper.hpp"
+
+namespace pldmtool
+{
+
+namespace fru
+{
+
+namespace
+{
+
+using namespace pldmtool::helper;
+
+std::vector<std::unique_ptr<CommandInterface>> commands;
+
+} // namespace
+
+class GetFruRecordTableMetadata : public CommandInterface
+{
+ public:
+ ~GetFruRecordTableMetadata() = default;
+ GetFruRecordTableMetadata() = delete;
+ GetFruRecordTableMetadata(const GetFruRecordTableMetadata&) = delete;
+ GetFruRecordTableMetadata(GetFruRecordTableMetadata&&) = default;
+ GetFruRecordTableMetadata&
+ operator=(const GetFruRecordTableMetadata&) = delete;
+ GetFruRecordTableMetadata& operator=(GetFruRecordTableMetadata&&) = default;
+
+ using CommandInterface::CommandInterface;
+
+ std::pair<int, std::vector<uint8_t>> createRequestMsg() override
+ {
+ std::vector<uint8_t> requestMsg(sizeof(pldm_msg_hdr));
+ auto request = reinterpret_cast<pldm_msg*>(requestMsg.data());
+
+ auto rc = encode_get_fru_record_table_metadata_req(
+ PLDM_LOCAL_INSTANCE_ID, request);
+ return {rc, requestMsg};
+ }
+
+ void parseResponseMsg(pldm_msg* responsePtr, size_t payloadLength) override
+ {
+ uint8_t cc = 0;
+ uint8_t fru_data_major_version, fru_data_minor_version;
+ uint32_t fru_table_maximum_size, fru_table_length;
+ uint16_t total_record_set_identifiers, total_table_records;
+ uint32_t checksum;
+
+ auto rc = decode_get_fru_record_table_metadata_resp(
+ responsePtr, payloadLength, &cc, &fru_data_major_version,
+ &fru_data_minor_version, &fru_table_maximum_size, &fru_table_length,
+ &total_record_set_identifiers, &total_table_records, &checksum);
+ if (rc != PLDM_SUCCESS || cc != PLDM_SUCCESS)
+ {
+ std::cerr << "Response Message Error: "
+ << "rc=" << rc << ",cc=" << (int)cc << std::endl;
+ return;
+ }
+ std::cout << "Parsed Response Msg : " << std::endl;
+ std::cout << "FRUDATAMajorVersion : "
+ << static_cast<uint32_t>(fru_data_major_version) << std::endl;
+ std::cout << "FRUDATAMinorVersion : "
+ << static_cast<uint32_t>(fru_data_minor_version) << std::endl;
+ std::cout << "FRUTableMaximumSize : " << fru_table_maximum_size
+ << std::endl;
+ std::cout << "FRUTableLength : " << fru_table_length << std::endl;
+ std::cout << "Total number of Record Set Identifiers in table : "
+ << total_record_set_identifiers << std::endl;
+ std::cout << "Total number of records in table : "
+ << total_table_records << std::endl;
+ std::cout << "FRU DATAStructureTableIntegrityChecksum : " << checksum
+ << std::endl;
+ }
+};
+
+void registerCommand(CLI::App& app)
+{
+ auto fru = app.add_subcommand("fru", "FRU type command");
+ fru->require_subcommand(1);
+ auto getFruRecordTableMetadata = fru->add_subcommand(
+ "GetFruRecordTableMetadata", "get FRU record table metadata");
+ commands.push_back(std::make_unique<GetFruRecordTableMetadata>(
+ "fru", "GetFruRecordTableMetadata", getFruRecordTableMetadata));
+}
+
+} // namespace fru
+
+} // namespace pldmtool
diff --git a/tool/pldm_fru_cmd.hpp b/tool/pldm_fru_cmd.hpp
new file mode 100644
index 0000000..1cb3210
--- /dev/null
+++ b/tool/pldm_fru_cmd.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <CLI/CLI.hpp>
+
+namespace pldmtool
+{
+
+namespace fru
+{
+
+void registerCommand(CLI::App& app);
+}
+
+} // namespace pldmtool
diff --git a/tool/pldmtool.cpp b/tool/pldmtool.cpp
index 0f0182b..7e4e0e8 100644
--- a/tool/pldmtool.cpp
+++ b/tool/pldmtool.cpp
@@ -1,6 +1,7 @@
#include "pldm_base_cmd.hpp"
#include "pldm_bios_cmd.hpp"
#include "pldm_cmd_helper.hpp"
+#include "pldm_fru_cmd.hpp"
#include "pldm_platform_cmd.hpp"
#include <CLI/CLI.hpp>
@@ -70,6 +71,7 @@
pldmtool::base::registerCommand(app);
pldmtool::bios::registerCommand(app);
pldmtool::platform::registerCommand(app);
+ pldmtool::fru::registerCommand(app);
CLI11_PARSE(app, argc, argv);
return 0;