From eabca51439ffbfd5e32fa4667e850ac437b42caa Mon Sep 17 00:00:00 2001 From: Anton Rakovchuk Date: Thu, 27 Jun 2024 19:01:34 +0000 Subject: [PATCH] Merged PR 3752: Report SPDM as supported message type for MCTP protocol Report SPDM as supported message type for MCTP protocol --- core/mctp/mctp_control_protocol_commands.c | 15 +++++- .../mctp/cmd_interface_mctp_control_test.c | 5 +- .../mctp_control_protocol_commands_test.c | 50 ++++++++++++++++++- 3 files changed, 65 insertions(+), 5 deletions(-) diff --git a/core/mctp/mctp_control_protocol_commands.c b/core/mctp/mctp_control_protocol_commands.c index 2028205..0f015a6 100644 --- a/core/mctp/mctp_control_protocol_commands.c +++ b/core/mctp/mctp_control_protocol_commands.c @@ -12,6 +12,7 @@ #include "mctp_logging.h" #include "platform_api.h" #include "cmd_interface/device_manager.h" +#include "spdm/spdm_protocol.h" /** @@ -214,6 +215,17 @@ int mctp_control_protocol_get_mctp_version_support (struct cmd_interface_msg *re CERBERUS_PROTOCOL_PROTOCOL_VERSION; break; + case MCTP_BASE_PROTOCOL_MSG_TYPE_SPDM: + response->version_num_entry_count = 1; + version_entry->alpha = 0; + version_entry->update = MCTP_CONTROL_GET_MCTP_VERSION_VERSION_IGNORE_UPDATE; + version_entry->minor = MCTP_CONTROL_GET_MCTP_VERSION_VERSION_ENCODING | + SPDM_MAX_MINOR_VERSION; + version_entry->major = MCTP_CONTROL_GET_MCTP_VERSION_VERSION_ENCODING | + SPDM_MAJOR_VERSION; + + break; + case 0xFF: response->version_num_entry_count = 1; version_entry->alpha = 0; @@ -268,12 +280,13 @@ int mctp_control_protocol_get_message_type_support (struct cmd_interface_msg *re return 0; } - response->message_type_count = 2; + response->message_type_count = 3; message_type_list = mctp_control_get_message_type_response_get_entries (response); message_type_list[0] = MCTP_BASE_PROTOCOL_MSG_TYPE_CONTROL_MSG; message_type_list[1] = MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF; + message_type_list[2] = MCTP_BASE_PROTOCOL_MSG_TYPE_SPDM; request->length = mctp_control_get_message_type_response_length (response->message_type_count); diff --git a/core/testing/mctp/cmd_interface_mctp_control_test.c b/core/testing/mctp/cmd_interface_mctp_control_test.c index 61a79f4..033f1f2 100644 --- a/core/testing/mctp/cmd_interface_mctp_control_test.c +++ b/core/testing/mctp/cmd_interface_mctp_control_test.c @@ -550,7 +550,7 @@ static void cmd_interface_mctp_control_test_process_request_get_message_type_sup status = cmd.handler.base.process_request (&cmd.handler.base, &request); CuAssertIntEquals (test, 0, status); CuAssertTrue (test, !request.crypto_timeout); - CuAssertIntEquals (test, mctp_control_get_message_type_response_length (2), request.length); + CuAssertIntEquals (test, mctp_control_get_message_type_response_length (3), request.length); CuAssertIntEquals (test, 0, rsp->header.header.msg_type); CuAssertIntEquals (test, 0, rsp->header.header.rq); CuAssertIntEquals (test, 0, rsp->header.header.d_bit); @@ -560,11 +560,12 @@ static void cmd_interface_mctp_control_test_process_request_get_message_type_sup CuAssertIntEquals (test, MCTP_CONTROL_PROTOCOL_GET_MESSAGE_TYPE, rsp->header.header.command_code); CuAssertIntEquals (test, MCTP_CONTROL_PROTOCOL_SUCCESS, rsp->header.completion_code); - CuAssertIntEquals (test, 2, rsp->message_type_count); + CuAssertIntEquals (test, 3, rsp->message_type_count); entry = mctp_control_get_message_type_response_get_entries (rsp); CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_CONTROL_MSG, entry[0]); CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, entry[1]); + CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_SPDM, entry[2]); complete_cmd_interface_mctp_control_test (test, &cmd); } diff --git a/core/testing/mctp/mctp_control_protocol_commands_test.c b/core/testing/mctp/mctp_control_protocol_commands_test.c index 59aab97..ba6ab2d 100644 --- a/core/testing/mctp/mctp_control_protocol_commands_test.c +++ b/core/testing/mctp/mctp_control_protocol_commands_test.c @@ -9,6 +9,7 @@ #include "cmd_interface/device_manager.h" #include "mctp/mctp_control_protocol.h" #include "mctp/mctp_control_protocol_commands.h" +#include "spdm/spdm_protocol.h" #include "testing/mock/cmd_interface/cmd_interface_mock.h" @@ -1081,6 +1082,49 @@ static void mctp_control_protocol_commands_test_process_get_mctp_version_support CuAssertIntEquals (test, 0, entry->alpha); } +static void mctp_control_protocol_commands_test_process_get_mctp_version_support_spdm_protocol ( + CuTest *test) +{ + uint8_t data[MCTP_BASE_PROTOCOL_MIN_TRANSMISSION_UNIT]; + struct cmd_interface_msg request; + struct mctp_control_get_mctp_version *rq = (struct mctp_control_get_mctp_version*) data; + struct mctp_control_get_mctp_version_response *response = + (struct mctp_control_get_mctp_version_response*) data; + struct mctp_control_mctp_version_number_entry *entry = + mctp_control_get_mctp_version_response_get_entries (response); + int status; + + TEST_START; + + memset (&request, 0, sizeof (request)); + memset (data, 0, sizeof (data)); + request.data = data; + + rq->header.msg_type = MCTP_BASE_PROTOCOL_MSG_TYPE_CONTROL_MSG; + rq->header.command_code = MCTP_CONTROL_PROTOCOL_GET_MCTP_VERSION; + rq->header.rq = 1; + rq->header.instance_id = 2; + + rq->message_type_num = MCTP_BASE_PROTOCOL_MSG_TYPE_SPDM; + + request.length = sizeof (struct mctp_control_get_mctp_version); + request.source_eid = MCTP_BASE_PROTOCOL_BMC_EID; + request.target_eid = MCTP_BASE_PROTOCOL_PA_ROT_CTRL_EID; + + status = mctp_control_protocol_get_mctp_version_support (&request); + CuAssertIntEquals (test, 0, status); + CuAssertIntEquals (test, mctp_control_get_mctp_version_response_length (1), request.length); + CuAssertIntEquals (test, 4, response->header.header.command_code); + CuAssertIntEquals (test, 0, response->header.completion_code); + CuAssertIntEquals (test, 1, response->version_num_entry_count); + CuAssertIntEquals (test, MCTP_CONTROL_GET_MCTP_VERSION_VERSION_ENCODING | SPDM_MAJOR_VERSION, + entry->major); + CuAssertIntEquals (test, + MCTP_CONTROL_GET_MCTP_VERSION_VERSION_ENCODING | SPDM_MAX_MINOR_VERSION, entry->minor); + CuAssertIntEquals (test, MCTP_CONTROL_GET_MCTP_VERSION_VERSION_IGNORE_UPDATE, entry->update); + CuAssertIntEquals (test, 0, entry->alpha); +} + static void mctp_control_protocol_commands_test_process_get_mctp_version_support_null (CuTest *test) { int status; @@ -1196,12 +1240,13 @@ static void mctp_control_protocol_commands_test_process_get_message_type_support status = mctp_control_protocol_get_message_type_support (&request); CuAssertIntEquals (test, 0, status); - CuAssertIntEquals (test, mctp_control_get_message_type_response_length (2), request.length); + CuAssertIntEquals (test, mctp_control_get_message_type_response_length (3), request.length); CuAssertIntEquals (test, 5, response->header.header.command_code); CuAssertIntEquals (test, 0, response->header.completion_code); - CuAssertIntEquals (test, 2, response->message_type_count); + CuAssertIntEquals (test, 3, response->message_type_count); CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_CONTROL_MSG, entry[0]); CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_VENDOR_DEF, entry[1]); + CuAssertIntEquals (test, MCTP_BASE_PROTOCOL_MSG_TYPE_SPDM, entry[2]); } static void mctp_control_protocol_commands_test_process_get_message_type_support_invalid_len ( @@ -2116,6 +2161,7 @@ TEST (mctp_control_protocol_commands_test_process_get_eid_invalid_len); TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_mctp_base_protocol); TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_mctp_ctrl_protocol); TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_vdm_protocol); +TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_spdm_protocol); TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_null); TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_invalid_len); TEST (mctp_control_protocol_commands_test_process_get_mctp_version_support_unsupported_msg_type);