Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library/pci_doe_responder_lib: Use libspdm DOE encode/decode helpers #268

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion library/pci_doe_responder_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ INCLUDE_DIRECTORIES(${LIBSPDM_DIR}/include

SET(src_pci_doe_responder_lib
pci_doe_dispatch.c
pci_doe_rsp_discovery.c
pci_doe_spdm_vendor_dispatch.c
)

Expand Down
47 changes: 26 additions & 21 deletions library/pci_doe_responder_lib/pci_doe_dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@
#include "library/spdm_transport_pcidoe_lib.h"
#include "library/pci_doe_responder_lib.h"

typedef struct {
pci_doe_data_object_protocol_t protocol;
pci_doe_get_response_func_t func;
} pci_doe_dispatch_struct_t;

pci_doe_dispatch_struct_t m_pci_doe_dispatch[] = {
{{PCI_DOE_VENDOR_ID_PCISIG, PCI_DOE_DATA_OBJECT_TYPE_DOE_DISCOVERY},
pci_doe_get_response_discovery},
pci_doe_data_object_protocol_t m_data_object_protocol[] = {
{PCI_DOE_VENDOR_ID_PCISIG, PCI_DOE_DATA_OBJECT_TYPE_DOE_DISCOVERY},
{PCI_DOE_VENDOR_ID_PCISIG, PCI_DOE_DATA_OBJECT_TYPE_SPDM},
{PCI_DOE_VENDOR_ID_PCISIG, PCI_DOE_DATA_OBJECT_TYPE_SECURED_SPDM},
};

/**
Expand All @@ -35,22 +31,31 @@ libspdm_return_t pci_doe_get_response_doe_request(const void *pci_doe_context,
const void *request, size_t request_size,
void *response, size_t *response_size)
{
pci_doe_data_object_header_t *doe_request;
size_t index;
uint8_t index = 0;
uint32_t *reply = response;
libspdm_return_t ret;

ret = libspdm_pci_doe_decode_discovery_request(request_size, request, &index);

doe_request = (void *)request;
if (request_size < sizeof(doe_request)) {
return LIBSPDM_STATUS_INVALID_MSG_SIZE;
if (ret != LIBSPDM_STATUS_SUCCESS) {
return ret;
}

for (index = 0; index < LIBSPDM_ARRAY_SIZE(m_pci_doe_dispatch); index++) {
if ((doe_request->vendor_id == m_pci_doe_dispatch[index].protocol.vendor_id) &&
(doe_request->data_object_type ==
m_pci_doe_dispatch[index].protocol.data_object_type)) {
return m_pci_doe_dispatch[index].func (pci_doe_context, request, request_size, response,
response_size);
}
if (index >= LIBSPDM_ARRAY_SIZE(m_data_object_protocol)) {
return LIBSPDM_STATUS_INVALID_MSG_FIELD;
} else if (index == LIBSPDM_ARRAY_SIZE(m_data_object_protocol) - 1) {
reply[2] = m_data_object_protocol[index].data_object_type << 16 |
m_data_object_protocol[index].vendor_id;
} else {
reply[2] = (index + 1) << 24 |
m_data_object_protocol[index].data_object_type << 16 |
m_data_object_protocol[index].vendor_id;
}

return LIBSPDM_STATUS_UNSUPPORTED_CAP;
return libspdm_pci_doe_encode_discovery(
sizeof(uint32_t),
&reply[2],
response_size,
&response
);
}
92 changes: 0 additions & 92 deletions library/pci_doe_responder_lib/pci_doe_rsp_discovery.c

This file was deleted.

Loading