From: Fan Ni <fan...@samsung.com> Add a new QAPI "qmp-cxl-process-mctp-message" to process the MCTP request cached in the shared buffer from FM VM.
Signed-off-by: Fan Ni <fan...@samsung.com> --- hw/mem/cxl_type3.c | 41 ++++++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3_stubs.c | 5 +++++ qapi/cxl.json | 18 ++++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 7f85616ca1..f7ac8e8da7 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1614,6 +1614,47 @@ void cxl_clear_poison_list_overflowed(CXLType3Dev *ct3d) ct3d->poison_list_overflow_ts = 0; } +void qmp_cxl_process_mctp_message(const char *cci_name, Error **errp) +{ + int i; + struct CXLCCINamePtrMap *map; + struct CXLMCTPCommandBuf *buf; + CXLCCI *cci = NULL; + CXLType3Dev *ct3d; + + if (!cci_map_buf) { + error_setg(errp, "CCI name mapping buffer not setup"); + return; + } + + for (i = 0; i < cci_map_buf->num_mappings; i++) { + map = &cci_map_buf->maps[i]; + if (!strcmp(map->cci_name, cci_name)) { + cci = (CXLCCI *) map->cci_pointer; + break; + } + } + if (!cci) { + error_setg(errp, "CCI instance is not found with name: %s", cci_name); + return; + } + ct3d = CXL_TYPE3(OBJECT(cci->d)); + if (!ct3d) { + error_setg(errp, "No Type3 device associated with the cci"); + return; + } + if (ct3d->mctp_shared_buffer->status != 1) { + error_setg(errp, "MCTP buffer status is not set to 1, skip"); + return; + } + buf = &ct3d->mctp_shared_buffer->command_buf; + buf->ret_val = cxl_process_cci_message(cci, buf->command_set, buf->command, + buf->len_in, buf->payload, + &buf->len_out, buf->payload_out, + &buf->bg_started); + ct3d->mctp_shared_buffer->status = 0; +} + void qmp_cxl_inject_poison(const char *path, uint64_t start, uint64_t length, Error **errp) { diff --git a/hw/mem/cxl_type3_stubs.c b/hw/mem/cxl_type3_stubs.c index c1a5e4a7c1..dbf18f2af2 100644 --- a/hw/mem/cxl_type3_stubs.c +++ b/hw/mem/cxl_type3_stubs.c @@ -92,3 +92,8 @@ void qmp_cxl_release_dynamic_capacity(const char *path, uint16_t host_id, { error_setg(errp, "CXL Type 3 support is not compiled in"); } + +void qmp_cxl_process_mctp_message(const char *cci_name, Error **errp) +{ + error_setg(errp, "CXL Type 3 support is not compiled in"); +} diff --git a/qapi/cxl.json b/qapi/cxl.json index dd947d3bbc..fcb1e0b3fd 100644 --- a/qapi/cxl.json +++ b/qapi/cxl.json @@ -553,3 +553,21 @@ }, 'features': [ 'unstable' ] } + +## +# @cxl-process-mctp-message: +# +# Command to process a MCTP command sent from another VM. +# +# @cci-name: name of the CCI to process the command; +# +# Features: +# +# @unstable: For now this command is subject to change. +# +# Since: 9.1 +## +{'command': 'cxl-process-mctp-message', + 'data': {'cci-name': 'str'}, + 'features': [ 'unstable' ] + } -- 2.47.2