qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [HACK QEMU PATCH v1 0/1] CXL MCTP FMAPI Binding Fix for MCTP over i2c/USB
@ 2025-06-26 23:41 anisa.su887
  2025-06-26 23:41 ` [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check anisa.su887
  0 siblings, 1 reply; 5+ messages in thread
From: anisa.su887 @ 2025-06-26 23:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jonathan.Cameron, nifan.cxl, dave, linux-cxl, Anisa Su

From: Anisa Su <anisa.su@samsung.com>

The FMAPI DCD Management patchset (https://lore.kernel.org/linux-cxl/20250626222743.1766404-1-anisa.su887@gmail.com/T/#t)
is based on upstream, which does not include the i2c MCTP hack or the new MCTP
USB support carried in Jonathan's tree.

The commands are accessible upstream through a switch-cci. Thus, to break the
dependence on the MCTP support patches, the commands are sent separately
from this patch.

This patch is based on Jonathan's latest branch
(https://gitlab.com/jic23/qemu/-/tree/cxl-2025-06-10) and fixes the if condition in
i2c_mctp_cxl.c and dev-mctp.c to allow FMAPI DCD commands to be processed.

For more info, refer to previous thread from v2 of the FMAPI DCD patchset:
https://lore.kernel.org/linux-cxl/20250530152655.00007132@huawei.com/

Anisa Su (1):
  hw/cxl: Fix MCTP binding check

 hw/cxl/cxl-mailbox-utils.c   | 74 +-----------------------------------
 hw/cxl/i2c_mctp_cxl.c        |  6 ++-
 hw/usb/dev-mctp.c            |  6 ++-
 include/hw/cxl/cxl_mailbox.h | 73 +++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 77 deletions(-)

-- 
2.47.2



^ permalink raw reply	[flat|nested] 5+ messages in thread

* [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check
  2025-06-26 23:41 [HACK QEMU PATCH v1 0/1] CXL MCTP FMAPI Binding Fix for MCTP over i2c/USB anisa.su887
@ 2025-06-26 23:41 ` anisa.su887
  2025-06-27  9:48   ` Jonathan Cameron via
  0 siblings, 1 reply; 5+ messages in thread
From: anisa.su887 @ 2025-06-26 23:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: Jonathan.Cameron, nifan.cxl, dave, linux-cxl, Anisa Su

From: Anisa Su <anisa.su@samsung.com>

Per the spec, FMAPI commands (0x51-0x59) must be bound with
MCTP_MT_CXL_FMAPI. Fix the conditions ensuring this in i2c_mctp_cxl.c
and dev-mctp.c

Move the opcode enum from cxl-mailbox-utils.c to cxl_mailbox.h to
allow i2c_mctp_cxl.c and dev-mctp.c to use the enum instead of
hardcoding the values.

Signed-off-by: Anisa Su <anisa.su@samsung.com>
---
 hw/cxl/cxl-mailbox-utils.c   | 74 +-----------------------------------
 hw/cxl/i2c_mctp_cxl.c        |  6 ++-
 hw/usb/dev-mctp.c            |  6 ++-
 include/hw/cxl/cxl_mailbox.h | 73 +++++++++++++++++++++++++++++++++++
 4 files changed, 82 insertions(+), 77 deletions(-)

diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
index 4c01b25110..7f84e147f7 100644
--- a/hw/cxl/cxl-mailbox-utils.c
+++ b/hw/cxl/cxl-mailbox-utils.c
@@ -37,7 +37,7 @@
 
 /*
  * How to add a new command, example. The command set FOO, with cmd BAR.
- *  1. Add the command set and cmd to the enum.
+ *  1. Add the command set and cmd to the enum in cxl_mailbox.h.
  *     FOO    = 0x7f,
  *          #define BAR 0
  *  2. Implement the handler
@@ -60,78 +60,6 @@
  *  a register interface that already deals with it.
  */
 
-enum {
-    INFOSTAT    = 0x00,
-        #define IS_IDENTIFY   0x1
-        #define BACKGROUND_OPERATION_STATUS    0x2
-        #define GET_RESPONSE_MSG_LIMIT         0x3
-        #define SET_RESPONSE_MSG_LIMIT         0x4
-        #define BACKGROUND_OPERATION_ABORT     0x5
-    EVENTS      = 0x01,
-        #define GET_RECORDS   0x0
-        #define CLEAR_RECORDS   0x1
-        #define GET_INTERRUPT_POLICY   0x2
-        #define SET_INTERRUPT_POLICY   0x3
-    FIRMWARE_UPDATE = 0x02,
-        #define GET_INFO      0x0
-        #define TRANSFER      0x1
-        #define ACTIVATE      0x2
-    TIMESTAMP   = 0x03,
-        #define GET           0x0
-        #define SET           0x1
-    LOGS        = 0x04,
-        #define GET_SUPPORTED 0x0
-        #define GET_LOG       0x1
-        #define GET_LOG_CAPABILITIES   0x2
-        #define CLEAR_LOG     0x3
-        #define POPULATE_LOG  0x4
-    FEATURES    = 0x05,
-        #define GET_SUPPORTED 0x0
-        #define GET_FEATURE   0x1
-        #define SET_FEATURE   0x2
-    IDENTIFY    = 0x40,
-        #define MEMORY_DEVICE 0x0
-    CCLS        = 0x41,
-        #define GET_PARTITION_INFO     0x0
-        #define GET_LSA       0x2
-        #define SET_LSA       0x3
-    HEALTH_INFO_ALERTS = 0x42,
-        #define GET_ALERT_CONFIG 0x1
-        #define SET_ALERT_CONFIG 0x2
-    SANITIZE    = 0x44,
-        #define OVERWRITE     0x0
-        #define SECURE_ERASE  0x1
-        #define MEDIA_OPERATIONS 0x2
-    PERSISTENT_MEM = 0x45,
-        #define GET_SECURITY_STATE     0x0
-    MEDIA_AND_POISON = 0x43,
-        #define GET_POISON_LIST        0x0
-        #define INJECT_POISON          0x1
-        #define CLEAR_POISON           0x2
-        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
-        #define SCAN_MEDIA             0x4
-        #define GET_SCAN_MEDIA_RESULTS 0x5
-    DCD_CONFIG  = 0x48,
-        #define GET_DC_CONFIG          0x0
-        #define GET_DYN_CAP_EXT_LIST   0x1
-        #define ADD_DYN_CAP_RSP        0x2
-        #define RELEASE_DYN_CAP        0x3
-    PHYSICAL_SWITCH = 0x51,
-        #define IDENTIFY_SWITCH_DEVICE      0x0
-        #define GET_PHYSICAL_PORT_STATE     0x1
-    TUNNEL = 0x53,
-        #define MANAGEMENT_COMMAND     0x0
-    MHD = 0x55,
-        #define GET_MHD_INFO 0x0
-    FMAPI_DCD_MGMT = 0x56,
-        #define GET_DCD_INFO    0x0
-        #define GET_HOST_DC_REGION_CONFIG   0x1
-        #define SET_DC_REGION_CONFIG        0x2
-        #define GET_DC_REGION_EXTENT_LIST   0x3
-        #define INITIATE_DC_ADD             0x4
-        #define INITIATE_DC_RELEASE         0x5
-};
-
 /* CCI Message Format CXL r3.1 Figure 7-19 */
 typedef struct CXLCCIMessage {
     uint8_t category;
diff --git a/hw/cxl/i2c_mctp_cxl.c b/hw/cxl/i2c_mctp_cxl.c
index 1714f36e8e..3f17779562 100644
--- a/hw/cxl/i2c_mctp_cxl.c
+++ b/hw/cxl/i2c_mctp_cxl.c
@@ -29,6 +29,7 @@
 #include "hw/pci/pcie_port.h"
 #include "hw/qdev-properties.h"
 #include "hw/registerfields.h"
+#include "hw/cxl/cxl_mailbox.h"
 
 #define TYPE_I2C_MCTP_CXL "i2c_mctp_cxl"
 
@@ -198,9 +199,10 @@ static void i2c_mctp_cxl_handle_message(MCTPI2CEndpoint *mctp)
          */
 
         if (!(msg->message_type == MCTP_MT_CXL_TYPE3 &&
-              msg->command_set < 0x51) &&
+              msg->command_set < PHYSICAL_SWITCH) &&
             !(msg->message_type == MCTP_MT_CXL_FMAPI &&
-              msg->command_set >= 0x51 && msg->command_set < 0x56)) {
+              msg->command_set >= PHYSICAL_SWITCH &&
+              msg->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
             buf->rc = CXL_MBOX_UNSUPPORTED;
             st24_le_p(buf->pl_length, len_out);
             s->len = s->pos;
diff --git a/hw/usb/dev-mctp.c b/hw/usb/dev-mctp.c
index aafb9e7e96..b82a269561 100644
--- a/hw/usb/dev-mctp.c
+++ b/hw/usb/dev-mctp.c
@@ -25,6 +25,7 @@
 #include "hw/usb.h"
 #include "hw/usb/desc.h"
 #include "net/mctp.h"
+#include "hw/cxl/cxl_mailbox.h"
 
 /* TODO: Move to header */
 
@@ -504,9 +505,10 @@ static void usb_cxl_mctp_handle_data(USBDevice *dev, USBPacket *p)
          * onwards.
          */
         if (!(req->message_type == MCTP_MT_CXL_TYPE3 &&
-              req->command_set < 0x51) &&
+              req->command_set < PHYSICAL_SWITCH) &&
             !(req->message_type == MCTP_MT_CXL_FMAPI &&
-              req->command_set >= 0x51 && req->command_set < 0x56)) {
+              req->command_set >= PHYSICAL_SWITCH &&
+              req->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
             len_out = 0;
             usb_pkt_len = sizeof(MCTPUSBPacket) + sizeof(CXLMCTPMessage) +
                 len_out;
diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h
index 820c411cbb..209a11ecbc 100644
--- a/include/hw/cxl/cxl_mailbox.h
+++ b/include/hw/cxl/cxl_mailbox.h
@@ -27,4 +27,77 @@
 #define CXL_LOG_CAP_AUTO_POPULATE_SUPPORTED (1 << 2)
 #define CXL_LOG_CAP_PERSISTENT_COLD_RESET_SUPPORTED (1 << 3)
 
+enum {
+    INFOSTAT    = 0x00,
+        #define IS_IDENTIFY   0x1
+        #define BACKGROUND_OPERATION_STATUS    0x2
+        #define GET_RESPONSE_MSG_LIMIT         0x3
+        #define SET_RESPONSE_MSG_LIMIT         0x4
+        #define BACKGROUND_OPERATION_ABORT     0x5
+    EVENTS      = 0x01,
+        #define GET_RECORDS   0x0
+        #define CLEAR_RECORDS   0x1
+        #define GET_INTERRUPT_POLICY   0x2
+        #define SET_INTERRUPT_POLICY   0x3
+    FIRMWARE_UPDATE = 0x02,
+        #define GET_INFO      0x0
+        #define TRANSFER      0x1
+        #define ACTIVATE      0x2
+    TIMESTAMP   = 0x03,
+        #define GET           0x0
+        #define SET           0x1
+    LOGS        = 0x04,
+        #define GET_SUPPORTED 0x0
+        #define GET_LOG       0x1
+        #define GET_LOG_CAPABILITIES   0x2
+        #define CLEAR_LOG     0x3
+        #define POPULATE_LOG  0x4
+    FEATURES    = 0x05,
+        #define GET_SUPPORTED 0x0
+        #define GET_FEATURE   0x1
+        #define SET_FEATURE   0x2
+    IDENTIFY    = 0x40,
+        #define MEMORY_DEVICE 0x0
+    CCLS        = 0x41,
+        #define GET_PARTITION_INFO     0x0
+        #define GET_LSA       0x2
+        #define SET_LSA       0x3
+    HEALTH_INFO_ALERTS = 0x42,
+        #define GET_ALERT_CONFIG 0x1
+        #define SET_ALERT_CONFIG 0x2
+    SANITIZE    = 0x44,
+        #define OVERWRITE     0x0
+        #define SECURE_ERASE  0x1
+        #define MEDIA_OPERATIONS 0x2
+    PERSISTENT_MEM = 0x45,
+        #define GET_SECURITY_STATE     0x0
+    MEDIA_AND_POISON = 0x43,
+        #define GET_POISON_LIST        0x0
+        #define INJECT_POISON          0x1
+        #define CLEAR_POISON           0x2
+        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
+        #define SCAN_MEDIA             0x4
+        #define GET_SCAN_MEDIA_RESULTS 0x5
+    DCD_CONFIG  = 0x48,
+        #define GET_DC_CONFIG          0x0
+        #define GET_DYN_CAP_EXT_LIST   0x1
+        #define ADD_DYN_CAP_RSP        0x2
+        #define RELEASE_DYN_CAP        0x3
+    PHYSICAL_SWITCH = 0x51,
+        #define IDENTIFY_SWITCH_DEVICE      0x0
+        #define GET_PHYSICAL_PORT_STATE     0x1
+    TUNNEL = 0x53,
+        #define MANAGEMENT_COMMAND     0x0
+    MHD = 0x55,
+        #define GET_MHD_INFO 0x0
+    FMAPI_DCD_MGMT = 0x56,
+        #define GET_DCD_INFO    0x0
+        #define GET_HOST_DC_REGION_CONFIG   0x1
+        #define SET_DC_REGION_CONFIG        0x2
+        #define GET_DC_REGION_EXTENT_LIST   0x3
+        #define INITIATE_DC_ADD             0x4
+        #define INITIATE_DC_RELEASE         0x5
+    GLOBAL_MEM_ACCESS_EP_MGMT = 0X59,
+};
+
 #endif
-- 
2.47.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check
  2025-06-26 23:41 ` [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check anisa.su887
@ 2025-06-27  9:48   ` Jonathan Cameron via
  2025-06-27 16:38     ` Anisa Su
  0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron via @ 2025-06-27  9:48 UTC (permalink / raw)
  To: anisa.su887; +Cc: qemu-devel, nifan.cxl, dave, linux-cxl, Anisa Su

On Thu, 26 Jun 2025 23:41:15 +0000
anisa.su887@gmail.com wrote:

> From: Anisa Su <anisa.su@samsung.com>
> 
> Per the spec, FMAPI commands (0x51-0x59) must be bound with
> MCTP_MT_CXL_FMAPI. Fix the conditions ensuring this in i2c_mctp_cxl.c
> and dev-mctp.c
> 
> Move the opcode enum from cxl-mailbox-utils.c to cxl_mailbox.h to
> allow i2c_mctp_cxl.c and dev-mctp.c to use the enum instead of
> hardcoding the values.
> 
> Signed-off-by: Anisa Su <anisa.su@samsung.com>
Why HACK in the patch title?

In general this seems reasonable - the complexity is how I merge it
into my tree given the code being modified slips in at various different
points. I'll sort that out though.

Jonathan

> ---
>  hw/cxl/cxl-mailbox-utils.c   | 74 +-----------------------------------
>  hw/cxl/i2c_mctp_cxl.c        |  6 ++-
>  hw/usb/dev-mctp.c            |  6 ++-
>  include/hw/cxl/cxl_mailbox.h | 73 +++++++++++++++++++++++++++++++++++
>  4 files changed, 82 insertions(+), 77 deletions(-)
> 
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index 4c01b25110..7f84e147f7 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -37,7 +37,7 @@
>  
>  /*
>   * How to add a new command, example. The command set FOO, with cmd BAR.
> - *  1. Add the command set and cmd to the enum.
> + *  1. Add the command set and cmd to the enum in cxl_mailbox.h.
>   *     FOO    = 0x7f,
>   *          #define BAR 0
>   *  2. Implement the handler
> @@ -60,78 +60,6 @@
>   *  a register interface that already deals with it.
>   */
>  
> -enum {
> -    INFOSTAT    = 0x00,
> -        #define IS_IDENTIFY   0x1
> -        #define BACKGROUND_OPERATION_STATUS    0x2
> -        #define GET_RESPONSE_MSG_LIMIT         0x3
> -        #define SET_RESPONSE_MSG_LIMIT         0x4
> -        #define BACKGROUND_OPERATION_ABORT     0x5
> -    EVENTS      = 0x01,
> -        #define GET_RECORDS   0x0
> -        #define CLEAR_RECORDS   0x1
> -        #define GET_INTERRUPT_POLICY   0x2
> -        #define SET_INTERRUPT_POLICY   0x3
> -    FIRMWARE_UPDATE = 0x02,
> -        #define GET_INFO      0x0
> -        #define TRANSFER      0x1
> -        #define ACTIVATE      0x2
> -    TIMESTAMP   = 0x03,
> -        #define GET           0x0
> -        #define SET           0x1
> -    LOGS        = 0x04,
> -        #define GET_SUPPORTED 0x0
> -        #define GET_LOG       0x1
> -        #define GET_LOG_CAPABILITIES   0x2
> -        #define CLEAR_LOG     0x3
> -        #define POPULATE_LOG  0x4
> -    FEATURES    = 0x05,
> -        #define GET_SUPPORTED 0x0
> -        #define GET_FEATURE   0x1
> -        #define SET_FEATURE   0x2
> -    IDENTIFY    = 0x40,
> -        #define MEMORY_DEVICE 0x0
> -    CCLS        = 0x41,
> -        #define GET_PARTITION_INFO     0x0
> -        #define GET_LSA       0x2
> -        #define SET_LSA       0x3
> -    HEALTH_INFO_ALERTS = 0x42,
> -        #define GET_ALERT_CONFIG 0x1
> -        #define SET_ALERT_CONFIG 0x2
> -    SANITIZE    = 0x44,
> -        #define OVERWRITE     0x0
> -        #define SECURE_ERASE  0x1
> -        #define MEDIA_OPERATIONS 0x2
> -    PERSISTENT_MEM = 0x45,
> -        #define GET_SECURITY_STATE     0x0
> -    MEDIA_AND_POISON = 0x43,
> -        #define GET_POISON_LIST        0x0
> -        #define INJECT_POISON          0x1
> -        #define CLEAR_POISON           0x2
> -        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
> -        #define SCAN_MEDIA             0x4
> -        #define GET_SCAN_MEDIA_RESULTS 0x5
> -    DCD_CONFIG  = 0x48,
> -        #define GET_DC_CONFIG          0x0
> -        #define GET_DYN_CAP_EXT_LIST   0x1
> -        #define ADD_DYN_CAP_RSP        0x2
> -        #define RELEASE_DYN_CAP        0x3
> -    PHYSICAL_SWITCH = 0x51,
> -        #define IDENTIFY_SWITCH_DEVICE      0x0
> -        #define GET_PHYSICAL_PORT_STATE     0x1
> -    TUNNEL = 0x53,
> -        #define MANAGEMENT_COMMAND     0x0
> -    MHD = 0x55,
> -        #define GET_MHD_INFO 0x0
> -    FMAPI_DCD_MGMT = 0x56,
> -        #define GET_DCD_INFO    0x0
> -        #define GET_HOST_DC_REGION_CONFIG   0x1
> -        #define SET_DC_REGION_CONFIG        0x2
> -        #define GET_DC_REGION_EXTENT_LIST   0x3
> -        #define INITIATE_DC_ADD             0x4
> -        #define INITIATE_DC_RELEASE         0x5
> -};
> -
>  /* CCI Message Format CXL r3.1 Figure 7-19 */
>  typedef struct CXLCCIMessage {
>      uint8_t category;
> diff --git a/hw/cxl/i2c_mctp_cxl.c b/hw/cxl/i2c_mctp_cxl.c
> index 1714f36e8e..3f17779562 100644
> --- a/hw/cxl/i2c_mctp_cxl.c
> +++ b/hw/cxl/i2c_mctp_cxl.c
> @@ -29,6 +29,7 @@
>  #include "hw/pci/pcie_port.h"
>  #include "hw/qdev-properties.h"
>  #include "hw/registerfields.h"
> +#include "hw/cxl/cxl_mailbox.h"
>  
>  #define TYPE_I2C_MCTP_CXL "i2c_mctp_cxl"
>  
> @@ -198,9 +199,10 @@ static void i2c_mctp_cxl_handle_message(MCTPI2CEndpoint *mctp)
>           */
>  
>          if (!(msg->message_type == MCTP_MT_CXL_TYPE3 &&
> -              msg->command_set < 0x51) &&
> +              msg->command_set < PHYSICAL_SWITCH) &&
>              !(msg->message_type == MCTP_MT_CXL_FMAPI &&
> -              msg->command_set >= 0x51 && msg->command_set < 0x56)) {
> +              msg->command_set >= PHYSICAL_SWITCH &&
> +              msg->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
>              buf->rc = CXL_MBOX_UNSUPPORTED;
>              st24_le_p(buf->pl_length, len_out);
>              s->len = s->pos;
> diff --git a/hw/usb/dev-mctp.c b/hw/usb/dev-mctp.c
> index aafb9e7e96..b82a269561 100644
> --- a/hw/usb/dev-mctp.c
> +++ b/hw/usb/dev-mctp.c
> @@ -25,6 +25,7 @@
>  #include "hw/usb.h"
>  #include "hw/usb/desc.h"
>  #include "net/mctp.h"
> +#include "hw/cxl/cxl_mailbox.h"
>  
>  /* TODO: Move to header */
>  
> @@ -504,9 +505,10 @@ static void usb_cxl_mctp_handle_data(USBDevice *dev, USBPacket *p)
>           * onwards.
>           */
>          if (!(req->message_type == MCTP_MT_CXL_TYPE3 &&
> -              req->command_set < 0x51) &&
> +              req->command_set < PHYSICAL_SWITCH) &&
>              !(req->message_type == MCTP_MT_CXL_FMAPI &&
> -              req->command_set >= 0x51 && req->command_set < 0x56)) {
> +              req->command_set >= PHYSICAL_SWITCH &&
> +              req->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
>              len_out = 0;
>              usb_pkt_len = sizeof(MCTPUSBPacket) + sizeof(CXLMCTPMessage) +
>                  len_out;
> diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h
> index 820c411cbb..209a11ecbc 100644
> --- a/include/hw/cxl/cxl_mailbox.h
> +++ b/include/hw/cxl/cxl_mailbox.h
> @@ -27,4 +27,77 @@
>  #define CXL_LOG_CAP_AUTO_POPULATE_SUPPORTED (1 << 2)
>  #define CXL_LOG_CAP_PERSISTENT_COLD_RESET_SUPPORTED (1 << 3)
>  
> +enum {
> +    INFOSTAT    = 0x00,
> +        #define IS_IDENTIFY   0x1
> +        #define BACKGROUND_OPERATION_STATUS    0x2
> +        #define GET_RESPONSE_MSG_LIMIT         0x3
> +        #define SET_RESPONSE_MSG_LIMIT         0x4
> +        #define BACKGROUND_OPERATION_ABORT     0x5
> +    EVENTS      = 0x01,
> +        #define GET_RECORDS   0x0
> +        #define CLEAR_RECORDS   0x1
> +        #define GET_INTERRUPT_POLICY   0x2
> +        #define SET_INTERRUPT_POLICY   0x3
> +    FIRMWARE_UPDATE = 0x02,
> +        #define GET_INFO      0x0
> +        #define TRANSFER      0x1
> +        #define ACTIVATE      0x2
> +    TIMESTAMP   = 0x03,
> +        #define GET           0x0
> +        #define SET           0x1
> +    LOGS        = 0x04,
> +        #define GET_SUPPORTED 0x0
> +        #define GET_LOG       0x1
> +        #define GET_LOG_CAPABILITIES   0x2
> +        #define CLEAR_LOG     0x3
> +        #define POPULATE_LOG  0x4
> +    FEATURES    = 0x05,
> +        #define GET_SUPPORTED 0x0
> +        #define GET_FEATURE   0x1
> +        #define SET_FEATURE   0x2
> +    IDENTIFY    = 0x40,
> +        #define MEMORY_DEVICE 0x0
> +    CCLS        = 0x41,
> +        #define GET_PARTITION_INFO     0x0
> +        #define GET_LSA       0x2
> +        #define SET_LSA       0x3
> +    HEALTH_INFO_ALERTS = 0x42,
> +        #define GET_ALERT_CONFIG 0x1
> +        #define SET_ALERT_CONFIG 0x2
> +    SANITIZE    = 0x44,
> +        #define OVERWRITE     0x0
> +        #define SECURE_ERASE  0x1
> +        #define MEDIA_OPERATIONS 0x2
> +    PERSISTENT_MEM = 0x45,
> +        #define GET_SECURITY_STATE     0x0
> +    MEDIA_AND_POISON = 0x43,
> +        #define GET_POISON_LIST        0x0
> +        #define INJECT_POISON          0x1
> +        #define CLEAR_POISON           0x2
> +        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
> +        #define SCAN_MEDIA             0x4
> +        #define GET_SCAN_MEDIA_RESULTS 0x5
> +    DCD_CONFIG  = 0x48,
> +        #define GET_DC_CONFIG          0x0
> +        #define GET_DYN_CAP_EXT_LIST   0x1
> +        #define ADD_DYN_CAP_RSP        0x2
> +        #define RELEASE_DYN_CAP        0x3
> +    PHYSICAL_SWITCH = 0x51,
> +        #define IDENTIFY_SWITCH_DEVICE      0x0
> +        #define GET_PHYSICAL_PORT_STATE     0x1
> +    TUNNEL = 0x53,
> +        #define MANAGEMENT_COMMAND     0x0
> +    MHD = 0x55,
> +        #define GET_MHD_INFO 0x0
> +    FMAPI_DCD_MGMT = 0x56,
> +        #define GET_DCD_INFO    0x0
> +        #define GET_HOST_DC_REGION_CONFIG   0x1
> +        #define SET_DC_REGION_CONFIG        0x2
> +        #define GET_DC_REGION_EXTENT_LIST   0x3
> +        #define INITIATE_DC_ADD             0x4
> +        #define INITIATE_DC_RELEASE         0x5
> +    GLOBAL_MEM_ACCESS_EP_MGMT = 0X59,
> +};
> +
>  #endif



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check
  2025-06-27  9:48   ` Jonathan Cameron via
@ 2025-06-27 16:38     ` Anisa Su
  2025-06-30 17:24       ` Jonathan Cameron via
  0 siblings, 1 reply; 5+ messages in thread
From: Anisa Su @ 2025-06-27 16:38 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: anisa.su887, qemu-devel, nifan.cxl, dave, linux-cxl

On Fri, Jun 27, 2025 at 10:48:59AM +0100, Jonathan Cameron wrote:
> On Thu, 26 Jun 2025 23:41:15 +0000
> anisa.su887@gmail.com wrote:
> 
> > From: Anisa Su <anisa.su@samsung.com>
> > 
> > Per the spec, FMAPI commands (0x51-0x59) must be bound with
> > MCTP_MT_CXL_FMAPI. Fix the conditions ensuring this in i2c_mctp_cxl.c
> > and dev-mctp.c
> > 
> > Move the opcode enum from cxl-mailbox-utils.c to cxl_mailbox.h to
> > allow i2c_mctp_cxl.c and dev-mctp.c to use the enum instead of
> > hardcoding the values.
> > 
> > Signed-off-by: Anisa Su <anisa.su@samsung.com>
> Why HACK in the patch title?
> 
I guess this isn't really a hack but my intention was to make
it clear that this patch isn't intended for upstream. Seems like that
made things more confusing though, but now I know!

> In general this seems reasonable - the complexity is how I merge it
> into my tree given the code being modified slips in at various different
> points. I'll sort that out though.

I could also send you an alternate version of the FMAPI DCD Management patchset
based on this one?

> Jonathan
> 
> > ---
> >  hw/cxl/cxl-mailbox-utils.c   | 74 +-----------------------------------
> >  hw/cxl/i2c_mctp_cxl.c        |  6 ++-
> >  hw/usb/dev-mctp.c            |  6 ++-
> >  include/hw/cxl/cxl_mailbox.h | 73 +++++++++++++++++++++++++++++++++++
> >  4 files changed, 82 insertions(+), 77 deletions(-)
> > 
> > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> > index 4c01b25110..7f84e147f7 100644
> > --- a/hw/cxl/cxl-mailbox-utils.c
> > +++ b/hw/cxl/cxl-mailbox-utils.c
> > @@ -37,7 +37,7 @@
> >  
> >  /*
> >   * How to add a new command, example. The command set FOO, with cmd BAR.
> > - *  1. Add the command set and cmd to the enum.
> > + *  1. Add the command set and cmd to the enum in cxl_mailbox.h.
> >   *     FOO    = 0x7f,
> >   *          #define BAR 0
> >   *  2. Implement the handler
> > @@ -60,78 +60,6 @@
> >   *  a register interface that already deals with it.
> >   */
> >  
> > -enum {
> > -    INFOSTAT    = 0x00,
> > -        #define IS_IDENTIFY   0x1
> > -        #define BACKGROUND_OPERATION_STATUS    0x2
> > -        #define GET_RESPONSE_MSG_LIMIT         0x3
> > -        #define SET_RESPONSE_MSG_LIMIT         0x4
> > -        #define BACKGROUND_OPERATION_ABORT     0x5
> > -    EVENTS      = 0x01,
> > -        #define GET_RECORDS   0x0
> > -        #define CLEAR_RECORDS   0x1
> > -        #define GET_INTERRUPT_POLICY   0x2
> > -        #define SET_INTERRUPT_POLICY   0x3
> > -    FIRMWARE_UPDATE = 0x02,
> > -        #define GET_INFO      0x0
> > -        #define TRANSFER      0x1
> > -        #define ACTIVATE      0x2
> > -    TIMESTAMP   = 0x03,
> > -        #define GET           0x0
> > -        #define SET           0x1
> > -    LOGS        = 0x04,
> > -        #define GET_SUPPORTED 0x0
> > -        #define GET_LOG       0x1
> > -        #define GET_LOG_CAPABILITIES   0x2
> > -        #define CLEAR_LOG     0x3
> > -        #define POPULATE_LOG  0x4
> > -    FEATURES    = 0x05,
> > -        #define GET_SUPPORTED 0x0
> > -        #define GET_FEATURE   0x1
> > -        #define SET_FEATURE   0x2
> > -    IDENTIFY    = 0x40,
> > -        #define MEMORY_DEVICE 0x0
> > -    CCLS        = 0x41,
> > -        #define GET_PARTITION_INFO     0x0
> > -        #define GET_LSA       0x2
> > -        #define SET_LSA       0x3
> > -    HEALTH_INFO_ALERTS = 0x42,
> > -        #define GET_ALERT_CONFIG 0x1
> > -        #define SET_ALERT_CONFIG 0x2
> > -    SANITIZE    = 0x44,
> > -        #define OVERWRITE     0x0
> > -        #define SECURE_ERASE  0x1
> > -        #define MEDIA_OPERATIONS 0x2
> > -    PERSISTENT_MEM = 0x45,
> > -        #define GET_SECURITY_STATE     0x0
> > -    MEDIA_AND_POISON = 0x43,
> > -        #define GET_POISON_LIST        0x0
> > -        #define INJECT_POISON          0x1
> > -        #define CLEAR_POISON           0x2
> > -        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
> > -        #define SCAN_MEDIA             0x4
> > -        #define GET_SCAN_MEDIA_RESULTS 0x5
> > -    DCD_CONFIG  = 0x48,
> > -        #define GET_DC_CONFIG          0x0
> > -        #define GET_DYN_CAP_EXT_LIST   0x1
> > -        #define ADD_DYN_CAP_RSP        0x2
> > -        #define RELEASE_DYN_CAP        0x3
> > -    PHYSICAL_SWITCH = 0x51,
> > -        #define IDENTIFY_SWITCH_DEVICE      0x0
> > -        #define GET_PHYSICAL_PORT_STATE     0x1
> > -    TUNNEL = 0x53,
> > -        #define MANAGEMENT_COMMAND     0x0
> > -    MHD = 0x55,
> > -        #define GET_MHD_INFO 0x0
> > -    FMAPI_DCD_MGMT = 0x56,
> > -        #define GET_DCD_INFO    0x0
> > -        #define GET_HOST_DC_REGION_CONFIG   0x1
> > -        #define SET_DC_REGION_CONFIG        0x2
> > -        #define GET_DC_REGION_EXTENT_LIST   0x3
> > -        #define INITIATE_DC_ADD             0x4
> > -        #define INITIATE_DC_RELEASE         0x5
> > -};
> > -
> >  /* CCI Message Format CXL r3.1 Figure 7-19 */
> >  typedef struct CXLCCIMessage {
> >      uint8_t category;
> > diff --git a/hw/cxl/i2c_mctp_cxl.c b/hw/cxl/i2c_mctp_cxl.c
> > index 1714f36e8e..3f17779562 100644
> > --- a/hw/cxl/i2c_mctp_cxl.c
> > +++ b/hw/cxl/i2c_mctp_cxl.c
> > @@ -29,6 +29,7 @@
> >  #include "hw/pci/pcie_port.h"
> >  #include "hw/qdev-properties.h"
> >  #include "hw/registerfields.h"
> > +#include "hw/cxl/cxl_mailbox.h"
> >  
> >  #define TYPE_I2C_MCTP_CXL "i2c_mctp_cxl"
> >  
> > @@ -198,9 +199,10 @@ static void i2c_mctp_cxl_handle_message(MCTPI2CEndpoint *mctp)
> >           */
> >  
> >          if (!(msg->message_type == MCTP_MT_CXL_TYPE3 &&
> > -              msg->command_set < 0x51) &&
> > +              msg->command_set < PHYSICAL_SWITCH) &&
> >              !(msg->message_type == MCTP_MT_CXL_FMAPI &&
> > -              msg->command_set >= 0x51 && msg->command_set < 0x56)) {
> > +              msg->command_set >= PHYSICAL_SWITCH &&
> > +              msg->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
> >              buf->rc = CXL_MBOX_UNSUPPORTED;
> >              st24_le_p(buf->pl_length, len_out);
> >              s->len = s->pos;
> > diff --git a/hw/usb/dev-mctp.c b/hw/usb/dev-mctp.c
> > index aafb9e7e96..b82a269561 100644
> > --- a/hw/usb/dev-mctp.c
> > +++ b/hw/usb/dev-mctp.c
> > @@ -25,6 +25,7 @@
> >  #include "hw/usb.h"
> >  #include "hw/usb/desc.h"
> >  #include "net/mctp.h"
> > +#include "hw/cxl/cxl_mailbox.h"
> >  
> >  /* TODO: Move to header */
> >  
> > @@ -504,9 +505,10 @@ static void usb_cxl_mctp_handle_data(USBDevice *dev, USBPacket *p)
> >           * onwards.
> >           */
> >          if (!(req->message_type == MCTP_MT_CXL_TYPE3 &&
> > -              req->command_set < 0x51) &&
> > +              req->command_set < PHYSICAL_SWITCH) &&
> >              !(req->message_type == MCTP_MT_CXL_FMAPI &&
> > -              req->command_set >= 0x51 && req->command_set < 0x56)) {
> > +              req->command_set >= PHYSICAL_SWITCH &&
> > +              req->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
> >              len_out = 0;
> >              usb_pkt_len = sizeof(MCTPUSBPacket) + sizeof(CXLMCTPMessage) +
> >                  len_out;
> > diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h
> > index 820c411cbb..209a11ecbc 100644
> > --- a/include/hw/cxl/cxl_mailbox.h
> > +++ b/include/hw/cxl/cxl_mailbox.h
> > @@ -27,4 +27,77 @@
> >  #define CXL_LOG_CAP_AUTO_POPULATE_SUPPORTED (1 << 2)
> >  #define CXL_LOG_CAP_PERSISTENT_COLD_RESET_SUPPORTED (1 << 3)
> >  
> > +enum {
> > +    INFOSTAT    = 0x00,
> > +        #define IS_IDENTIFY   0x1
> > +        #define BACKGROUND_OPERATION_STATUS    0x2
> > +        #define GET_RESPONSE_MSG_LIMIT         0x3
> > +        #define SET_RESPONSE_MSG_LIMIT         0x4
> > +        #define BACKGROUND_OPERATION_ABORT     0x5
> > +    EVENTS      = 0x01,
> > +        #define GET_RECORDS   0x0
> > +        #define CLEAR_RECORDS   0x1
> > +        #define GET_INTERRUPT_POLICY   0x2
> > +        #define SET_INTERRUPT_POLICY   0x3
> > +    FIRMWARE_UPDATE = 0x02,
> > +        #define GET_INFO      0x0
> > +        #define TRANSFER      0x1
> > +        #define ACTIVATE      0x2
> > +    TIMESTAMP   = 0x03,
> > +        #define GET           0x0
> > +        #define SET           0x1
> > +    LOGS        = 0x04,
> > +        #define GET_SUPPORTED 0x0
> > +        #define GET_LOG       0x1
> > +        #define GET_LOG_CAPABILITIES   0x2
> > +        #define CLEAR_LOG     0x3
> > +        #define POPULATE_LOG  0x4
> > +    FEATURES    = 0x05,
> > +        #define GET_SUPPORTED 0x0
> > +        #define GET_FEATURE   0x1
> > +        #define SET_FEATURE   0x2
> > +    IDENTIFY    = 0x40,
> > +        #define MEMORY_DEVICE 0x0
> > +    CCLS        = 0x41,
> > +        #define GET_PARTITION_INFO     0x0
> > +        #define GET_LSA       0x2
> > +        #define SET_LSA       0x3
> > +    HEALTH_INFO_ALERTS = 0x42,
> > +        #define GET_ALERT_CONFIG 0x1
> > +        #define SET_ALERT_CONFIG 0x2
> > +    SANITIZE    = 0x44,
> > +        #define OVERWRITE     0x0
> > +        #define SECURE_ERASE  0x1
> > +        #define MEDIA_OPERATIONS 0x2
> > +    PERSISTENT_MEM = 0x45,
> > +        #define GET_SECURITY_STATE     0x0
> > +    MEDIA_AND_POISON = 0x43,
> > +        #define GET_POISON_LIST        0x0
> > +        #define INJECT_POISON          0x1
> > +        #define CLEAR_POISON           0x2
> > +        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
> > +        #define SCAN_MEDIA             0x4
> > +        #define GET_SCAN_MEDIA_RESULTS 0x5
> > +    DCD_CONFIG  = 0x48,
> > +        #define GET_DC_CONFIG          0x0
> > +        #define GET_DYN_CAP_EXT_LIST   0x1
> > +        #define ADD_DYN_CAP_RSP        0x2
> > +        #define RELEASE_DYN_CAP        0x3
> > +    PHYSICAL_SWITCH = 0x51,
> > +        #define IDENTIFY_SWITCH_DEVICE      0x0
> > +        #define GET_PHYSICAL_PORT_STATE     0x1
> > +    TUNNEL = 0x53,
> > +        #define MANAGEMENT_COMMAND     0x0
> > +    MHD = 0x55,
> > +        #define GET_MHD_INFO 0x0
> > +    FMAPI_DCD_MGMT = 0x56,
> > +        #define GET_DCD_INFO    0x0
> > +        #define GET_HOST_DC_REGION_CONFIG   0x1
> > +        #define SET_DC_REGION_CONFIG        0x2
> > +        #define GET_DC_REGION_EXTENT_LIST   0x3
> > +        #define INITIATE_DC_ADD             0x4
> > +        #define INITIATE_DC_RELEASE         0x5
> > +    GLOBAL_MEM_ACCESS_EP_MGMT = 0X59,
> > +};
> > +
> >  #endif
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check
  2025-06-27 16:38     ` Anisa Su
@ 2025-06-30 17:24       ` Jonathan Cameron via
  0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron via @ 2025-06-30 17:24 UTC (permalink / raw)
  To: Anisa Su; +Cc: qemu-devel, nifan.cxl, dave, linux-cxl

On Fri, 27 Jun 2025 16:38:16 +0000
Anisa Su <anisa.su887@gmail.com> wrote:

> On Fri, Jun 27, 2025 at 10:48:59AM +0100, Jonathan Cameron wrote:
> > On Thu, 26 Jun 2025 23:41:15 +0000
> > anisa.su887@gmail.com wrote:
> >   
> > > From: Anisa Su <anisa.su@samsung.com>
> > > 
> > > Per the spec, FMAPI commands (0x51-0x59) must be bound with
> > > MCTP_MT_CXL_FMAPI. Fix the conditions ensuring this in i2c_mctp_cxl.c
> > > and dev-mctp.c
> > > 
> > > Move the opcode enum from cxl-mailbox-utils.c to cxl_mailbox.h to
> > > allow i2c_mctp_cxl.c and dev-mctp.c to use the enum instead of
> > > hardcoding the values.
> > > 
> > > Signed-off-by: Anisa Su <anisa.su@samsung.com>  
> > Why HACK in the patch title?
> >   
> I guess this isn't really a hack but my intention was to make
> it clear that this patch isn't intended for upstream. Seems like that
> made things more confusing though, but now I know!
> 
> > In general this seems reasonable - the complexity is how I merge it
> > into my tree given the code being modified slips in at various different
> > points. I'll sort that out though.  
> 
> I could also send you an alternate version of the FMAPI DCD Management patchset
> based on this one?

No need. I've queued the DCD series up way ahead of where this makes sense.
I'll tweak this into a precursor patch doing the move and then squash the other
bits into the two mctp implementations.

Jonathan

> 
> > Jonathan
> >   
> > > ---
> > >  hw/cxl/cxl-mailbox-utils.c   | 74 +-----------------------------------
> > >  hw/cxl/i2c_mctp_cxl.c        |  6 ++-
> > >  hw/usb/dev-mctp.c            |  6 ++-
> > >  include/hw/cxl/cxl_mailbox.h | 73 +++++++++++++++++++++++++++++++++++
> > >  4 files changed, 82 insertions(+), 77 deletions(-)
> > > 
> > > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> > > index 4c01b25110..7f84e147f7 100644
> > > --- a/hw/cxl/cxl-mailbox-utils.c
> > > +++ b/hw/cxl/cxl-mailbox-utils.c
> > > @@ -37,7 +37,7 @@
> > >  
> > >  /*
> > >   * How to add a new command, example. The command set FOO, with cmd BAR.
> > > - *  1. Add the command set and cmd to the enum.
> > > + *  1. Add the command set and cmd to the enum in cxl_mailbox.h.
> > >   *     FOO    = 0x7f,
> > >   *          #define BAR 0
> > >   *  2. Implement the handler
> > > @@ -60,78 +60,6 @@
> > >   *  a register interface that already deals with it.
> > >   */
> > >  
> > > -enum {
> > > -    INFOSTAT    = 0x00,
> > > -        #define IS_IDENTIFY   0x1
> > > -        #define BACKGROUND_OPERATION_STATUS    0x2
> > > -        #define GET_RESPONSE_MSG_LIMIT         0x3
> > > -        #define SET_RESPONSE_MSG_LIMIT         0x4
> > > -        #define BACKGROUND_OPERATION_ABORT     0x5
> > > -    EVENTS      = 0x01,
> > > -        #define GET_RECORDS   0x0
> > > -        #define CLEAR_RECORDS   0x1
> > > -        #define GET_INTERRUPT_POLICY   0x2
> > > -        #define SET_INTERRUPT_POLICY   0x3
> > > -    FIRMWARE_UPDATE = 0x02,
> > > -        #define GET_INFO      0x0
> > > -        #define TRANSFER      0x1
> > > -        #define ACTIVATE      0x2
> > > -    TIMESTAMP   = 0x03,
> > > -        #define GET           0x0
> > > -        #define SET           0x1
> > > -    LOGS        = 0x04,
> > > -        #define GET_SUPPORTED 0x0
> > > -        #define GET_LOG       0x1
> > > -        #define GET_LOG_CAPABILITIES   0x2
> > > -        #define CLEAR_LOG     0x3
> > > -        #define POPULATE_LOG  0x4
> > > -    FEATURES    = 0x05,
> > > -        #define GET_SUPPORTED 0x0
> > > -        #define GET_FEATURE   0x1
> > > -        #define SET_FEATURE   0x2
> > > -    IDENTIFY    = 0x40,
> > > -        #define MEMORY_DEVICE 0x0
> > > -    CCLS        = 0x41,
> > > -        #define GET_PARTITION_INFO     0x0
> > > -        #define GET_LSA       0x2
> > > -        #define SET_LSA       0x3
> > > -    HEALTH_INFO_ALERTS = 0x42,
> > > -        #define GET_ALERT_CONFIG 0x1
> > > -        #define SET_ALERT_CONFIG 0x2
> > > -    SANITIZE    = 0x44,
> > > -        #define OVERWRITE     0x0
> > > -        #define SECURE_ERASE  0x1
> > > -        #define MEDIA_OPERATIONS 0x2
> > > -    PERSISTENT_MEM = 0x45,
> > > -        #define GET_SECURITY_STATE     0x0
> > > -    MEDIA_AND_POISON = 0x43,
> > > -        #define GET_POISON_LIST        0x0
> > > -        #define INJECT_POISON          0x1
> > > -        #define CLEAR_POISON           0x2
> > > -        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
> > > -        #define SCAN_MEDIA             0x4
> > > -        #define GET_SCAN_MEDIA_RESULTS 0x5
> > > -    DCD_CONFIG  = 0x48,
> > > -        #define GET_DC_CONFIG          0x0
> > > -        #define GET_DYN_CAP_EXT_LIST   0x1
> > > -        #define ADD_DYN_CAP_RSP        0x2
> > > -        #define RELEASE_DYN_CAP        0x3
> > > -    PHYSICAL_SWITCH = 0x51,
> > > -        #define IDENTIFY_SWITCH_DEVICE      0x0
> > > -        #define GET_PHYSICAL_PORT_STATE     0x1
> > > -    TUNNEL = 0x53,
> > > -        #define MANAGEMENT_COMMAND     0x0
> > > -    MHD = 0x55,
> > > -        #define GET_MHD_INFO 0x0
> > > -    FMAPI_DCD_MGMT = 0x56,
> > > -        #define GET_DCD_INFO    0x0
> > > -        #define GET_HOST_DC_REGION_CONFIG   0x1
> > > -        #define SET_DC_REGION_CONFIG        0x2
> > > -        #define GET_DC_REGION_EXTENT_LIST   0x3
> > > -        #define INITIATE_DC_ADD             0x4
> > > -        #define INITIATE_DC_RELEASE         0x5
> > > -};
> > > -
> > >  /* CCI Message Format CXL r3.1 Figure 7-19 */
> > >  typedef struct CXLCCIMessage {
> > >      uint8_t category;
> > > diff --git a/hw/cxl/i2c_mctp_cxl.c b/hw/cxl/i2c_mctp_cxl.c
> > > index 1714f36e8e..3f17779562 100644
> > > --- a/hw/cxl/i2c_mctp_cxl.c
> > > +++ b/hw/cxl/i2c_mctp_cxl.c
> > > @@ -29,6 +29,7 @@
> > >  #include "hw/pci/pcie_port.h"
> > >  #include "hw/qdev-properties.h"
> > >  #include "hw/registerfields.h"
> > > +#include "hw/cxl/cxl_mailbox.h"
> > >  
> > >  #define TYPE_I2C_MCTP_CXL "i2c_mctp_cxl"
> > >  
> > > @@ -198,9 +199,10 @@ static void i2c_mctp_cxl_handle_message(MCTPI2CEndpoint *mctp)
> > >           */
> > >  
> > >          if (!(msg->message_type == MCTP_MT_CXL_TYPE3 &&
> > > -              msg->command_set < 0x51) &&
> > > +              msg->command_set < PHYSICAL_SWITCH) &&
> > >              !(msg->message_type == MCTP_MT_CXL_FMAPI &&
> > > -              msg->command_set >= 0x51 && msg->command_set < 0x56)) {
> > > +              msg->command_set >= PHYSICAL_SWITCH &&
> > > +              msg->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
> > >              buf->rc = CXL_MBOX_UNSUPPORTED;
> > >              st24_le_p(buf->pl_length, len_out);
> > >              s->len = s->pos;
> > > diff --git a/hw/usb/dev-mctp.c b/hw/usb/dev-mctp.c
> > > index aafb9e7e96..b82a269561 100644
> > > --- a/hw/usb/dev-mctp.c
> > > +++ b/hw/usb/dev-mctp.c
> > > @@ -25,6 +25,7 @@
> > >  #include "hw/usb.h"
> > >  #include "hw/usb/desc.h"
> > >  #include "net/mctp.h"
> > > +#include "hw/cxl/cxl_mailbox.h"
> > >  
> > >  /* TODO: Move to header */
> > >  
> > > @@ -504,9 +505,10 @@ static void usb_cxl_mctp_handle_data(USBDevice *dev, USBPacket *p)
> > >           * onwards.
> > >           */
> > >          if (!(req->message_type == MCTP_MT_CXL_TYPE3 &&
> > > -              req->command_set < 0x51) &&
> > > +              req->command_set < PHYSICAL_SWITCH) &&
> > >              !(req->message_type == MCTP_MT_CXL_FMAPI &&
> > > -              req->command_set >= 0x51 && req->command_set < 0x56)) {
> > > +              req->command_set >= PHYSICAL_SWITCH &&
> > > +              req->command_set < GLOBAL_MEM_ACCESS_EP_MGMT)) {
> > >              len_out = 0;
> > >              usb_pkt_len = sizeof(MCTPUSBPacket) + sizeof(CXLMCTPMessage) +
> > >                  len_out;
> > > diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h
> > > index 820c411cbb..209a11ecbc 100644
> > > --- a/include/hw/cxl/cxl_mailbox.h
> > > +++ b/include/hw/cxl/cxl_mailbox.h
> > > @@ -27,4 +27,77 @@
> > >  #define CXL_LOG_CAP_AUTO_POPULATE_SUPPORTED (1 << 2)
> > >  #define CXL_LOG_CAP_PERSISTENT_COLD_RESET_SUPPORTED (1 << 3)
> > >  
> > > +enum {
> > > +    INFOSTAT    = 0x00,
> > > +        #define IS_IDENTIFY   0x1
> > > +        #define BACKGROUND_OPERATION_STATUS    0x2
> > > +        #define GET_RESPONSE_MSG_LIMIT         0x3
> > > +        #define SET_RESPONSE_MSG_LIMIT         0x4
> > > +        #define BACKGROUND_OPERATION_ABORT     0x5
> > > +    EVENTS      = 0x01,
> > > +        #define GET_RECORDS   0x0
> > > +        #define CLEAR_RECORDS   0x1
> > > +        #define GET_INTERRUPT_POLICY   0x2
> > > +        #define SET_INTERRUPT_POLICY   0x3
> > > +    FIRMWARE_UPDATE = 0x02,
> > > +        #define GET_INFO      0x0
> > > +        #define TRANSFER      0x1
> > > +        #define ACTIVATE      0x2
> > > +    TIMESTAMP   = 0x03,
> > > +        #define GET           0x0
> > > +        #define SET           0x1
> > > +    LOGS        = 0x04,
> > > +        #define GET_SUPPORTED 0x0
> > > +        #define GET_LOG       0x1
> > > +        #define GET_LOG_CAPABILITIES   0x2
> > > +        #define CLEAR_LOG     0x3
> > > +        #define POPULATE_LOG  0x4
> > > +    FEATURES    = 0x05,
> > > +        #define GET_SUPPORTED 0x0
> > > +        #define GET_FEATURE   0x1
> > > +        #define SET_FEATURE   0x2
> > > +    IDENTIFY    = 0x40,
> > > +        #define MEMORY_DEVICE 0x0
> > > +    CCLS        = 0x41,
> > > +        #define GET_PARTITION_INFO     0x0
> > > +        #define GET_LSA       0x2
> > > +        #define SET_LSA       0x3
> > > +    HEALTH_INFO_ALERTS = 0x42,
> > > +        #define GET_ALERT_CONFIG 0x1
> > > +        #define SET_ALERT_CONFIG 0x2
> > > +    SANITIZE    = 0x44,
> > > +        #define OVERWRITE     0x0
> > > +        #define SECURE_ERASE  0x1
> > > +        #define MEDIA_OPERATIONS 0x2
> > > +    PERSISTENT_MEM = 0x45,
> > > +        #define GET_SECURITY_STATE     0x0
> > > +    MEDIA_AND_POISON = 0x43,
> > > +        #define GET_POISON_LIST        0x0
> > > +        #define INJECT_POISON          0x1
> > > +        #define CLEAR_POISON           0x2
> > > +        #define GET_SCAN_MEDIA_CAPABILITIES 0x3
> > > +        #define SCAN_MEDIA             0x4
> > > +        #define GET_SCAN_MEDIA_RESULTS 0x5
> > > +    DCD_CONFIG  = 0x48,
> > > +        #define GET_DC_CONFIG          0x0
> > > +        #define GET_DYN_CAP_EXT_LIST   0x1
> > > +        #define ADD_DYN_CAP_RSP        0x2
> > > +        #define RELEASE_DYN_CAP        0x3
> > > +    PHYSICAL_SWITCH = 0x51,
> > > +        #define IDENTIFY_SWITCH_DEVICE      0x0
> > > +        #define GET_PHYSICAL_PORT_STATE     0x1
> > > +    TUNNEL = 0x53,
> > > +        #define MANAGEMENT_COMMAND     0x0
> > > +    MHD = 0x55,
> > > +        #define GET_MHD_INFO 0x0
> > > +    FMAPI_DCD_MGMT = 0x56,
> > > +        #define GET_DCD_INFO    0x0
> > > +        #define GET_HOST_DC_REGION_CONFIG   0x1
> > > +        #define SET_DC_REGION_CONFIG        0x2
> > > +        #define GET_DC_REGION_EXTENT_LIST   0x3
> > > +        #define INITIATE_DC_ADD             0x4
> > > +        #define INITIATE_DC_RELEASE         0x5
> > > +    GLOBAL_MEM_ACCESS_EP_MGMT = 0X59,
> > > +};
> > > +
> > >  #endif  
> >   



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-30 17:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 23:41 [HACK QEMU PATCH v1 0/1] CXL MCTP FMAPI Binding Fix for MCTP over i2c/USB anisa.su887
2025-06-26 23:41 ` [HACK QEMU PATCH v1 1/1] hw/cxl: Fix MCTP Binding Check anisa.su887
2025-06-27  9:48   ` Jonathan Cameron via
2025-06-27 16:38     ` Anisa Su
2025-06-30 17:24       ` Jonathan Cameron via

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).