From nobody Sat Nov 15 12:50:00 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1752519840; cv=none; d=zohomail.com; s=zohoarc; b=SZnPpAwGF+9CDhZ3UZ7bfn33DBg68kj+slAKQIyKN7PP2lyvRI6uPvzqdSy6UdBjoLgjwrGhoawfZKBfO7ULd9MZs+D2p1xI1Mo9OA/sFPCctmWSqMeSTcLZ+FnV1w8fcBC9DS/M+GvDEAFoPw9Oh+2FIHxEAXKRwcugKigu4mE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752519840; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=iPJYxsKHwmIVukJmjRhn1BHjXFRKPjE38Fp/cNrSjCg=; b=mH1tecPbsevtczPv+qgN7+DNvxk2j3x9irPdQjQcDjr54iBfvY3KrEslFjCxDq+dbUJdLBa5bihhkLMScOwZzi6FrWYuBigX6O6gf6ub3fvN2GviwHXPR3Sh3QLdD2LGWDIsP1um1CJqV45bM4ARmwqF2qdDfQHShs6hmz9EEkU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1752519839953246.77134692572565; Mon, 14 Jul 2025 12:03:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ubOSp-0005Fh-OO; Mon, 14 Jul 2025 15:03:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubNIn-0002XN-Hb for qemu-devel@nongnu.org; Mon, 14 Jul 2025 13:49:31 -0400 Received: from [185.176.79.56] (helo=frasgout.his.huawei.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ubNIl-00080u-L4 for qemu-devel@nongnu.org; Mon, 14 Jul 2025 13:49:21 -0400 Received: from mail.maildlp.com (unknown [172.18.186.31]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4bgqY85R1mz6L4sY; Tue, 15 Jul 2025 01:48:12 +0800 (CST) Received: from frapeml500008.china.huawei.com (unknown [7.182.85.71]) by mail.maildlp.com (Postfix) with ESMTPS id E2F64140142; Tue, 15 Jul 2025 01:49:17 +0800 (CST) Received: from SecurePC-101-06.china.huawei.com (10.122.19.247) by frapeml500008.china.huawei.com (7.182.85.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Mon, 14 Jul 2025 19:49:17 +0200 To: , Michael Tsirkin , Fan Ni , Anisa Su , Anisa Su CC: , Subject: [PATCH qemu v2 08/11] hw/cxl: mailbox-utils: 0x5603 - FMAPI Get DC Region Extent Lists Date: Mon, 14 Jul 2025 18:45:04 +0100 Message-ID: <20250714174509.1984430-9-Jonathan.Cameron@huawei.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250714174509.1984430-1-Jonathan.Cameron@huawei.com> References: <20250714174509.1984430-1-Jonathan.Cameron@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.122.19.247] X-ClientProxiedBy: lhrpeml100011.china.huawei.com (7.191.174.247) To frapeml500008.china.huawei.com (7.182.85.71) X-Host-Lookup-Failed: Reverse DNS lookup failed for 185.176.79.56 (deferred) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=185.176.79.56; envelope-from=jonathan.cameron@huawei.com; helo=frasgout.his.huawei.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Jonathan Cameron From: Jonathan Cameron via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1752519842414116600 Content-Type: text/plain; charset="utf-8" From: Anisa Su FM DCD Management command 0x5603 implemented per CXL r3.2 Spec Section 7.6.= 7.6.4 Very similar to previously implemented command 0x4801. Reviewed-by: Fan Ni Signed-off-by: Anisa Su Signed-off-by: Jonathan Cameron --- v2 for merge: - Added a missing : in a comment similar to Fan feedback on a later patch. --- hw/cxl/cxl-mailbox-utils.c | 76 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index b4a0f7d664..4b0fdbbdd8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -123,6 +123,7 @@ enum { #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 }; =20 /* CCI Message Format CXL r3.1 Figure 7-19 */ @@ -3470,6 +3471,79 @@ static CXLRetCode cmd_fm_set_dc_region_config(const = struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* CXL r3.2 section 7.6.7.6.4: Get DC Region Extent Lists (Opcode 5603h) */ +static CXLRetCode cmd_fm_get_dc_region_extent_list(const struct cxl_cmd *c= md, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint16_t host_id; + uint8_t rsvd[2]; + uint32_t extent_cnt; + uint32_t start_extent_id; + } QEMU_PACKED *in =3D (void *)payload_in; + struct { + uint16_t host_id; + uint8_t rsvd[2]; + uint32_t start_extent_id; + uint32_t extents_returned; + uint32_t total_extents; + uint32_t list_generation_num; + uint8_t rsvd2[4]; + CXLDCExtentRaw records[]; + } QEMU_PACKED *out =3D (void *)payload_out; + QEMU_BUILD_BUG_ON(sizeof(*in) !=3D 0xc); + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDCExtent *ent; + CXLDCExtentRaw *out_rec; + uint16_t record_count =3D 0, record_done =3D 0, i =3D 0; + uint16_t out_pl_len, max_size; + + if (in->host_id !=3D 0) { + return CXL_MBOX_INVALID_INPUT; + } + + if (in->start_extent_id > ct3d->dc.nr_extents_accepted) { + return CXL_MBOX_INVALID_INPUT; + } + + record_count =3D MIN(in->extent_cnt, + ct3d->dc.nr_extents_accepted - in->start_extent_id); + max_size =3D CXL_MAILBOX_MAX_PAYLOAD_SIZE - sizeof(*out); + record_count =3D MIN(record_count, max_size / sizeof(out->records[0])); + out_pl_len =3D sizeof(*out) + record_count * sizeof(out->records[0]); + + stw_le_p(&out->host_id, in->host_id); + stl_le_p(&out->start_extent_id, in->start_extent_id); + stl_le_p(&out->extents_returned, record_count); + stl_le_p(&out->total_extents, ct3d->dc.nr_extents_accepted); + stl_le_p(&out->list_generation_num, ct3d->dc.ext_list_gen_seq); + + if (record_count > 0) { + QTAILQ_FOREACH(ent, &ct3d->dc.extents, node) { + if (i++ < in->start_extent_id) { + continue; + } + out_rec =3D &out->records[record_done]; + stq_le_p(&out_rec->start_dpa, ent->start_dpa); + stq_le_p(&out_rec->len, ent->len); + memcpy(&out_rec->tag, ent->tag, 0x10); + stw_le_p(&out_rec->shared_seq, ent->shared_seq); + + record_done++; + if (record_done =3D=3D record_count) { + break; + } + } + } + + *len_out =3D out_pl_len; + return CXL_MBOX_SUCCESS; +} + static const struct cxl_cmd cxl_cmd_set[256][256] =3D { [INFOSTAT][BACKGROUND_OPERATION_ABORT] =3D { "BACKGROUND_OPERATION_ABO= RT", cmd_infostat_bg_op_abort, 0, 0 }, @@ -3595,6 +3669,8 @@ static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][2= 56] =3D { CXL_MBOX_CONFIG_CHANGE_CXL_RESET | CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | CXL_MBOX_IMMEDIATE_DATA_CHANGE) }, + [FMAPI_DCD_MGMT][GET_DC_REGION_EXTENT_LIST] =3D { "GET_DC_REGION_EXTEN= T_LIST", + cmd_fm_get_dc_region_extent_list, 12, 0 }, }; =20 /* --=20 2.48.1