From nobody Mon Nov 25 09:42:59 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716486682; cv=none; d=zohomail.com; s=zohoarc; b=WdfbjHEkUVK0mz/bg+bAU0ndlf7q4S4KoeYoCWum7qHVRjoeU6voxscj0Wosg7J/75jEqrARHdwGU9zSpPW3rUkx0iiqEVo0xTvMELfpfbeR2e9WM5z6PpdY9KOLYywPP5ULh7Xg5lt79vFlSeeHCoAttA8i8ioy+Vn0nLaYSiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716486682; h=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:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sUY+tVIrLXlBWDYAZLBMIzgstxLzMinOnAd95xKbspQ=; b=jMyY+BAcCx8yADcuucGeFojym77jq8mjzCwJRf5tl+itwoznpdt7ZOfeWymj/ozU4GrW9mXujPfmrn4mVMkP4NeTGald4RSx2WIKSTHDsN4v0xRPYSv66CNYVyblReiM2RIQK8z5drmQGSx7MTB23L6aMVF2DpBPKcvcZXcQysg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1716486682029426.2162204910477; Thu, 23 May 2024 10:51:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sACZ6-00069A-HU; Thu, 23 May 2024 13:49:20 -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 1sACYh-0005wz-TQ for qemu-devel@nongnu.org; Thu, 23 May 2024 13:49:02 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sACYT-0003e1-Nh for qemu-devel@nongnu.org; Thu, 23 May 2024 13:48:47 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1f2ecea41deso118211815ad.1 for ; Thu, 23 May 2024 10:48:40 -0700 (PDT) Received: from localhost.localdomain ([2601:646:8f03:9fee:4f9e:216e:ed5a:642d]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c137e7esm253436265ad.257.2024.05.23.10.48.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 10:48:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716486519; x=1717091319; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sUY+tVIrLXlBWDYAZLBMIzgstxLzMinOnAd95xKbspQ=; b=lNnosEGQJm4g6YCEo9UHHvg4wxzOxIWXviyMqt8/VXfDeayg4wYPbIKzgVVvrbhg5F BSnsCOd1pVOJ5cwBRvpUC4WU0vvdSGyp9VbUj+e6LfJ4f3rkPV1GwVWs/aDUFigGMSNO pezxRGv6aSxNBb5mfrp33GORCl4+0vMI7RNgQG1ROHuPgVubmkYYBIDmuV+4uZOzMP8V J1Of04rHmmTXTnSKOZVmo9Ebw+E0Iiqdu3/gmyrVykhhhJl0OyhLe8Ew+vxdpmEf1TeS T6bv+rzDWQiyw5aMCrcN1dt+jEtw5SrK/arJ31fhqoOM5kMG3+P7LL2eQ7JH3EGiK9ac V95Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716486519; x=1717091319; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sUY+tVIrLXlBWDYAZLBMIzgstxLzMinOnAd95xKbspQ=; b=oWyzxfJTtlqBJvzRuegeTObiU9m+S54H+B+rVy2bI4n02EvkJ6TRNDR13xBNeBISus ff0hzMV+KTyYU+b2U7sxDvaKkxYYu7vVHGosrETKNV5uMRRIEu/3lmt9M8SwCT4kpGgi DUAm28XdgkijrksCJwP4/Z2yIWIbWVszpLf38lGil7ExkreYp0Rd/XiFw9/0pArj1t0t xg7ba4SQX4Pa2JWfCp+CwRbMFEMFMf2gl00OHx8uYRIWLtlv1qFjyiGT4uyJxDOAi7rE efIM+V/SyuNrOl9wTh9Ty6UZdFudRhk84rwOHOm/2gXaj9qBBhWDdwOz9Z9y9JAvYaPu n7CQ== X-Gm-Message-State: AOJu0YxxASrwZGj2/hTePV0BF8RS6Ixy1JYDT2Y/AFy0EIZGC/486nYQ Tf+udyWdOHCs6S9ADcGNSwGNQbwkMtfxKvgKG6QIuZqLl6QXJ/0stiDYCQ== X-Google-Smtp-Source: AGHT+IFf20NX3YEVB79xFwOa3YX1k2qEZb8NgiEQW9xioF3Hrc65GPKe5k6j4CXoBHvaPjkpWIscPA== X-Received: by 2002:a17:903:22c6:b0:1ec:e3c2:790e with SMTP id d9443c01a7336-1f4486fe183mr792505ad.19.1716486519218; Thu, 23 May 2024 10:48:39 -0700 (PDT) From: nifan.cxl@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, linux-cxl@vger.kernel.org, gregory.price@memverge.com, ira.weiny@intel.com, dan.j.williams@intel.com, a.manzanares@samsung.com, dave@stgolabs.net, nmtadam.samsung@gmail.com, nifan.cxl@gmail.com, jim.harris@samsung.com, Jorgen.Hansen@wdc.com, wj28.lee@gmail.com, armbru@redhat.com, mst@redhat.com, Gregory Price , Jonathan Cameron , Fan Ni Subject: [PATCH v8 01/14] hw/cxl/mailbox: change CCI cmd set structure to be a member, not a reference Date: Thu, 23 May 2024 10:44:41 -0700 Message-ID: <20240523174651.1089554-2-nifan.cxl@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240523174651.1089554-1-nifan.cxl@gmail.com> References: <20240523174651.1089554-1-nifan.cxl@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=2607:f8b0:4864:20::62c; envelope-from=nifan.cxl@gmail.com; helo=mail-pl1-x62c.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716486682975100003 Content-Type: text/plain; charset="utf-8" From: Gregory Price This allows devices to have fully customized CCIs, along with complex devices where wrapper devices can override or add additional CCI commands without having to replicate full command structures or pollute a base device with every command that might ever be used. Signed-off-by: Gregory Price Signed-off-by: Jonathan Cameron Signed-off-by: Fan Ni --- hw/cxl/cxl-mailbox-utils.c | 19 +++++++++++++++---- include/hw/cxl/cxl_device.h | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e5eb97cb91..2c9f50f0f9 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1447,10 +1447,21 @@ void cxl_init_cci(CXLCCI *cci, size_t payload_max) bg_timercb, cci); } =20 +static void cxl_copy_cci_commands(CXLCCI *cci, const struct cxl_cmd (*cxl_= cmds)[256]) +{ + for (int set =3D 0; set < 256; set++) { + for (int cmd =3D 0; cmd < 256; cmd++) { + if (cxl_cmds[set][cmd].handler) { + cci->cxl_cmd_set[set][cmd] =3D cxl_cmds[set][cmd]; + } + } + } +} + void cxl_initialize_mailbox_swcci(CXLCCI *cci, DeviceState *intf, DeviceState *d, size_t payload_max) { - cci->cxl_cmd_set =3D cxl_cmd_set_sw; + cxl_copy_cci_commands(cci, cxl_cmd_set_sw); cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); @@ -1458,7 +1469,7 @@ void cxl_initialize_mailbox_swcci(CXLCCI *cci, Device= State *intf, =20 void cxl_initialize_mailbox_t3(CXLCCI *cci, DeviceState *d, size_t payload= _max) { - cci->cxl_cmd_set =3D cxl_cmd_set; + cxl_copy_cci_commands(cci, cxl_cmd_set); cci->d =3D d; =20 /* No separation for PCI MB as protocol handled in PCI device */ @@ -1476,7 +1487,7 @@ static const struct cxl_cmd cxl_cmd_set_t3_ld[256][25= 6] =3D { void cxl_initialize_t3_ld_cci(CXLCCI *cci, DeviceState *d, DeviceState *in= tf, size_t payload_max) { - cci->cxl_cmd_set =3D cxl_cmd_set_t3_ld; + cxl_copy_cci_commands(cci, cxl_cmd_set_t3_ld); cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); @@ -1496,7 +1507,7 @@ void cxl_initialize_t3_fm_owned_ld_mctpcci(CXLCCI *cc= i, DeviceState *d, DeviceState *intf, size_t payload_max) { - cci->cxl_cmd_set =3D cxl_cmd_set_t3_fm_owned_ld_mctp; + cxl_copy_cci_commands(cci, cxl_cmd_set_t3_fm_owned_ld_mctp); cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 279b276bda..ccc4611875 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -164,7 +164,7 @@ typedef struct CXLEventLog { } CXLEventLog; =20 typedef struct CXLCCI { - const struct cxl_cmd (*cxl_cmd_set)[256]; + struct cxl_cmd cxl_cmd_set[256][256]; struct cel_log { uint16_t opcode; uint16_t effect; --=20 2.43.0