From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: linux-cxl@vger.kernel.org, qemu-devel@nongnu.org,
linuxarm@huawei.com, fan.ni@samsung.com,
Yuquan Wang <wangyuquan1236@phytium.com.cn>,
Arpit Kumar <arpit1.kumar@samsung.com>,
Sweta Kumari <s5.kumari@samsung.com>,
Vinayak Holikatti <vinayak.kh@samsung.com>,
Davidlohr Bueso <dave@stgolabs.net>,
Ajay Joshi <ajay.opensrc@micron.com>
Subject: Re: [PATCH qemu 7/8] hw/cxl/cxl-mailbox-utils: Added support for Get Log Capabilities (Opcode 0402h)
Date: Mon, 12 May 2025 09:37:07 -0400 [thread overview]
Message-ID: <20250512093638-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20250512043011-mutt-send-email-mst@kernel.org>
On Mon, May 12, 2025 at 04:42:41AM -0400, Michael S. Tsirkin wrote:
> On Wed, Mar 05, 2025 at 09:24:58AM +0000, Jonathan Cameron wrote:
> > From: Arpit Kumar <arpit1.kumar@samsung.com>
> >
> > CXL spec 3.2 section 8.2.10.5.3 describes Get Log Capabilities.
> > It provides log capabilities supported by specified log.
> >
> > Signed-off-by: Arpit Kumar <arpit1.kumar@samsung.com>
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > ---
> > include/hw/cxl/cxl_device.h | 20 ++++++++++++++++
> > include/hw/cxl/cxl_mailbox.h | 5 ++++
> > hw/cxl/cxl-mailbox-utils.c | 45 ++++++++++++++++++++++++++++++++++++
> > 3 files changed, 70 insertions(+)
> >
> > diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h
> > index ed6cd50c67..87a376c982 100644
> > --- a/include/hw/cxl/cxl_device.h
> > +++ b/include/hw/cxl/cxl_device.h
> > @@ -133,6 +133,18 @@ typedef enum {
> > CXL_MBOX_MAX = 0x20
> > } CXLRetCode;
> >
> > +/* types of logs */
> > +typedef enum {
> > + CXL_LOG_COMMAND_EFFECT,
> > + CXL_LOG_VENDOR_DEBUG,
> > + CXL_LOG_COMPONENT_STATE_DUMP,
> > + CXL_LOG_ERROR_CHECK_SCRUB,
> > + CXL_LOG_MEDIA_TEST_CAPABILITY,
> > + CXL_LOG_MEDIA_TEST_RESULTS_SHORT,
> > + CXL_LOG_MEDIA_TEST_RESULTS_LONG,
> > + MAX_LOG_TYPE
> > +} CXLLogType;
> > +
> > typedef struct CXLCCI CXLCCI;
> > typedef struct cxl_device_state CXLDeviceState;
> > struct cxl_cmd;
> > @@ -163,6 +175,11 @@ typedef struct CXLEventLog {
> > QSIMPLEQ_HEAD(, CXLEvent) events;
> > } CXLEventLog;
> >
> > +typedef struct CXLLogCapabilities {
> > + uint32_t param_flags;
> > + QemuUUID uuid;
> > +} CXLLogCapabilities;
> > +
> > typedef struct CXLCCI {
> > struct cxl_cmd cxl_cmd_set[256][256];
> > struct cel_log {
> > @@ -171,6 +188,9 @@ typedef struct CXLCCI {
> > } cel_log[1 << 16];
> > size_t cel_size;
> >
> > + /* get log capabilities */
> > + const CXLLogCapabilities *supported_log_cap;
> > +
> > /* background command handling (times in ms) */
> > struct {
> > uint16_t opcode;
> > diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h
> > index 9008402d1c..8e1c7c5f15 100644
> > --- a/include/hw/cxl/cxl_mailbox.h
> > +++ b/include/hw/cxl/cxl_mailbox.h
> > @@ -16,4 +16,9 @@
> > #define CXL_MBOX_BACKGROUND_OPERATION (1 << 6)
> > #define CXL_MBOX_BACKGROUND_OPERATION_ABORT (1 << 7)
> >
> > +#define CXL_LOG_CAP_CLEAR_SUPPORTED (1 << 0)
> > +#define CXL_LOG_CAP_POPULATE_SUPPORTED (1 << 1)
> > +#define CXL_LOG_CAP_AUTO_POPULATE_SUPPORTED (1 << 2)
> > +#define CXL_LOG_CAP_PERSISTENT_COLD_RESET_SUPPORTED (1 << 3)
> > +
> > #endif
> > diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> > index 299f232f26..f35fc4f112 100644
> > --- a/hw/cxl/cxl-mailbox-utils.c
> > +++ b/hw/cxl/cxl-mailbox-utils.c
> > @@ -81,6 +81,7 @@ enum {
> > LOGS = 0x04,
> > #define GET_SUPPORTED 0x0
> > #define GET_LOG 0x1
> > + #define GET_LOG_CAPABILITIES 0x2
> > FEATURES = 0x05,
> > #define GET_SUPPORTED 0x0
> > #define GET_FEATURE 0x1
> > @@ -1068,6 +1069,43 @@ static CXLRetCode cmd_logs_get_log(const struct cxl_cmd *cmd,
> > return CXL_MBOX_SUCCESS;
> > }
> >
> > +static const struct CXLLogCapabilities *find_log_index(QemuUUID *uuid, CXLCCI *cci)
> > +{
> > + for (int i = CXL_LOG_COMMAND_EFFECT; i < MAX_LOG_TYPE; i++) {
> > + if (qemu_uuid_is_equal(uuid,
> > + &cci->supported_log_cap[i].uuid)) {
> > + return &cci->supported_log_cap[i];
> > + }
> > + }
> > + return NULL;
> > +}
> > +
> > +/* CXL r3.2 Section 8.2.10.5.3: Get Log Capabilities (Opcode 0402h) */
> > +static CXLRetCode cmd_logs_get_log_capabilities(const struct cxl_cmd *cmd,
> > + uint8_t *payload_in,
> > + size_t len_in,
> > + uint8_t *payload_out,
> > + size_t *len_out,
> > + CXLCCI *cci)
> > +{
> > + const CXLLogCapabilities *cap;
> > + struct {
> > + QemuUUID uuid;
> > + } QEMU_PACKED QEMU_ALIGNED(8) *get_log_capabilities_in = (void *)payload_in;
> > +
> > + uint32_t *get_log_capabilities_out = (uint32_t *)payload_out;
> > +
> > + cap = find_log_index(&get_log_capabilities_in->uuid, cci);
> > + if (!cap) {
> > + return CXL_MBOX_INVALID_LOG;
> > + }
> > +
> > + memcpy(get_log_capabilities_out, &cap->param_flags,
> > + sizeof(cap->param_flags));
> > + *len_out = sizeof(*get_log_capabilities_out);
> > + return CXL_MBOX_SUCCESS;
> > +}
> > +
> > /* CXL r3.1 section 8.2.9.6: Features */
> > /*
> > * Get Supported Features output payload
> > @@ -3253,6 +3291,8 @@ static const struct cxl_cmd cxl_cmd_set[256][256] = {
> > [LOGS][GET_SUPPORTED] = { "LOGS_GET_SUPPORTED", cmd_logs_get_supported,
> > 0, 0 },
> > [LOGS][GET_LOG] = { "LOGS_GET_LOG", cmd_logs_get_log, 0x18, 0 },
> > + [LOGS][GET_LOG_CAPABILITIES] = { "LOGS_GET_LOG_CAPABILITIES",
> > + cmd_logs_get_log_capabilities, 0x10, 0 },
> > [FEATURES][GET_SUPPORTED] = { "FEATURES_GET_SUPPORTED",
> > cmd_features_get_supported, 0x8, 0 },
> > [FEATURES][GET_FEATURE] = { "FEATURES_GET_FEATURE",
> > @@ -3512,10 +3552,15 @@ static void cxl_rebuild_cel(CXLCCI *cci)
> > }
> > }
> >
> > +static const struct CXLLogCapabilities cxl_get_log_cap[MAX_LOG_TYPE] = {
> > + [CXL_LOG_COMMAND_EFFECT] = { .param_flags = 0, .uuid = cel_uuid },
> > +};
> > +
>
>
> causes ci build failures:
>
> https://gitlab.com/mstredhat/qemu/-/jobs/9999980051
>
> ../hw/cxl/cxl-mailbox-utils.c:3556:60: error: initializer element is not constant
> [CXL_LOG_COMMAND_EFFECT] = { .param_flags = 0, .uuid = cel_uuid },
> ^~~~~~~~
> ../hw/cxl/cxl-mailbox-utils.c:3556:60: note: (near initialization for ‘cxl_get_log_cap[0].uuid’)
>
>
> Fixed it up like this:
>
> diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c
> index f35fc4f112..13d26e391b 100644
> --- a/hw/cxl/cxl-mailbox-utils.c
> +++ b/hw/cxl/cxl-mailbox-utils.c
> @@ -992,9 +992,10 @@ static CXLRetCode cmd_timestamp_set(const struct cxl_cmd *cmd,
> }
>
> /* CXL r3.1 Section 8.2.9.5.2.1: Command Effects Log (CEL) */
> -static const QemuUUID cel_uuid = {
> - .data = UUID(0x0da9c0b5, 0xbf41, 0x4b78, 0x8f, 0x79,
> +#define CEL_UUID UUID(0x0da9c0b5, 0xbf41, 0x4b78, 0x8f, 0x79, \
> 0x96, 0xb1, 0x62, 0x3b, 0x3f, 0x17)
> +static const QemuUUID cel_uuid = {
> + .data = CEL_UUID
> };
>
> /* CXL r3.1 Section 8.2.9.5.1: Get Supported Logs (Opcode 0400h) */
> @@ -3553,7 +3554,7 @@ static void cxl_rebuild_cel(CXLCCI *cci)
> }
>
> static const struct CXLLogCapabilities cxl_get_log_cap[MAX_LOG_TYPE] = {
> - [CXL_LOG_COMMAND_EFFECT] = { .param_flags = 0, .uuid = cel_uuid },
> + [CXL_LOG_COMMAND_EFFECT] = { .param_flags = 0, .uuid = CEL_UUID },
> };
>
> void cxl_init_cci(CXLCCI *cci, size_t payload_max)
>
Actually no, does not help either. Dropped for now.
Next patch does not depend on this one, right?
> > void cxl_init_cci(CXLCCI *cci, size_t payload_max)
> > {
> > cci->payload_max = payload_max;
> > cxl_rebuild_cel(cci);
> > + cci->supported_log_cap = cxl_get_log_cap;
> >
> > cci->bg.complete_pct = 0;
> > cci->bg.starttime = 0;
> > --
> > 2.43.0
next prev parent reply other threads:[~2025-05-12 13:37 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-05 9:24 [PATCH qemu 0/8] hw/cxl: new features for 10.0 (possibly) Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 1/8] hw/cxl: Support aborting background commands Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 2/8] hw/cxl: Support get/set mctp response payload size Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 3/8] hw/cxl/cxl-mailbox-utils: Add support for Media operations discovery commands cxl r3.2 (8.2.10.9.5.3) Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 4/8] hw/cxl: factor out calculation of sanitize duration from cmd_santize_overwrite Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 5/8] hw/cxl/cxl-mailbox-utils: Media operations Sanitize and Write Zeros commands CXL r3.2(8.2.10.9.5.3) Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 6/8] hw/cxl/cxl-mailbox-utils: CXL CCI Get/Set alert config commands Jonathan Cameron via
2025-03-05 9:24 ` [PATCH qemu 7/8] hw/cxl/cxl-mailbox-utils: Added support for Get Log Capabilities (Opcode 0402h) Jonathan Cameron via
2025-05-12 8:42 ` Michael S. Tsirkin
2025-05-12 10:14 ` Jonathan Cameron via
2025-05-12 13:37 ` Michael S. Tsirkin [this message]
2025-05-12 16:40 ` Jonathan Cameron via
[not found] ` <CGME20250516134255epcas5p378dda7fbda7db62fe73cc6163c5e7043@epcas5p3.samsung.com>
2025-05-16 13:42 ` Arpit Kumar
2025-05-28 12:31 ` Jonathan Cameron via
2025-05-28 12:38 ` Jonathan Cameron via
2025-05-29 11:45 ` Arpit Kumar
2025-03-05 9:24 ` [PATCH qemu 8/8] docs/cxl: Add serial number for persistent-memdev Jonathan Cameron via
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250512093638-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=ajay.opensrc@micron.com \
--cc=arpit1.kumar@samsung.com \
--cc=dave@stgolabs.net \
--cc=fan.ni@samsung.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=s5.kumari@samsung.com \
--cc=vinayak.kh@samsung.com \
--cc=wangyuquan1236@phytium.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).