From nobody Thu Apr 3 10:07:06 2025 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=1742240948; cv=none; d=zohomail.com; s=zohoarc; b=iqrEY0K2hBdtxGB84Nor2oSkVR+38e8NoQwhyqetWQZc42ISFJGrrS3EqKkRgotDNArvMw46a/WoW/Zocp4CpHq9aaDOepfLelyamE6Udzw20ZCW6QtoTKR/hwHT9AK5waYGSqlZKth3SWDfs+y2YUDx1+519vJN8uFKEmVvhPQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240948; 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=LAaLVmqu9E16HyMGv9eV8vHzoQlr4XWZ3Yj3gmP1ZVU=; b=I0KbTbTYy9w/1mzEPX/yjzPQw73BZHeM31FxVbEJCYi/H25LesF2ARJaHJzi+hD4ZkDXAeagbDYH6I1XDBu0LN8pLsuu5uruuDSizQ1kiU1n105tF0l2SdsSBcEWnIp61S67p7a8MH85nGOy0SpZxFR0ugoNAqTC9Xeufxvo+FM= 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 1742240948216680.9050259812473; Mon, 17 Mar 2025 12:49:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGSB-0007bl-0G; Mon, 17 Mar 2025 15:48:51 -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 1tuDZ3-0003Ur-P6 for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:43:51 -0400 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDYr-0001Be-U0 for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:43:44 -0400 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-225477548e1so80024915ad.0 for ; Mon, 17 Mar 2025 09:43:30 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229808; x=1742834608; 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=LAaLVmqu9E16HyMGv9eV8vHzoQlr4XWZ3Yj3gmP1ZVU=; b=G2fY61TKjFhlx9zRjKMU3eNArzLb10QGCZ7cr91UAjhLKWqKrc7Ll3p2e+c9NKQ77W sE8AxDPbq7v/wu7dpWlsbEKReei4wVJkgfScTXQcNEYiOahA2OV0Ui3TH1TZEeNLM4DP aTBOLEHOeOtAsKd5/N49Kxf9BD2qp6uR5SDxvuoE3wohFTbdUg81Vp9CE6H+Kfiyns8a q+/uBB8t8iGoaMNTjURqW+eUXF1ACT02bp7RNSJAXi4/xvZCsBMhFCM0wGz2nnSw8mvL afyH5AjyAvLMmxGFCODS4NHlqEogwbpCSawyHhvp0n/fdpnRbXkZkLVQ9NvLIk930vh0 DzEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229808; x=1742834608; 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=LAaLVmqu9E16HyMGv9eV8vHzoQlr4XWZ3Yj3gmP1ZVU=; b=aZje9iXaz8JCkPB6t8zJz0R0/SmSNFSR2cFkeJ7ru0EllOY7VfxacTwwDNjTUUENgc Mm7OVmhNSy16t6k3YP1K06id/BVytksN9Lyxy3E2soTK2sJ1lT7SGVgDBXE8kZ3/xj6k XgGqAtz4ewUHVUjD6BoSoDmIvfdivrIWl1e4gXR/A3O8ZaxFNs86enWO3AbYDPHADfcc M/T+2bxdJsSDN0CIs0lHSd5VTgA4gPDonFy1vkT76t2JKPIHmZ2SYFz6IuhQPbESQROZ NAiNrmuCSB+vDKYqUamX7d3OWGjYBnW4sQqe9o80DNLqXX49FYl+NlDUsYtCFMD9e5lh f0uQ== X-Gm-Message-State: AOJu0Yzjpb5JhFUfgEQ8chy999IXcXSJA+WP1E+r87Kh/QxWYHdQ3NGu +BvIrSikL6T8/uWI+9oAuTi8F8nrBRxMvxbCLo9m5EsLH8fb7kMPJ0JCmw== X-Gm-Gg: ASbGncvk656HBqloWo+iQNqdx+KkUzFoxiyo7rchnN+BPuOO0l964ZVLtQBYjQ+fC/g GMLtUPItBvjPbAH4Tv1/g3s4KnfDslIH4UEZNS9SVB4ybW7HQuzfhTwcUWHl+FUGUusFtvkutVB lATII2LjNlnT1XGYi521RQoal+o8i7mUsihGPz3Vpqa/b0yZY1Bwy0e8u5UjVx1CRnRXiZyhPEJ wbl4h51/7s6WSO5tg34XfjtrOeHmtAp2jAyTmTeXmgCrpi+UAOxFZmkvI/Skf6jo4zDgB3mjwUw 4yF3S/W5OHkx2NqQcs4OsxiOMwmap+9/pO83UCHIL+8bzJucEiM88asK3B8qPuh5KQ== X-Google-Smtp-Source: AGHT+IGkTtuuqZhQdLdpoG9OkgJlR5lZTGZes5mG3fw6uc48OLBRxw/jQmjoTiuqAN7bv3zJRRROTA== X-Received: by 2002:a17:902:7488:b0:224:826:277f with SMTP id d9443c01a7336-225e0af5bc8mr123722155ad.33.1742229808421; Mon, 17 Mar 2025 09:43:28 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 1/9] cxl/type3: Add supported block sizes bitmask to CXLDCRegion struct Date: Mon, 17 Mar 2025 16:31:28 +0000 Message-ID: <20250317164204.2299371-2-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::631; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x631.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:47:56 -0400 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: 1742240952702019000 Content-Type: text/plain; charset="utf-8" From: Anisa Su Add supported_blk_size field to CXLDCRegion struct in preparation for next patch. It is needed by command 0x5600 Get DC Region Config. Signed-off-by: Anisa Su --- hw/mem/cxl_type3.c | 3 +++ include/hw/cxl/cxl_device.h | 1 + 2 files changed, 4 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 11c38a9292..731497ebda 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -8,6 +8,7 @@ * * SPDX-License-Identifier: GPL-v2-only */ +#include =20 #include "qemu/osdep.h" #include "qemu/units.h" @@ -766,6 +767,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) uint64_t region_len; uint64_t decode_len; uint64_t blk_size =3D 2 * MiB; + uint64_t supported_blk_size_bitmask =3D BIT((int) log2(blk_size)); CXLDCRegion *region; MemoryRegion *mr; uint64_t dc_size; @@ -811,6 +813,7 @@ static bool cxl_create_dc_regions(CXLType3Dev *ct3d, Er= ror **errp) .block_size =3D blk_size, /* dsmad_handle set when creating CDAT table entries */ .flags =3D 0, + .supported_blk_size_bitmask =3D supported_blk_size_bitmask, }; ct3d->dc.total_capacity +=3D region->len; region->blk_bitmap =3D bitmap_new(region->len / region->block_size= ); diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index ca515cab13..bebed04085 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -608,6 +608,7 @@ typedef struct CXLDCRegion { uint32_t dsmadhandle; uint8_t flags; unsigned long *blk_bitmap; + uint64_t supported_blk_size_bitmask; } CXLDCRegion; =20 typedef struct CXLSetFeatureInfo { --=20 2.47.2 From nobody Thu Apr 3 10:07:06 2025 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=1742240977; cv=none; d=zohomail.com; s=zohoarc; b=DjB8boHAy7T9r91Ko14PCri7GZwJ5Uo9JdjyIGDpA3bLjF9ywnAxyzmV0/vcYhrSXJncOD3SHQZPf80SNq2p+DiWT0xMOHCaOfnD9zuh/AyiDkJJEFEJQUQRC3yKMlmFwlJ8ARA3U006nzfrMhUgZzaV/mL+7U5wvpfR006PEzs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240977; 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=mFCl+PuL71rwLfqWjVxR8UqDMsn9wX/Wj1FpBaxlxKs=; b=IQaQ2oyUmjBzLwr9QtFWVp4DFk2zlaoQ32N1/B8u8wr4KtUroZUB5u8KcdKIhJ/R9gDBS2ckk1E0NwPcIoUsmDhQ4OkxhQcecM7/dR1Hfe72KtguTiVd1tIMPN/oJH0qmOfhDf8WBRaeJgldLqfuKA65rOrK+f5EPMAfII3ywgU= 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 1742240977046984.735976374856; Mon, 17 Mar 2025 12:49:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGSE-0007eY-Hd; Mon, 17 Mar 2025 15:48:55 -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 1tuDZ7-0003Vs-Hx for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:43:58 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZ3-0001DB-CW for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:43:48 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-225d66a4839so56114685ad.1 for ; Mon, 17 Mar 2025 09:43:40 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229818; x=1742834618; 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=mFCl+PuL71rwLfqWjVxR8UqDMsn9wX/Wj1FpBaxlxKs=; b=I6vInkTO9/9TReoVaGSE72so7BMImRPk+kxcdY6oGVOrn+39IaNxtQwjuZKfX046GF nqhUCiICUWgOyHJHGYrEzp68vou1UR3ZOWIzRv4hg477MDVxcNpISSZ+9L6fL/zoiKgX uBo8dfksz6gVU56hBe036dl7KEssLJSmHe899SuEDb4sJFG60ny47Vgl+TV4WN0meS3U Xi98GB7SNHPzrU1H9TxkBp9vOGBW+nOwXSSabeDbbdmRMZkz997kziOtoOfxSkaimfua XzayvgKbNbiafzZot9+bUl59zLsOVHhz9s0XykzOxZ1NySeti+q7WdrrxEGwAAs+E0n7 /iqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229818; x=1742834618; 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=mFCl+PuL71rwLfqWjVxR8UqDMsn9wX/Wj1FpBaxlxKs=; b=uWQA25ZaIIKVkwWplEw0mYyPfVA/iMxHuS+afLSmNrNUAgOuyuh4VbeDr4diSwtUi5 dUf9U2sYhk5Kei/hG6smiWsqtu/2j4TcPStQHksptyWD285iodugEpI6UPjImQBf6JrE aEewlDgM6PLHYr4nkej1ArAr8ebvT7OxUprkhXb831fHZZ7NelxIh9SQlJNt1RUluNVF 0NVXTofSAETctCezVrxZPqDDkKtY6ZTg2QMr7U7Q8N/DBKf9FAmrluTxtpMBZdJulCwl 13J+qtQrTzCFR8SKpwfM4lQN2iIIVh1fJV1Gff8rlhoe9hgS2jFbh1R+uPN+P3Kpx0Gw ztSg== X-Gm-Message-State: AOJu0Yx/KSUhc7sgYo4H+Jb4V38KzzDuJjdUQSeQBmJFEzuWaaamEdey z1VJO7500mwaCkErYa5BbHtM57WkXSq5BwuIoKt5ropzRwcA/E0EbjJFEg== X-Gm-Gg: ASbGncsij62MKFJekdu+w92CBfLAU4nuCLYyHCl41+gyxq5un324ZwbdBIQq2Rjgkk2 rEi+I//JnkTC0L3W3CFRRXOEYiumgWEse6tFHVovdEmFwbebfHmao6NHKZjPOmW7i/+hZaKo+N0 8nmVUOJXGI+9Kz7UU8VS7musiyJFLSGMN5RW+qngJ4O2apf4HbK/onPe059HvwsAjIC059zLlBn X7gZKsYy4jywI2Q7gfLFEeWmdRGlBu4VGgHdYWvWUQXL/DOmQIFEBZVQmQGc1WkH9rLsmPiVbL4 AumXXpr6YEp1lSyDE5Fgy6wlkloy5WMSVRNS63jv/2leuM25sk4zbKap8/EDQcfDNg== X-Google-Smtp-Source: AGHT+IEyirkL/BekZ2sWuYBKXsGbAnndgmUTBSB4qasF2yNHne2DfTlFWrpxNJXBQMHxhsjOyLsxtA== X-Received: by 2002:a17:903:228c:b0:226:194f:48ef with SMTP id d9443c01a7336-2262c9d26d4mr1856565ad.13.1742229818322; Mon, 17 Mar 2025 09:43:38 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 2/9] cxl-mailbox-utils: 0x5600 - FMAPI Get DCD Info Date: Mon, 17 Mar 2025 16:31:29 +0000 Message-ID: <20250317164204.2299371-3-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::633; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:00 -0400 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: 1742240979019019100 Content-Type: text/plain; charset="utf-8" From: Anisa Su FM DCD Management command 0x5600 implemented per CXL 3.2 Spec Section 7.6.7= .6.1 Signed-off-by: Anisa Su --- hw/cxl/cxl-mailbox-utils.c | 67 ++++++++++++++++++++++++++++++++++++++ hw/cxl/i2c_mctp_cxl.c | 6 +++- 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 1b62d36101..e9991fd1a7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -122,6 +122,8 @@ enum { #define MANAGEMENT_COMMAND 0x0 MHD =3D 0x55, #define GET_MHD_INFO 0x0 + FMAPI_DCD_MGMT =3D 0x56, + #define GET_DCD_INFO 0x0 }; =20 /* CCI Message Format CXL r3.1 Figure 7-19 */ @@ -3341,6 +3343,62 @@ static CXLRetCode cmd_dcd_release_dyn_cap(const stru= ct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* + * CXL r3.2 section 7.6.7.6.1: Get DCD Info (Opcode 5600h) + */ +static CXLRetCode cmd_fm_get_dcd_info(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint8_t num_hosts; + uint8_t num_regions_supported; + uint8_t rsvd1[2]; + uint16_t add_select_policy_bitmask; + uint8_t rsvd2[2]; + uint16_t release_select_policy_bitmask; + uint8_t sanitize_on_release_bitmask; + uint8_t rsvd3; + uint64_t total_dynamic_capacity; + uint64_t region_blk_size_bitmasks[8]; + } QEMU_PACKED *out; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLDCRegion region; + int i; + + if (ct3d->dc.num_regions =3D=3D 0) { + return CXL_MBOX_UNSUPPORTED; + } + + out =3D (void *)payload_out; + + /* TODO: num hosts set to 1 for now */ + out->num_hosts =3D 1; + out->num_regions_supported =3D ct3d->dc.num_regions; + /* TODO: only prescriptive supported for now */ + stw_le_p(&out->add_select_policy_bitmask, + CXL_EXTENT_SELECTION_POLICY_PRESCRIPTIVE); + stw_le_p(&out->release_select_policy_bitmask, + CXL_EXTENT_REMOVAL_POLICY_PRESCRIPTIVE); + /* TODO: sanitize on release bitmask cleared for now */ + out->sanitize_on_release_bitmask =3D 0; + + stq_le_p(&out->total_dynamic_capacity, + ct3d->dc.total_capacity / CXL_CAPACITY_MULTIPLIER); + + for (i =3D 0; i < ct3d->dc.num_regions; i++) { + region =3D ct3d->dc.regions[i]; + memcpy(&out->region_blk_size_bitmasks[i], + ®ion.supported_blk_size_bitmask, 8); + } + + *len_out =3D sizeof(*out); + 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 }, @@ -3462,6 +3520,11 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256]= =3D { cmd_tunnel_management_cmd, ~0, 0 }, }; =20 +static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][256] =3D { + [FMAPI_DCD_MGMT][GET_DCD_INFO] =3D { "GET_DCD_INFO", + cmd_fm_get_dcd_info, 0, 0}, +}; + /* * While the command is executing in the background, the device should * update the percentage complete in the Background Command Status Register @@ -3764,7 +3827,11 @@ void cxl_initialize_t3_fm_owned_ld_mctpcci(CXLCCI *c= ci, DeviceState *d, DeviceState *intf, size_t payload_max) { + CXLType3Dev *ct3d =3D CXL_TYPE3(d); cxl_copy_cci_commands(cci, cxl_cmd_set_t3_fm_owned_ld_mctp); + if (ct3d->dc.num_regions) { + cxl_copy_cci_commands(cci, cxl_cmd_set_fm_dcd); + } cci->d =3D d; cci->intf =3D intf; cxl_init_cci(cci, payload_max); diff --git a/hw/cxl/i2c_mctp_cxl.c b/hw/cxl/i2c_mctp_cxl.c index 7d2cbc3b75..df95182925 100644 --- a/hw/cxl/i2c_mctp_cxl.c +++ b/hw/cxl/i2c_mctp_cxl.c @@ -46,6 +46,9 @@ /* Implementation choice - may make this configurable */ #define MCTP_CXL_MAILBOX_BYTES 512 =20 +/* Supported FMAPI Cmds */ +#define FMAPI_CMD_MAX_OPCODE 0x57 + typedef struct CXLMCTPMessage { /* * DSP0236 (MCTP Base) Integrity Check + Message Type @@ -200,7 +203,8 @@ static void i2c_mctp_cxl_handle_message(MCTPI2CEndpoint= *mctp) if (!(msg->message_type =3D=3D MCTP_MT_CXL_TYPE3 && msg->command_set < 0x51) && !(msg->message_type =3D=3D MCTP_MT_CXL_FMAPI && - msg->command_set >=3D 0x51 && msg->command_set < 0x56)) { + msg->command_set >=3D 0x51 && + msg->command_set < FMAPI_CMD_MAX_OPCODE)) { buf->rc =3D CXL_MBOX_UNSUPPORTED; st24_le_p(buf->pl_length, len_out); s->len =3D s->pos; --=20 2.47.2 From nobody Thu Apr 3 10:07:06 2025 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=1742240992; cv=none; d=zohomail.com; s=zohoarc; b=XPx6ozHFD7Fnuk9Bvm1vX5oPbs61t8npnawHdYV+AY0yL7Z9nyFQdi5ynKZKSgswTME4ZVpQ2/hwL7gge5FxMBz47toRreLEtVIMGY4fM7k/iGdWe5xGYeITOtoGoDrHBBjKv+SVHGkDOeMn/dZ5G7fbSJQF3RrZwmdqZjkd37E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240992; 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=Rk6IJKvkiGFyR1sJ6s9cHj4os4KvgEvO+mrUOM2U7lM=; b=ga86xPATWtP9/0HMpKO2NybWj0iPZhuRSFNBrmuF/FSZT4xETvgg+J2Wrz8s0Y8F3+4Qae7BgUG4bsRHnw3Ghd78jZoOF3NMS8ZKv+eVT9ZVaWHMRTLl3B32dcxb5GhZ78ycPsdufTOOJs8HIf9xR0NvbINd1n+B69YGWdK1+i0= 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 1742240992882495.49374738276003; Mon, 17 Mar 2025 12:49:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGSG-0007ic-QO; Mon, 17 Mar 2025 15:48:57 -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 1tuDZ9-0003WY-89 for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:01 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZ3-0001Dj-TZ for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:43:50 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-225e3002dffso45153105ad.1 for ; Mon, 17 Mar 2025 09:43:43 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.43.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:43:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229821; x=1742834621; 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=Rk6IJKvkiGFyR1sJ6s9cHj4os4KvgEvO+mrUOM2U7lM=; b=DryDuqnDO/lKsoZ5KCvGVpNX2Y5ObvBvei8DM1J9wYUM6fOsDPSyhgIy+4FO6nwaIx XNYENlPX6IwumK5ez5QOI83CBQdto68wM8eHJB5Pea+BN6VyE0sjBmEGGuLRDbMQrE4a GlEhxmdfDF4C+4HK4UGcFOs1ZN0rz8KVdn+esfV0erViPR+atySf/t0SC+Xg9ScLk95O H6yAxSFG92FL7sxEaRi8e6iQPI1ofE8TkhzgNS/F+Web1DzkUxnH/BBWUbdzGojMS+h4 GH8cAJT6JqcEhAGA89WivzbxQ2PPMVQFKkySVJhUVXffX74ahTjC0DEthiFSEaaS+VmN qoQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229821; x=1742834621; 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=Rk6IJKvkiGFyR1sJ6s9cHj4os4KvgEvO+mrUOM2U7lM=; b=S44iM4+dvRyjD4N8jVlsPJr040gJohFsXg/32tl+FCEb/F6+06j6Stxah5QxeqXcNV yhvngwCsHYrzZalNlpGyUCavOShR6IVxhPN+6hewr2RHniVMFmfqjqhIgKwpCVEFMC2W 1hgeG5yASe5UYxlbQpzezd8wArCNJfKtjC7H2DvzW3juRuGR8K5Ahl4DnTQ12Otzz9Nz Lvz8M6VThZKyijymwW6M9jOnr41aNT2JBTgF/qRK4V7o+BN9SafQ+b5SzHlU3TmY9zIM LchT8hW/HwW2IO01GWNnu2moIIQOnur+KhcOGUUW3rifY/lCqUJl0cAtynFPCyspNd6n kEzg== X-Gm-Message-State: AOJu0YxhlvMLMB0rq0iCdlmDrcCX998vRW7yrhOporbDyE0zOV8f7cIr QTOoZHa0t7pN0tokw5yBLnz74KHxtqZCR8vhZ3rj3v2XKb9/aPCJjvF5Bw== X-Gm-Gg: ASbGncsqtvxlPo9jT/khGZBgwiehk5fnLnZP5jVPPShxZIhwUNfq9uR6h0iVQgXPkSV sWR2uFGKBztBqRGtHqG9n3RADgH6udP1+843kcY94iBJOpQXeaCTbm3jeQiaECut1YWWVCLSKI9 sPLFERqiP8wPmCJrWrYBIajCpTYwH+o1HcEl6iAw1THPmCAP5bGfC3DUMeeV3mp9Q/+zDyj+2U5 lInUgNp7p49jjj6R+ctHNo4n/h9gjHrpga4DrIT1wOD/Da3JQsRBVPzBHUJ4DL897qUjeW/S7zb gB5saDG8Mm6ZWgccQ26CbAEtgw+R1Ftyia7l4VjWchyE/2jtxLWktupaSuSp7FztvQ== X-Google-Smtp-Source: AGHT+IHJF7qFLM+Pmkm+5K3dO4fVWd4hfqjmxUtHCW9DjeicaQbB8loeNTkjtv4HsY3E1p8uNG/mgg== X-Received: by 2002:a17:903:19cf:b0:223:3396:15e8 with SMTP id d9443c01a7336-2262c562623mr3466815ad.22.1742229821467; Mon, 17 Mar 2025 09:43:41 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 3/9] cxl/type3: Add dsmas_flags to CXLDCRegion struct Date: Mon, 17 Mar 2025 16:31:30 +0000 Message-ID: <20250317164204.2299371-4-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::629; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:18 -0400 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: 1742240993607019000 Content-Type: text/plain; charset="utf-8" From: Anisa Su Add dsmas_flags field to DC Region struct in preparation for next command, which returns the dsmas flags in the response. Signed-off-by: Anisa Su --- hw/mem/cxl_type3.c | 2 ++ include/hw/cxl/cxl_device.h | 1 + 2 files changed, 3 insertions(+) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 731497ebda..452a0c101a 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -237,6 +237,8 @@ static int ct3_build_cdat_table(CDATSubHeader ***cdat_t= able, void *priv) ct3d->dc.regions[i].len, false, true, region_base); ct3d->dc.regions[i].dsmadhandle =3D dsmad_handle - 1; + CDATDsmas *dsmas =3D (CDATDsmas *) table[cur_ent + CT3_CDAT_DS= MAS]; + ct3d->dc.regions[i].dsmas_flags =3D dsmas->flags; =20 cur_ent +=3D CT3_CDAT_NUM_ENTRIES; region_base +=3D ct3d->dc.regions[i].len; diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index bebed04085..81b826f570 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -609,6 +609,7 @@ typedef struct CXLDCRegion { uint8_t flags; unsigned long *blk_bitmap; uint64_t supported_blk_size_bitmask; + uint8_t dsmas_flags; } CXLDCRegion; =20 typedef struct CXLSetFeatureInfo { --=20 2.47.2 From nobody Thu Apr 3 10:07:07 2025 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=1742240949; cv=none; d=zohomail.com; s=zohoarc; b=n2aJ5ogNCwwETdEYAVK4qcm3QR7qeNbRvTfbZ7Oq0Nf9xw3X0PFEmpjNCiCEld/0D45iAR97xaGdXPqePc7ZQBatuf8+dfZQHAMNCfl/lPhcd1a05T6alSK9qPOin5k2BqEiBbAJGG3S1PnWwisO6JfaQxDbDQ9Lrups1vkJEyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240949; 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=/81TCdkrP4U9ftuJqqmxfWdVPH8Vq1OR4n4vbJaQfuc=; b=NH7jQ9i3KAfTUkeKCHik3/7EqsU/SA7GrznwtBgfVZRreNQfvim4lmCbsA7EDudjrlb6yIjPGw2lCr95eBd8fwQ/0oxXDR38kZCEviLux0OnGyBRCzabgXehYXr8l36ArpvE3T3O4vSY7U6DnDbW5O9A8iXx3iy+eWWLd6nZy0s= 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 1742240949772806.9195864582724; Mon, 17 Mar 2025 12:49:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGS1-0007OK-Q0; Mon, 17 Mar 2025 15:48:42 -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 1tuDZT-0003aU-Az for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:14 -0400 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZ6-0001EU-M5 for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:43:51 -0400 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-22409077c06so117371995ad.1 for ; Mon, 17 Mar 2025 09:43:46 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:43:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229825; x=1742834625; 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=/81TCdkrP4U9ftuJqqmxfWdVPH8Vq1OR4n4vbJaQfuc=; b=DTlxxt54tddpa2kGdQIPQKm8Ow1jsE7GjnQplRmw5XsbXdx2oRHGf6+xon8dOM6GsI n8WDc43GbMYwROS3uLfWLPS22f/fGtFdcbbq1h9/XYkL/DFDItwT727BKzz1wpoIY/Lw GY+7JEi/WBxw24XeWbi9V8km+8AooLMN8xgufw+lunieZ7WacN1zaupWLrHvDAIu7kdb LBkmXCMFObHpzTM0480ec+IDOy2LQe9v7JNfVeDKIYlI5CNb8EYPGDWdXkWy5Yoq0E+i BUHnsHTVerc5yETzUkri8ckQAlO8xzx7tiyuLOHLhrNklnv0cPIQ33uMYz8rCCoGlAMb jMPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229825; x=1742834625; 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=/81TCdkrP4U9ftuJqqmxfWdVPH8Vq1OR4n4vbJaQfuc=; b=u2CCZ7KKPXsroSShCHM2uGdG6U1vFD6GdvuAPeXJArKNa1dB38iQ0qxcG02Vh/CDWn BChFfK2SZOI481T2RnStiddVxqlW8V2F1mGA0L8tHlB6UDUe1lY3oF7f9diCXdI80br4 wM/VrBOnf2+0iDdP4CCd1AWJwrF+nGAje87SFQOwvdoTRvF5+0coLL0PGvIyXsGRXKgv t/LfJX8S+z3BOms8JgboHbbGhhKa/HVcWe2S3P3lRMBLK4ubgyykUZUQ/z+RaO3Ji/3P lcQwp+RAc0uDgI52JYui6hHyUfqZg6t0+AxBCrqRB+xrpPFLOXkyJDXLjhYThihRiiAU ZtHw== X-Gm-Message-State: AOJu0Yzr+bn7/VadlKyEgcNEtVOzANcxGkSN4BHj12dtIQ51gf5l6OdX RbVRXwGVCAJEvKwo+PbRpcqikgNW7NlN7j92M/Wo4X2vvAb/xQT54EZNcw== X-Gm-Gg: ASbGnctpVtV/Sknz+eE0hEo9wIaPAcrmxcR7b24jE/D9zBZGyow8WTG7RlyrH+wBbYo 5gytNue+yFgRFfiev+QuOHAkC/J1NvbzwBNmWkXWZA4n1XKVx3WDASUFb3RAUFpfXpOn8oEOtm6 WtrcEXVHIt+2kw2WJdSAqDiVjCUCP9rawnIflJW9sUneHEDMCo2ko5poX8G/ytivm7GcMXgSqhR Km4KPUcQCjlsqQL+tX2tzo6YjlVKBy35/8ETO8DJ0DygAdMhINulzDLdXA7YcS4w8oYfVPmEWaS qBdDkr/llNffqyC5medx+YkC0j2aUphzbfCbFHjQP10d0pTnto2SU2m+JTjgCJMgIA== X-Google-Smtp-Source: AGHT+IFak24zVoWJ9MyZ/aEEihMeyRc3i0vqCnEzyb8zC6JLW9jUB2nMLHXl1QSGf0gpVDtxsB5jkQ== X-Received: by 2002:a17:903:1a2f:b0:223:5a6e:b16 with SMTP id d9443c01a7336-225e0a15ecemr181984885ad.5.1742229824837; Mon, 17 Mar 2025 09:43:44 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 4/9] cxl-mailbox-utils: 0x5601 - FMAPI Get Host Region Config Date: Mon, 17 Mar 2025 16:31:31 +0000 Message-ID: <20250317164204.2299371-5-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::634; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x634.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:05 -0400 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: 1742240953348019000 Content-Type: text/plain; charset="utf-8" From: Anisa Su FM DCD Management command 0x5601 implemented per CXL r3.2 Spec Section 7.6.= 7.6.2 Signed-off-by: Anisa Su --- hw/cxl/cxl-mailbox-utils.c | 97 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index e9991fd1a7..4bb51bf3e8 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -124,6 +124,7 @@ enum { #define GET_MHD_INFO 0x0 FMAPI_DCD_MGMT =3D 0x56, #define GET_DCD_INFO 0x0 + #define GET_HOST_DC_REGION_CONFIG 0x1 }; =20 /* CCI Message Format CXL r3.1 Figure 7-19 */ @@ -3399,6 +3400,100 @@ static CXLRetCode cmd_fm_get_dcd_info(const struct = cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* + * CXL r3.2 section 7.6.7.6.2: Get Host DC Region Configuration (Opcode 56= 01h) + */ +static CXLRetCode cmd_fm_get_host_dc_region_config(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 region_cnt; + uint8_t start_rid; + } QEMU_PACKED *in; + struct { + uint16_t host_id; + uint8_t num_regions; + uint8_t regions_returned; + struct { + uint64_t base; + uint64_t decode_len; + uint64_t region_len; + uint64_t block_size; + uint8_t dsmas_flags; + uint8_t rsvd1[3]; + uint8_t sanitize; + uint8_t rsvd2[3]; + } QEMU_PACKED records[]; + } QEMU_PACKED *out; + struct { + uint32_t num_extents_supported; + uint32_t num_extents_available; + uint32_t num_tags_supported; + uint32_t num_tags_available; + } QEMU_PACKED *extra_out; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + uint16_t record_count, out_pl_len, i; + uint8_t start_rid; + + if (ct3d->dc.num_regions =3D=3D 0) { + return CXL_MBOX_UNSUPPORTED; + } + + in =3D (void *)payload_in; + if (in->start_rid >=3D ct3d->dc.num_regions) { + return CXL_MBOX_INVALID_INPUT; + } + + start_rid =3D in->start_rid; + record_count =3D MIN(ct3d->dc.num_regions - start_rid, in->region_cnt); + + out =3D (void *)payload_out; + out_pl_len =3D sizeof(*out) + record_count * sizeof(out->records[0]); + + extra_out =3D (void *)(out) + out_pl_len; + out_pl_len +=3D sizeof(*extra_out); + + assert(*len_out <=3D CXL_MAILBOX_MAX_PAYLOAD_SIZE); + + /* TODO: For now, fix host id to be 0 */ + stw_le_p(&out->host_id, 0); + out->num_regions =3D ct3d->dc.num_regions; + out->regions_returned =3D record_count; + + for (i =3D 0; i < record_count; i++) { + stq_le_p(&out->records[i].base, + ct3d->dc.regions[start_rid + i].base); + stq_le_p(&out->records[i].decode_len, + ct3d->dc.regions[start_rid + i].decode_len / + CXL_CAPACITY_MULTIPLIER); + stq_le_p(&out->records[i].region_len, + ct3d->dc.regions[start_rid + i].len); + stq_le_p(&out->records[i].block_size, + ct3d->dc.regions[start_rid + i].block_size); + out->records[i].dsmas_flags =3D + ct3d->dc.regions[start_rid + i].dsmas_flags; + out->records[i].sanitize =3D 0; + } + /* + * TODO: Assign values once extents and tags are introduced + * to use. + */ + stl_le_p(&extra_out->num_extents_supported, CXL_NUM_EXTENTS_SUPPORTED); + stl_le_p(&extra_out->num_extents_available, CXL_NUM_EXTENTS_SUPPORTED - + ct3d->dc.total_extent_count); + stl_le_p(&extra_out->num_tags_supported, CXL_NUM_TAGS_SUPPORTED); + stl_le_p(&extra_out->num_tags_available, CXL_NUM_TAGS_SUPPORTED); + + *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 }, @@ -3523,6 +3618,8 @@ static const struct cxl_cmd cxl_cmd_set_sw[256][256] = =3D { static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][256] =3D { [FMAPI_DCD_MGMT][GET_DCD_INFO] =3D { "GET_DCD_INFO", cmd_fm_get_dcd_info, 0, 0}, + [FMAPI_DCD_MGMT][GET_HOST_DC_REGION_CONFIG] =3D { "GET_HOST_DC_REGION_= CONFIG", + cmd_fm_get_host_dc_region_config, 4, 0}, }; =20 /* --=20 2.47.2 From nobody Thu Apr 3 10:07:07 2025 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=1742240948; cv=none; d=zohomail.com; s=zohoarc; b=kIiEl7GpOMwJ+T8hUwVyEHrDiT7tVIwsEN0c60FQ0zC3a46kPF3ftpMaUFNbnmer6fbwdXhHNjR0p4i08Jg+hUid0bh6QOoUJLJX58e6wfqaI7mqy7nIzgjWq50mphnNITfwcTFLruk/rGasgEW+FPlxIjnVrV5qQj4QU+IJWHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240948; 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=KuObOv7hVkPzGs/EkWPUQYYcsZbgB99BokPUyC+2nNg=; b=RAWlvzOcI5EodQHsSOKxmvRA9dY3ceq1/WuXwQCd8mIojS1zHhCyVupOnRTLWLetwQI7AqBdwv6IKxMBws6cKb/cvJpb0COZCnPuxkdZIl/CFF41I3gqvPDjd+HHufmPueNSqQuXbhP63MfVaq71EVhyY53+r1MwBH4DLYdYiHo= 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 1742240948199175.854740479798; Mon, 17 Mar 2025 12:49:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGS1-0007NZ-Cv; Mon, 17 Mar 2025 15:48:41 -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 1tuDZc-0003eW-IL for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:20 -0400 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZV-0001GC-Gf for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:20 -0400 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-225b5448519so85480805ad.0 for ; Mon, 17 Mar 2025 09:44:02 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.43.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229840; x=1742834640; 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=KuObOv7hVkPzGs/EkWPUQYYcsZbgB99BokPUyC+2nNg=; b=INPmDcuEkz5BL14OBllVi3BO35i5q6CbVphqcgZ7cMnzGZG+q1jqr5Fh+pgJIDr33u 6m9AUQ+Qw49irytwQ89/ZIPxifZ3Vs0rqB2JaDcKdsItZjakr+9gCpV4zO6a7k8lNIco SDlx+2d1RdT6lExScG436kY6tBtEHNJMHl43eiWKSb7s7i8KptvY3FrU7f+ghdemJA2U zYV1Mp5oeDIcJjrV///EHPk8j2XydUVBYELPDoC3cKnBWsILdw8q1BIWGE/rbiy+ym2x wHGCmerVgEn5wwBY3ebZammj0SIhpUp10aphkek78tlxkog8IK7ZY5Ra1+wZmLiKkfWO G2zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229840; x=1742834640; 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=KuObOv7hVkPzGs/EkWPUQYYcsZbgB99BokPUyC+2nNg=; b=HmrreCcoeR34v2J5L/9Q9Kbh+QkDpge6ppbAC97qZtyqCIzvg/o201opIG/NzHuT+w gaMHGjCRtqFK+vcOL90/X0OaphQ2VL4xmUlYr20uJa+yHPk4SkXaxio5svLcyyQJtrIt eyQuzitVh3BftM2CoNhekCecjFQG+Pb2LUbsc9/JUfj0w+W1qwMN4px+nT83eeZq5F11 aM6fpbrPI4o8akP+88XWGw4/bdsQGjjE+oqt1YX54PdgM0hTfI549r/n6n06eqqwB1cH d1+zoV7cbgBspyud2Upon40V2f6HmRaqbFHnzWFtknQIA5CZ8LZqauQncLkWArN0cVC6 0iMg== X-Gm-Message-State: AOJu0Yzp232VRASzPncZsHl+dlLxQnMjSwla7EaLUiL+Ufo6vf1oks3W CFoLOACBDBsqJ2jZx/HuP6AExlpnRsXSye7dEwMtqLZoilCKv1gk/tCuFQ== X-Gm-Gg: ASbGncvhbiU/9t/H/44uWTQdysxiJ5bgNuh1d9u/1SPY+ORnCYFPPiZgwia45vs3FHG cPKq7T1Ab6QG6jxlC2KsMhh/emElN6nQIsrRVCFEIDijabEkfqQSKef3mYsf6G8v5Mta2IOqaPb UXQzR1Ogik1Uy1Ov8GzWriMdy1VTllYHU3SEopFgjUu7BvkXQlLdQKxT90ac0TzeaGIaJi5I/TC X8F/eUcfKdNzjknJ9tJTWU/+geaThUKTmiuDCSqc73i8qL6W4a6fjK/x1b5ifMPQESmN2fy0eWb prKaVQ43W/79Bh8HUG/LStwNEaXhz6MabF1DqbTxQl+QNH15OPIKXRmWKYXX1H/68g== X-Google-Smtp-Source: AGHT+IE9pdhC//ePNgMp9s0EvG5nIUDk60Qus2o8mI6ZGm9DAyJpfV1qoZWjtv30LUTlH7bL6Ce93A== X-Received: by 2002:a17:902:ea06:b0:223:6657:5001 with SMTP id d9443c01a7336-225e0afb86cmr170861585ad.40.1742229839789; Mon, 17 Mar 2025 09:43:59 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 5/9] cxl_events.h: move definition for dynamic_capacity_uuid and enum for DC event types Date: Mon, 17 Mar 2025 16:31:32 +0000 Message-ID: <20250317164204.2299371-6-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::635; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x635.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:11 -0400 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: 1742240952710019000 Content-Type: text/plain; charset="utf-8" From: Anisa Su move definition for dynamic_capacity_uuid and enum for DC event types to cxl_events.h from cxl_type3.c for shared use in next patch Signed-off-by: Anisa Su --- hw/mem/cxl_type3.c | 15 --------------- include/hw/cxl/cxl_events.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index 452a0c101a..ac74e62875 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1977,21 +1977,6 @@ void qmp_cxl_inject_memory_module_event(const char *= path, CxlEventLog log, } } =20 -/* CXL r3.1 Table 8-50: Dynamic Capacity Event Record */ -static const QemuUUID dynamic_capacity_uuid =3D { - .data =3D UUID(0xca95afa7, 0xf183, 0x4018, 0x8c, 0x2f, - 0x95, 0x26, 0x8e, 0x10, 0x1a, 0x2a), -}; - -typedef enum CXLDCEventType { - DC_EVENT_ADD_CAPACITY =3D 0x0, - DC_EVENT_RELEASE_CAPACITY =3D 0x1, - DC_EVENT_FORCED_RELEASE_CAPACITY =3D 0x2, - DC_EVENT_REGION_CONFIG_UPDATED =3D 0x3, - DC_EVENT_ADD_CAPACITY_RSP =3D 0x4, - DC_EVENT_CAPACITY_RELEASED =3D 0x5, -} CXLDCEventType; - /* * Check whether the range [dpa, dpa + len - 1] has overlaps with extents = in * the list. diff --git a/include/hw/cxl/cxl_events.h b/include/hw/cxl/cxl_events.h index 38cadaa0f3..758b075a64 100644 --- a/include/hw/cxl/cxl_events.h +++ b/include/hw/cxl/cxl_events.h @@ -184,4 +184,19 @@ typedef struct CXLEventDynamicCapacity { uint32_t tags_avail; } QEMU_PACKED CXLEventDynamicCapacity; =20 +/* CXL r3.1 Table 8-50: Dynamic Capacity Event Record */ +static const QemuUUID dynamic_capacity_uuid =3D { + .data =3D UUID(0xca95afa7, 0xf183, 0x4018, 0x8c, 0x2f, + 0x95, 0x26, 0x8e, 0x10, 0x1a, 0x2a), +}; + +typedef enum CXLDCEventType { + DC_EVENT_ADD_CAPACITY =3D 0x0, + DC_EVENT_RELEASE_CAPACITY =3D 0x1, + DC_EVENT_FORCED_RELEASE_CAPACITY =3D 0x2, + DC_EVENT_REGION_CONFIG_UPDATED =3D 0x3, + DC_EVENT_ADD_CAPACITY_RSP =3D 0x4, + DC_EVENT_CAPACITY_RELEASED =3D 0x5, +} CXLDCEventType; + #endif /* CXL_EVENTS_H */ --=20 2.47.2 From nobody Thu Apr 3 10:07:07 2025 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=1742241039; cv=none; d=zohomail.com; s=zohoarc; b=V6zTYQ4N9rMYdTJDV2UQIvemLfPKKeZpImX7b9sgzfP55cE626kgF2JTgHMr9Kiek2rAgy0ZhfLpvRtey3Ri/yFq+hZpreQwVkYAh0BFMDHv3qQyr8wLx3DTJNZNGfFHTg9i6ruTMhwPhlTkIK5gnSMX9yHz0IPzdSoMaiNOw8M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742241039; 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=Hkn8lClrCPRJjRc61OgGLP/RguDNSmf0MEgtbmwbv9k=; b=lt6wMgTG/gr9M9UpoRB+y5BUljY4FqTyK7kYODBe4lMa7MVHlo0gnRHkRbG+IkjjPyxqd47Zi/iSyNc9vf5xF5762Vqnniw4g/IqKe/G3qgfQmV2pFum+qq31SAWjBlOMoMLrPkSqLipxLcg0uBCRefJ7Z7jnmFbKHPXdHttwac= 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 1742241039425394.8356936171299; Mon, 17 Mar 2025 12:50:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGS6-0007YG-Lp; Mon, 17 Mar 2025 15:48:46 -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 1tuDZi-0003g1-SF for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:29 -0400 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZX-0001GV-DA for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:25 -0400 Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-223a7065ff8so48293225ad.0 for ; Mon, 17 Mar 2025 09:44:06 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.44.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:44:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229843; x=1742834643; 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=Hkn8lClrCPRJjRc61OgGLP/RguDNSmf0MEgtbmwbv9k=; b=HWAq2HQkQBooDYUriAS0r/tvYPFOk24qXmiceR6e3UKMYDl4t5nqpCxZIU5OJF9WRI efDn2H4tIUa1eYBPeK/+NUv2QhOQPD3EPQ6k8z6zDyQ5sOuieE1Dweo++M4z+O3DxQ3J 6NAbHfzWGnT14woDqDY+EofTPqwcNFk0ecSUzjH3MZ1LeMJs5e7IbbeoQ7Stz3hPySXh JnhmwOfAiaQghxRmywvbDGcBbeeIgvFatcCgN3vTGLjDybsNSngyzLy8+CFcz6sNO5cI ZHBalBkF2mCawM5m2Gj3rst7yI2f2cNsRrzIhRgxnxjYBkZeB7BFEFnAHErfgOBh4/Vq ngqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229843; x=1742834643; 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=Hkn8lClrCPRJjRc61OgGLP/RguDNSmf0MEgtbmwbv9k=; b=VD5LDiSaqivXVmx65gpH1zFENNEuTt+R/SrOoJ5UG9Zbo2swm6OnMVex/LMXWS8A5C Ee/BCz6m7RReYtAeBdmMGAIlwW3oXmbivt8io3Xkykglg6maiNK8XjEjTAo2JjjaBZ0y de68Z+nxYgEwPf5TXGvz37rxDGV+TgCkRcZGJKe7M+cGVUEK0B3zYHC2H93QKO1RLjbf N5YKXf4rDYAgTEOLKsQ2FX8LSWqSXYVRgRnq6Z0xXdx4QRzzR7JM6UPB1uG7pGZreLHN FDe0c0g8XAL+3EbcPJfOpgMyBkzJPg8j40WjbO1Sny8GcPD6M7TWs0/1OqBJZ3ozdhbI fo0A== X-Gm-Message-State: AOJu0Yzh02pmfThfAnQc9y/oxE/BJLTV8yE8X9J9OFfzP2qZXctEO86w 9wXcHCZCIXuME0JYrsmRJVfc1Jn7v7z5BbXv+NJujhlqqycZNqMvWKdrYg== X-Gm-Gg: ASbGncu2u5QLaIi5RbEjvV5Li8AoIi5cM35N3uyH1/ZGGsOs6zHt9RwJ4c+yukpSeCp hNH2CiD96dhDd7Coxk/Pk/EBVFnhu/cta/KAHG/U0L2JAqN2plXrVASht33Ung6hMxnu9gruzlb nfMDsB/IXlx6oOq52fDQuaUA7KAMveaNaxhTKVV/T/t+s9P8U8XGBj+XQJgKxrrc9I+eV0i+ZLJ PzGA4wfYLDkQemBMJH3mCRVxiQUliqdQ7lS5OVy3+JyoAx8X5iRGxBVolqFZ2xp6mZIotODtvJg 9SeOd+L2gZq+gxAKkRQMMXYQDxSspTEhFZBUeDKmIPzHdSyTfxQ6tRWXSW+Y7Ndt5Q== X-Google-Smtp-Source: AGHT+IFBkclO4TGHL2gkT3CI6sTdHYNvtYyBsSFqLvPDNhaaWWBtBRtVqvIa0ai7H0IA+fE/Z8x3dA== X-Received: by 2002:a17:903:1d0:b0:21f:6c81:f63 with SMTP id d9443c01a7336-225e0a89e29mr142478615ad.16.1742229842840; Mon, 17 Mar 2025 09:44:02 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 6/9] cxl-mailbox-utils: 0x5602 - FMAPI Set DC Region Config Date: Mon, 17 Mar 2025 16:31:33 +0000 Message-ID: <20250317164204.2299371-7-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::629; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x629.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:39 -0400 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: 1742241043647019100 Content-Type: text/plain; charset="utf-8" From: Anisa Su FM DCD Management command 0x5602 implemented per CXL r3.2 Spec Section 7.6.= 7.6.3 Signed-off-by: Anisa Su --- hw/cxl/cxl-mailbox-utils.c | 100 +++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 2 +- include/hw/cxl/cxl_device.h | 3 ++ include/hw/cxl/cxl_mailbox.h | 6 +++ 4 files changed, 110 insertions(+), 1 deletion(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 4bb51bf3e8..51ead2b152 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -125,6 +125,7 @@ enum { FMAPI_DCD_MGMT =3D 0x56, #define GET_DCD_INFO 0x0 #define GET_HOST_DC_REGION_CONFIG 0x1 + #define SET_DC_REGION_CONFIG 0x2 }; =20 /* CCI Message Format CXL r3.1 Figure 7-19 */ @@ -3494,6 +3495,98 @@ static CXLRetCode cmd_fm_get_host_dc_region_config(c= onst struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +static void cxl_mbox_dc_event_create_record_hdr(CXLType3Dev *ct3d, + CXLEventRecordHdr *hdr) +{ + /* + * CXL r3.1 section 8.2.9.2.1.6: Dynamic Capacity Event Record + * + * All Dynamic Capacity event records shall set the Event Record Sever= ity + * field in the Common Event Record Format to Informational Event. All + * Dynamic Capacity related events shall be logged in the Dynamic Capa= city + * Event Log. + */ + uint8_t flags =3D 1 << CXL_EVENT_TYPE_INFO; + + st24_le_p(&hdr->flags, flags); + hdr->length =3D sizeof(struct CXLEventDynamicCapacity); + memcpy(&hdr->id, &dynamic_capacity_uuid, sizeof(hdr->id)); + stq_le_p(&hdr->timestamp, cxl_device_get_timestamp(&ct3d->cxl_dstate)); +} + +/* + * CXL r3.2 section 7.6.7.6.3: Set Host DC Region Configuration (Opcode 56= 02) + */ +static CXLRetCode cmd_fm_set_dc_region_config(const struct cxl_cmd *cmd, + uint8_t *payload_in, + size_t len_in, + uint8_t *payload_out, + size_t *len_out, + CXLCCI *cci) +{ + struct { + uint8_t reg_id; + uint8_t rsvd[3]; + uint64_t block_sz; + uint8_t flags; + uint8_t rsvd2[3]; + } QEMU_PACKED *in; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + CXLEventDynamicCapacity dcEvent =3D {}; + CXLDCRegion *region; + + if (ct3d->dc.num_regions =3D=3D 0) { + return CXL_MBOX_UNSUPPORTED; + } + + /* + * TODO: Fail with CXL_MBOX_INVALID_SECURITY_STATE if + * device has been locked + */ + + in =3D (void *)payload_in; + region =3D &ct3d->dc.regions[in->reg_id]; + + /* + * TODO: Fail if sanitize bit doesn't match current config and "the de= vice + * does not support reconfiguration of the Sanitize on Release setting= ." + * Currently not reconfigurable, so always fail if sanitize bit + * doesn't match. + */ + if ((in->flags & 1) !=3D (region->flags & 1)) { + return CXL_MBOX_UNSUPPORTED; + } + + if (in->reg_id >=3D DCD_MAX_NUM_REGION) { + return CXL_MBOX_UNSUPPORTED; + } + + /* Check that no extents are in the region being reconfigured */ + if (!bitmap_empty(region->blk_bitmap, region->len / region->block_size= )) { + return CXL_MBOX_UNSUPPORTED; + } + + /* Free bitmap and create new one for new block size. */ + g_free(region->blk_bitmap); + region->blk_bitmap =3D bitmap_new(region->len / in->block_sz); + + /* Create event record and insert into event log */ + cxl_mbox_dc_event_create_record_hdr(ct3d, &dcEvent.hdr); + dcEvent.type =3D DC_EVENT_REGION_CONFIG_UPDATED; + /* FIXME: for now, validity flag is cleared */ + dcEvent.validity_flags =3D 0; + /* FIXME: Currently only support 1 host */ + dcEvent.host_id =3D 0; + dcEvent.updated_region_id =3D in->reg_id; + + if (cxl_event_insert(&ct3d->cxl_dstate, + CXL_EVENT_TYPE_DYNAMIC_CAP, + (CXLEventRecordRaw *)&dcEvent)) { + cxl_event_irq_assert(ct3d); + } + 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 }, @@ -3620,6 +3713,13 @@ static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][= 256] =3D { cmd_fm_get_dcd_info, 0, 0}, [FMAPI_DCD_MGMT][GET_HOST_DC_REGION_CONFIG] =3D { "GET_HOST_DC_REGION_= CONFIG", cmd_fm_get_host_dc_region_config, 4, 0}, + [FMAPI_DCD_MGMT][SET_DC_REGION_CONFIG] =3D { "SET_DC_REGION_CONFIG", + cmd_fm_set_dc_region_config, 16, + (CXL_MBOX_CONFIG_CHANGE_COLD_RESET | + CXL_MBOX_CONFIG_CHANGE_CONV_RESET | + CXL_MBOX_CONFIG_CHANGE_CXL_RESET | + CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | + CXL_MBOX_IMMEDIATE_DATA_CHANGE)}, }; =20 /* diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index ac74e62875..b742b2bb8d 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1686,7 +1686,7 @@ void qmp_cxl_inject_correctable_error(const char *pat= h, CxlCorErrorType type, pcie_aer_inject_error(PCI_DEVICE(obj), &err); } =20 -static void cxl_assign_event_header(CXLEventRecordHdr *hdr, +void cxl_assign_event_header(CXLEventRecordHdr *hdr, const QemuUUID *uuid, uint32_t flags, uint8_t length, uint64_t timestamp) { diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 81b826f570..217003a29d 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -806,4 +806,7 @@ void ct3_clear_region_block_backed(CXLType3Dev *ct3d, u= int64_t dpa, uint64_t len); bool ct3_test_region_block_backed(CXLType3Dev *ct3d, uint64_t dpa, uint64_t len); +void cxl_assign_event_header(CXLEventRecordHdr *hdr, + const QemuUUID *uuid, uint32_t flags, + uint8_t length, uint64_t timestamp); #endif diff --git a/include/hw/cxl/cxl_mailbox.h b/include/hw/cxl/cxl_mailbox.h index 8e1c7c5f15..820c411cbb 100644 --- a/include/hw/cxl/cxl_mailbox.h +++ b/include/hw/cxl/cxl_mailbox.h @@ -8,6 +8,7 @@ #ifndef CXL_MAILBOX_H #define CXL_MAILBOX_H =20 +#define CXL_MBOX_CONFIG_CHANGE_COLD_RESET (1) #define CXL_MBOX_IMMEDIATE_CONFIG_CHANGE (1 << 1) #define CXL_MBOX_IMMEDIATE_DATA_CHANGE (1 << 2) #define CXL_MBOX_IMMEDIATE_POLICY_CHANGE (1 << 3) @@ -15,6 +16,11 @@ #define CXL_MBOX_SECURITY_STATE_CHANGE (1 << 5) #define CXL_MBOX_BACKGROUND_OPERATION (1 << 6) #define CXL_MBOX_BACKGROUND_OPERATION_ABORT (1 << 7) +#define CXL_MBOX_SECONDARY_MBOX_SUPPORTED (1 << 8) +#define CXL_MBOX_REQUEST_ABORT_BACKGROUND_OP_SUPPORTED (1 << 9) +#define CXL_MBOX_CEL_10_TO_11_VALID (1 << 10) +#define CXL_MBOX_CONFIG_CHANGE_CONV_RESET (1 << 11) +#define CXL_MBOX_CONFIG_CHANGE_CXL_RESET (1 << 12) =20 #define CXL_LOG_CAP_CLEAR_SUPPORTED (1 << 0) #define CXL_LOG_CAP_POPULATE_SUPPORTED (1 << 1) --=20 2.47.2 From nobody Thu Apr 3 10:07:07 2025 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=1742240988; cv=none; d=zohomail.com; s=zohoarc; b=n3O610qEUbxtRSX1WwR7G6L9rzgNDiPfeu6DrXxIfsO5g39HrkrkK37GKOXoAc+lJHI9dTN+Y7CSOhkDs5spexXsv46CXeIEKQ+0eE0o/GxhJNvdnCJRwJce+ffHXr5IHXmG18jV+FlViI6yIEmQTyH61w/fWrYKucez/E+jws4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240988; 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=353TAKo8VnbJ8QqIp//xm5+02cW4+3eAhYTJE+s11Po=; b=DxTW12qbuuNJlp/aceWreR7/ypp+cvtbANKOJk9/PnVYPDiwaSxIRKjsCzlQ03KskpWG95HwehnSChUqxX64Fn48566MKHBDqfZjLgYHnL34QOli9OMtt/a68h4VrnrS1e7tg6GZSNTDKId8q/sJ5ikQSa9jc6EQNgW5mNny04A= 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 1742240988835810.267944764338; Mon, 17 Mar 2025 12:49:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGS3-0007Tu-Rv; Mon, 17 Mar 2025 15:48:43 -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 1tuDZi-0003g3-SM for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:29 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZW-0001Ge-Mi for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:25 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-226185948ffso22914575ad.0 for ; Mon, 17 Mar 2025 09:44:07 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.44.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:44:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229846; x=1742834646; 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=353TAKo8VnbJ8QqIp//xm5+02cW4+3eAhYTJE+s11Po=; b=dUDZBP3rOaoGRg7FVgxfs7nuk9RYpeL8XfWjjuijeerHn+NGIEKFBune8FCfnD6Vzu vi0u4oHNLfo2h5VS7I3nL8EzFkRYMGDkul5wDZLDnb1B2IhxHl5gvNAxlnYSXH+o86E1 BAWaMg3w8BmfS/RYwwl66oFJLqMzjX45by7UerHZZuReyAqtJPR59YmFUKpulsPFqLsm 372cLtBT/a1xyRpDZvrhubnekrO8jkCOBuaLm0N/RuGE9mQKMrmgSLcw4IrKfgtmCTiD I1lMtSy9770GT+L/vGCPjTlNUG0KRArvg1OZHKoi6OsY2z9dWZMDsK2y5H2t7dUzzTQ5 uhJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229846; x=1742834646; 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=353TAKo8VnbJ8QqIp//xm5+02cW4+3eAhYTJE+s11Po=; b=E46GkJWwC34cTmBXBwPTYnoQATgvpYER6FD1pIts4lZobGhp/Zy+zltmS6nFixcbPq OqVdY0eZNvf80HUBSxnOuITZWLceWslQJ/ODKlMDQE3801LgTv6MlB4zjwI9bhuGzERl S7v2Pw6dQ7ykXlHBmUxhTOnkOd/3FBHlucLqQvMwj1sp8rLXYxKtdtJJ/T/RUmBwf8JA Jo/A6E6ygsgzr3e3NeRypcvnSNwzxtwu5GwRWUpJ4Lrg+Y0Ffkeb93jOUzXf23wabnR6 mQDLOAeSUcJIcffkOtPZZYt98IwfuHcaQYgaXsgNiGBwjRkZTgF+YyAZKlm9HV4xvS8X Z7Lw== X-Gm-Message-State: AOJu0YzXMOXcwdiXE1sPrJaKiehWou2UJUh62Xlo7bj149HtR4Z/fQrN i0TeEgWg1R248IW2GlEG2uGgvPt8dmWILwCT7dQ5VQZ7UVEwdGNDggMqhQ== X-Gm-Gg: ASbGncuZTwvd9SoYcwEXJMM+eibozl3jGmm+Z1tE6jN09rpLnCqld/kBw200JGUKGA+ JtXG4OEbKwfzH/qBk+KtA1N8xzgwPSnOWETaza+Q+S/qN84BCtf2YjC9EJYnWJiImNMtSlKow0C f6S7QtTgB27efcMmIYtOEEbkaSp0u0jLKjkSIrskw6W1b/l/7rjcBDFSi49205htjS8KqqUT2sv qoHbLOddT8anZTDurIpIqKjJMfUvuL6xB3PXoJBvby+1VTNYxSI6XvkhIXfwfQOFnMLz0g14392 Yq84X9fLkreW2U1OoGZFkQMcLfaykFmnex+swadQEHOBjBN9p1dQ4wRc29HeP8RJNw== X-Google-Smtp-Source: AGHT+IH2UQVAMxqKvpv3asrn5zmBcvf0OAu7rzB4rOpB6x7Pz7Oqydnwl9BwCTj1jDJg3+oVjydsTw== X-Received: by 2002:a17:902:ec81:b0:220:fe50:5b44 with SMTP id d9443c01a7336-2262c583a37mr3222255ad.31.1742229846058; Mon, 17 Mar 2025 09:44:06 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 7/9] cxl-mailbox-utils: 0x5603 - FMAPI Get DC Region Extent Lists Date: Mon, 17 Mar 2025 16:31:34 +0000 Message-ID: <20250317164204.2299371-8-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::633; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:39 -0400 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: 1742240990142019100 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. Signed-off-by: Anisa Su --- hw/cxl/cxl-mailbox-utils.c | 84 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 51ead2b152..77cf0fdb15 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -126,6 +126,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 */ @@ -3587,6 +3588,87 @@ 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 (ct3d->dc.num_regions =3D=3D 0) { + return CXL_MBOX_UNSUPPORTED; + } + + if (in->host_id !=3D 0) { + return CXL_MBOX_INVALID_INPUT; + } + + if (in->start_extent_id > ct3d->dc.total_extent_count) { + return CXL_MBOX_INVALID_INPUT; + } + + record_count =3D MIN(in->extent_cnt, + ct3d->dc.total_extent_count - 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.total_extent_count); + stl_le_p(&out->list_generation_num, ct3d->dc.ext_list_gen_seq); + + if (record_count > 0) { + out_rec =3D &out->records[record_done]; + + QTAILQ_FOREACH(ent, &ct3d->dc.extents, node) { + if (i++ < in->start_extent_id) { + continue; + } + 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++; + out_rec++; + 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 }, @@ -3720,6 +3802,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.47.2 From nobody Thu Apr 3 10:07:07 2025 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=1742241013; cv=none; d=zohomail.com; s=zohoarc; b=gdYIMlBY0nQJtbesi7owuZTEaM6IsXVibnz7f0w4PQvolUFujAli9/X/Ua4az3AwKp+/Smd6sV+DeXaTnz9WI1JAbRiZ5jINZ91TZo/V8MqLU1jNIb5Mb3AqWSvj7shBpVoEQysS60RXFhmBELsyo6SN2KQsWgq52Gew1ZTGrxw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742241013; 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=OeD8bm35WueORl8KNXonDwF4c8bIUJRaJ8sV3CTjwqM=; b=CAv7Y+xaK7fbumq2YNxDOqq3AEudK26O8Nn5ZzLuGzZwRsoqOzSpDMGSxmWSiVfqj72Musipu4hvEEELtXbwo5fYBqzoRXz55rMlNqTNg0JQza9Vpd6+Kz6dDhs1JgmJPKqPtCfW0ZFc7QzVWGS7A0K1/PsXGQtdCpy1KOhp00w= 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 1742241013656430.5987853419813; Mon, 17 Mar 2025 12:50:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGS4-0007Wq-Tq; Mon, 17 Mar 2025 15:48:44 -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 1tuDZf-0003f5-Af for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:24 -0400 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZV-0001Gv-Do for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:22 -0400 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-22401f4d35aso86774395ad.2 for ; Mon, 17 Mar 2025 09:44:10 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:44:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229848; x=1742834648; 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=OeD8bm35WueORl8KNXonDwF4c8bIUJRaJ8sV3CTjwqM=; b=S/Usznr1xGuBWaLju3AfaMyZjIgpxihnH9Q74DYdJ9HfE0P5zCEhjC04KWbywdz6QB 3IJC9rYU4KBwX0LmFOizbGkPIpjcdIP55jf5nDobl92hk7KwGLV7O6eEBdydXG478y/D PSoMCpyYKPM9UqrSJSpBQtYRs3u0msf+3E4nfWQzaMO4rMyjVDB4JRYmB5rKrjBr6EM9 5BQe3qH0rSgr447aFukk/33QKq2THYtRBqEemXBtKgqU/BBvHwUzZnvClE8ZZ2dZu2eJ sDCr5oh/7hTMXFmuph/pnJGXTvVmiKkGVPCWmC/lg7aPtZwfN6VQQVwFDwc0lRJjqUs0 mo7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229848; x=1742834648; 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=OeD8bm35WueORl8KNXonDwF4c8bIUJRaJ8sV3CTjwqM=; b=ecqEcq9g7Fkc1iPNvREVEWVTurfbkAgqNp+B+xBFxAlphZlsTzI3Ghia6Lup/sinEO dbvYWR9Ffwo6KwE92r31P2Kij5Td1gwzaf+MChbJIKqbLScKPlCAs/gE/yuT2dft4wZL x+SR93UhZxqqesaP65xob+GZSyNV/7Aetdtqyw9k3iZPXmAr0FSkcm4w8XcCR8BI8hRZ F00uq+DPXPmfRDQXUFeEGobkgKnG+hWZAwfXDy8RMgoyacmOGj+a2i3g3NYBdRT3iPnp lf5JcmqiahPw3hs7jBzYggfNaGXC/w9RBkXLlxoNfNzM7Er/gQKzyjRewqNLpQwuxWPZ VVfA== X-Gm-Message-State: AOJu0YzKk/tfgBEVlMUlZogOwVzAS+TvBJ22jM70YxPl0EvrkdfLP4hu OK6Kt1/2JQx3m08zvgYptnNQu8yuu8qqEGHnMnZnnPbhUCQ1gPxfDKM2gw== X-Gm-Gg: ASbGnctZIRnSi907wDSdMRGkpKxSWC1zskT+7+4++tG1zGcEdPXGSWzXda6Yu3BoSx3 dCvw15IzfMFukGK5QDZaQvAFRpjpmzu8l9fDSPIZkmVyfhYsjQ9nzr84C1iHjDIakQXR+60IRm6 cQJx311fc4ZrLu9No0bYPlaAnM2MDQu7bdF2N0iMczz5AErqGhOPhfeu7pZHqjnyJUdQTQHino6 qc1aHAjtaH20ZOOmYqCu1rnW6rfY59/5rZIkIbz8v/UrhAz8iMM2kQJ8x/e6V0UXhpLJU1gK4UJ M0wBEf0Y2g5Cl9GDJYzSg0BRtD4qFXB7lOeNPQz5qsfktziD6SWCEESboIudjxYt2g== X-Google-Smtp-Source: AGHT+IG0XeoWDYSAWB21haDmsMHHN7vfotQour+vtP/CxU8L4xDi/z4qMOAZA355+nOAzMAQY9rxlA== X-Received: by 2002:a17:903:188:b0:224:1d1c:8837 with SMTP id d9443c01a7336-2262c554bc8mr2540105ad.19.1742229848165; Mon, 17 Mar 2025 09:44:08 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 8/9] cxl-mailbox-utils: 0x5604 - FMAPI Initiate DC Add Date: Mon, 17 Mar 2025 16:31:35 +0000 Message-ID: <20250317164204.2299371-9-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::630; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x630.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:34 -0400 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: 1742241016097019100 Content-Type: text/plain; charset="utf-8" From: Anisa Su FM DCD Management command 0x5604 implemented per CXL r3.2 Spec Section 7.6.= 7.6.5 Signed-off-by: Anisa Su --- hw/cxl/cxl-mailbox-utils.c | 173 ++++++++++++++++++++++++++++++++++++ hw/mem/cxl_type3.c | 8 +- include/hw/cxl/cxl_device.h | 4 + 3 files changed, 181 insertions(+), 4 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 77cf0fdb15..5bcbd434b7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -127,6 +127,8 @@ enum { #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 + }; =20 /* CCI Message Format CXL r3.1 Figure 7-19 */ @@ -3669,6 +3671,170 @@ static CXLRetCode cmd_fm_get_dc_region_extent_list(= const struct cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +static CXLRetCode cxl_mbox_dc_prescriptive_sanity_check(CXLType3Dev *dcd, + uint16_t host_id, + uint32_t ext_count, + CXLDCExtentRaw ext= ents[], + CXLDCEventType typ= e) +{ + CXLDCExtentRaw ext; + CXLDCRegion *reg =3D NULL; + int i, j; + + if (dcd->dc.num_regions =3D=3D 0) { + qemu_log_mask(LOG_UNIMP, + "No dynamic capacity support from the device.\n"); + return CXL_MBOX_UNSUPPORTED; + } + + /* TODO: host id check will be added later, currently host id must be = 0. */ + if (host_id !=3D 0) { + return CXL_MBOX_INVALID_INPUT; + } + + for (i =3D 0; i < ext_count; i++) { + ext =3D extents[i]; + + if (ext.len =3D=3D 0) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + + reg =3D cxl_find_dc_region(dcd, ext.start_dpa, ext.len); + if (!reg) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + + if (ext.len % reg->block_size || ext.start_dpa % reg->block_size) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + + /* Check requested extents do not overlap with each other. */ + for (j =3D i + 1; j < ext_count; j++) { + if (ranges_overlap(ext.start_dpa, ext.len, extents[j].start_dp= a, + extents[j].len)) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + } + + if (type =3D=3D DC_EVENT_ADD_CAPACITY) { + /* Check requested extents do not overlap with existing extent= s. */ + if (cxl_extents_overlaps_dpa_range(&dcd->dc.extents, + ext.start_dpa, ext.len)) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + } + } + + return CXL_MBOX_SUCCESS; +} + +/* + * CXL r3.2 Section 7.6.7.6.5 Initiate Dynamic Capacity Add (Opcode 5604h) + */ +static CXLRetCode cmd_fm_initiate_dc_add(const struct cxl_cmd *cmd, + 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 selection_policy; + uint8_t reg_num; + uint64_t length; + uint8_t tag[0x10]; + uint32_t ext_count; + CXLDCExtentRaw extents[]; + } QEMU_PACKED *in =3D (void *)payload_in; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + g_autofree CXLDCExtentRaw *event_rec_exts =3D NULL; + CXLEventDynamicCapacity event_rec =3D {}; + CXLDCExtentGroup *group =3D NULL; + CXLDCExtentRaw ext; + int rc, i; + + switch (in->selection_policy) { + case CXL_EXTENT_SELECTION_POLICY_PRESCRIPTIVE: + /* Adding extents causes exceeding device's extent tracking abilit= y. */ + if (in->ext_count + ct3d->dc.total_extent_count > + CXL_NUM_EXTENTS_SUPPORTED) { + return CXL_MBOX_RESOURCES_EXHAUSTED; + } + rc =3D cxl_mbox_dc_prescriptive_sanity_check(ct3d, + in->host_id, + in->ext_count, + in->extents, + DC_EVENT_ADD_CAPACITY); + if (rc) { + return rc; + } + + /* Prepare extents for Event Record */ + event_rec_exts =3D g_new0(CXLDCExtentRaw, in->ext_count); + for (i =3D 0; i < in->ext_count; i++) { + ext =3D in->extents[i]; + event_rec_exts[i].start_dpa =3D ext.start_dpa; + event_rec_exts[i].len =3D ext.len; + memset(event_rec_exts[i].tag, 0, 0x10); + event_rec_exts[i].shared_seq =3D 0; + + /* Check requested extents do not overlap with pending extents= . */ + if (cxl_extent_groups_overlaps_dpa_range(&ct3d->dc.extents_pen= ding, + ext.start_dpa, ext.le= n)) { + return CXL_MBOX_INVALID_EXTENT_LIST; + } + + /* Create extent group to add to pending list. */ + group =3D cxl_insert_extent_to_extent_group(group, + event_rec_exts[i].st= art_dpa, + event_rec_exts[i].le= n, + event_rec_exts[i].ta= g, + event_rec_exts[i].sh= ared_seq); + } + + /* Add requested extents to pending list. */ + if (group) { + cxl_extent_group_list_insert_tail(&ct3d->dc.extents_pending, g= roup); + } + + /* Create event record and insert to event log */ + cxl_mbox_dc_event_create_record_hdr(ct3d, &event_rec.hdr); + event_rec.type =3D DC_EVENT_ADD_CAPACITY; + /* FIXME: for now, validity flag is cleared */ + event_rec.validity_flags =3D 0; + /* FIXME: Currently only support 1 host */ + event_rec.host_id =3D 0; + /* updated_region_id only valid for DC_EVENT_REGION_CONFIG_UPDATED= */ + event_rec.updated_region_id =3D 0; + for (i =3D 0; i < in->ext_count; i++) { + memcpy(&event_rec.dynamic_capacity_extent, + &event_rec_exts[i], + sizeof(CXLDCExtentRaw)); + + event_rec.flags =3D 0; + if (i < in->ext_count - 1) { + /* Set "More" flag */ + event_rec.flags |=3D BIT(0); + } + + if (cxl_event_insert(&ct3d->cxl_dstate, + CXL_EVENT_TYPE_DYNAMIC_CAP, + (CXLEventRecordRaw *)&event_rec)) { + cxl_event_irq_assert(ct3d); + } + } + + return CXL_MBOX_SUCCESS; + default: + qemu_log_mask(LOG_UNIMP, + "CXL extent selection policy not supported.\n"); + return CXL_MBOX_INVALID_INPUT; + } + + 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 }, @@ -3804,6 +3970,13 @@ static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][= 256] =3D { 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}, + [FMAPI_DCD_MGMT][INITIATE_DC_ADD] =3D { "INIT_DC_ADD", + cmd_fm_initiate_dc_add, ~0, + (CXL_MBOX_CONFIG_CHANGE_COLD_RESET | + CXL_MBOX_CONFIG_CHANGE_CONV_RESET | + CXL_MBOX_CONFIG_CHANGE_CXL_RESET | + CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | + CXL_MBOX_IMMEDIATE_DATA_CHANGE)}, }; =20 /* diff --git a/hw/mem/cxl_type3.c b/hw/mem/cxl_type3.c index b742b2bb8d..ccc619fe10 100644 --- a/hw/mem/cxl_type3.c +++ b/hw/mem/cxl_type3.c @@ -1982,8 +1982,8 @@ void qmp_cxl_inject_memory_module_event(const char *p= ath, CxlEventLog log, * the list. * Return value: return true if has overlaps; otherwise, return false */ -static bool cxl_extents_overlaps_dpa_range(CXLDCExtentList *list, - uint64_t dpa, uint64_t len) +bool cxl_extents_overlaps_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len) { CXLDCExtent *ent; Range range1, range2; @@ -2028,8 +2028,8 @@ bool cxl_extents_contains_dpa_range(CXLDCExtentList *= list, return false; } =20 -static bool cxl_extent_groups_overlaps_dpa_range(CXLDCExtentGroupList *lis= t, - uint64_t dpa, uint64_t le= n) +bool cxl_extent_groups_overlaps_dpa_range(CXLDCExtentGroupList *list, + uint64_t dpa, uint64_t len) { CXLDCExtentGroup *group; =20 diff --git a/include/hw/cxl/cxl_device.h b/include/hw/cxl/cxl_device.h index 217003a29d..1d5831a0b6 100644 --- a/include/hw/cxl/cxl_device.h +++ b/include/hw/cxl/cxl_device.h @@ -809,4 +809,8 @@ bool ct3_test_region_block_backed(CXLType3Dev *ct3d, ui= nt64_t dpa, void cxl_assign_event_header(CXLEventRecordHdr *hdr, const QemuUUID *uuid, uint32_t flags, uint8_t length, uint64_t timestamp); +bool cxl_extents_overlaps_dpa_range(CXLDCExtentList *list, + uint64_t dpa, uint64_t len); +bool cxl_extent_groups_overlaps_dpa_range(CXLDCExtentGroupList *list, + uint64_t dpa, uint64_t len); #endif --=20 2.47.2 From nobody Thu Apr 3 10:07:07 2025 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=1742240974; cv=none; d=zohomail.com; s=zohoarc; b=KcZXIC1YAVkysuRvtQ/s4OzkeaSdkQqX0w1nfljGBzJ6SqiRAXEtnrEKqB8i1juC8Bjwdv4/pFeTtKe0jGXQPR9OmIOkpOtMCA6Tf7V1TwKg7P4p+4J6AJL5uXGqkfw1hoVZeXNusCh91LIbjj0GWWrZnsq0fwLC2yYxdlwRYwM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1742240974; 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=qX31zqHeedLuC0moymwx118I/OYgCdYe/VclY70qVzc=; b=RI0swKaDFrJQqBUQjkxRuJ7On1TsCcg3vziK9z74/0CS/xH+t5eUVrgR39ABesZ//3eClqfONfXzIq8VklwnnjujUsZciX1mvwQJVm6yeTdem7EXln15jtySopLSQpap+9SnvarTLRcN0UZzxDwPBsC9BfE7JF2sbKFfYyEhk4U= 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 1742240974703936.8359856420964; Mon, 17 Mar 2025 12:49:34 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tuGS7-0007ZN-Lu; Mon, 17 Mar 2025 15:48: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 1tuDZi-0003g2-So for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:29 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tuDZW-0001Gx-NO for qemu-devel@nongnu.org; Mon, 17 Mar 2025 12:44:26 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-224019ad9edso36905275ad.1 for ; Mon, 17 Mar 2025 09:44:11 -0700 (PDT) Received: from deb-101020-bm01.dtc.local ([149.97.161.244]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-225c6888461sm77810085ad.23.2025.03.17.09.44.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Mar 2025 09:44:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742229850; x=1742834650; 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=qX31zqHeedLuC0moymwx118I/OYgCdYe/VclY70qVzc=; b=ffz8VMyKVduhBT3gard/L3p1W+ATrzhWrmIxWPDRcuQXP97U9M+pwVKJ4IU1OFOk6T nONCuuJdnPw4GNYV5X/p2F5lvvG9RjPZd+BhaC2SLjpd62XVQi1DJzBNEPEKCVDbYoGh CkNW4X2HCsO71uc9gcgsw2qmQrikt1BEceY+jOOXC1H6oQEl4CQzn6eiMa2plCkZ++K5 D6kbE1r8LZTBa9irwxbunOf9PxXhGi4H1p4RGLPdlMovTqNDP73/hPnGEP+MJB+sejSQ jhp9jxDGKDdODYEeCPaCaC3Z991WpP7VyQQqExbvJFNW6Exm6MXYUldxqjOs2ibcRD1P dHJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742229850; x=1742834650; 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=qX31zqHeedLuC0moymwx118I/OYgCdYe/VclY70qVzc=; b=mYJj+j2KNzRrUOuHU2MMlKkUZKAwG6hGBN4uOgD/1Ad3ldsxlFPKHYOkS63CKbmt/V 7lICo6EtUMK78fCuzZX3MYFvYI5U/ngrqiOiYV2wgt8NFPpaaahmxkKtzy9N+0K+PW3/ mZcGH/nrLXtNb91lRI6w6c17En9/b4zTym7gEuzx+/oTuCAYS/9B4vWiGagW2YjAte5P nrW/seeNw8n4W07/wB2HQhMwjajDPbC1/rVOm9+4W3x/6XwSlWk4LlSNTnObtBYICf7I 9l4NE4mZWUpJKQYP8DDExQj2kq5g/dPBGRvuPuLWJYSXTDLeZK0/wRmzFkSZQ9yTP6Zh mNQQ== X-Gm-Message-State: AOJu0YyJcAM9PLiDl33O2mQjaGC2Rq/A06lNZ41DWMkOVfFAjZx/3oiO aDBe/PQ+BGW+Sm20rx4ffMdtJ7iUHB/ERp/jCmQUc6SREkaShTRuBUWN5w== X-Gm-Gg: ASbGnctZqf0njQ319/vLNuCho7I3sUnTH1y7KHRZn6IzZgWFbYBpg2OTQtl1wWYcGub p5OcheTAZnQ99ym9qrsvuATdDoaqpTiRFlfAGi7+casWXO8S8o1M+11s/NIsD3OuChX93PFSQS2 zHsPbiXMD7jAhUEMN7l9+47y9X6JTm5ku6EeZJlE7EYg4hQEYPhMpFgVydIoiZFWH+IcJttQM0y kdugDDGsIwt819bkYJ3fa4yb2923r1WxFcuF3hYN82Cw1BXKRK6Yk1oSUSlWri9wjFvCALgMf3A KNfaB1nfUCccTHvFpmQx1ch1/DjTXx8OCbR5idkJt5BYdS5cJkk7nAQgElq6LHngmw== X-Google-Smtp-Source: AGHT+IHTebDERZjGklDFMKmEuc+upsuhOSlF8scUGuGJDUpkpQHIzWWc0tRIDXwvlj9dgAvfbHTwPA== X-Received: by 2002:a17:902:f708:b0:223:90ec:80f0 with SMTP id d9443c01a7336-2262c55fcafmr2783855ad.22.1742229849743; Mon, 17 Mar 2025 09:44:09 -0700 (PDT) From: anisa.su887@gmail.com To: qemu-devel@nongnu.org Cc: jonathan.cameron@huawei.com, nifan.cxl@gmail.com, dave@stgolabs.net, linux-cxl@vger.kernel.org, Anisa Su Subject: [PATCH 9/9] cxl-mailbox-utils: 0x5605 - FMAPI Initiate DC Release Date: Mon, 17 Mar 2025 16:31:36 +0000 Message-ID: <20250317164204.2299371-10-anisa.su887@gmail.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250317164204.2299371-1-anisa.su887@gmail.com> References: <20250317164204.2299371-1-anisa.su887@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::633; envelope-from=anisa.su887@gmail.com; helo=mail-pl1-x633.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 17 Mar 2025 15:48:39 -0400 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: 1742240979432019100 Content-Type: text/plain; charset="utf-8" From: Anisa Su FM DCD Managment command 0x5605 implemented per CXL r3.2 Spec Section 7.6.7= .6.6 Signed-off-by: Anisa Su --- hw/cxl/cxl-mailbox-utils.c | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index 5bcbd434b7..37810d892f 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -128,6 +128,7 @@ enum { #define SET_DC_REGION_CONFIG 0x2 #define GET_DC_REGION_EXTENT_LIST 0x3 #define INITIATE_DC_ADD 0x4 + #define INITIATE_DC_RELEASE 0x5 =20 }; =20 @@ -3722,6 +3723,10 @@ static CXLRetCode cxl_mbox_dc_prescriptive_sanity_ch= eck(CXLType3Dev *dcd, ext.start_dpa, ext.len)) { return CXL_MBOX_INVALID_EXTENT_LIST; } + } else if (type =3D=3D DC_EVENT_RELEASE_CAPACITY) { + if (!ct3_test_region_block_backed(dcd, ext.start_dpa, ext.len)= ) { + return CXL_MBOX_INVALID_PA; + } } } =20 @@ -3835,6 +3840,88 @@ static CXLRetCode cmd_fm_initiate_dc_add(const struc= t cxl_cmd *cmd, return CXL_MBOX_SUCCESS; } =20 +/* + * CXL r3.2 Section 7.6.7.6.6 Initiate Dynamic Capacity Release (Opcode 56= 05h) + */ +static CXLRetCode cmd_fm_initiate_dc_release(const struct cxl_cmd *cmd, + 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 flags; + uint8_t reg_num; + uint64_t length; + uint8_t tag[0x10]; + uint32_t ext_count; + CXLDCExtentRaw extents[]; + } QEMU_PACKED *in =3D (void *)payload_in; + CXLType3Dev *ct3d =3D CXL_TYPE3(cci->d); + g_autofree CXLDCExtentRaw *event_rec_exts =3D NULL; + CXLEventDynamicCapacity event_rec =3D {}; + CXLDCExtentRaw ext; + int i, rc =3D 0; + + switch (in->flags & 0x7) { + case CXL_EXTENT_REMOVAL_POLICY_PRESCRIPTIVE: + rc =3D cxl_mbox_dc_prescriptive_sanity_check(ct3d, + in->host_id, + in->ext_count, + in->extents, + DC_EVENT_RELEASE_CAPACI= TY); + if (rc) { + return rc; + } + + /* Create extents for Event Record */ + event_rec_exts =3D g_new0(CXLDCExtentRaw, in->ext_count); + for (i =3D 0; i < in->ext_count; i++) { + ext =3D in->extents[i]; + event_rec_exts[i].start_dpa =3D ext.start_dpa; + event_rec_exts[i].len =3D ext.len; + memset(event_rec_exts[i].tag, 0, 0x10); + event_rec_exts[i].shared_seq =3D 0; + } + + /* Create event record and insert to event log */ + cxl_mbox_dc_event_create_record_hdr(ct3d, &event_rec.hdr); + event_rec.type =3D DC_EVENT_RELEASE_CAPACITY; + /* FIXME: for now, validity flag is cleared */ + event_rec.validity_flags =3D 0; + /* FIXME: Currently only support 1 host */ + event_rec.host_id =3D 0; + /* updated_region_id only valid for DC_EVENT_REGION_CONFIG_UPDATED= */ + event_rec.updated_region_id =3D 0; + for (i =3D 0; i < in->ext_count; i++) { + memcpy(&event_rec.dynamic_capacity_extent, + &event_rec_exts[i], + sizeof(CXLDCExtentRaw)); + + event_rec.flags =3D 0; + if (i < in->ext_count - 1) { + /* Set "More" flag */ + event_rec.flags |=3D BIT(0); + } + + if (cxl_event_insert(&ct3d->cxl_dstate, + CXL_EVENT_TYPE_DYNAMIC_CAP, + (CXLEventRecordRaw *)&event_rec)) { + cxl_event_irq_assert(ct3d); + } + } + return CXL_MBOX_SUCCESS; + default: + qemu_log_mask(LOG_UNIMP, + "CXL extent selection policy not supported.\n"); + return CXL_MBOX_INVALID_INPUT; + } + + 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 }, @@ -3977,6 +4064,13 @@ static const struct cxl_cmd cxl_cmd_set_fm_dcd[256][= 256] =3D { CXL_MBOX_CONFIG_CHANGE_CXL_RESET | CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | CXL_MBOX_IMMEDIATE_DATA_CHANGE)}, + [FMAPI_DCD_MGMT][INITIATE_DC_RELEASE] =3D { "INIT_DC_RELEASE", + cmd_fm_initiate_dc_release, ~0, + (CXL_MBOX_CONFIG_CHANGE_COLD_RESET | + CXL_MBOX_CONFIG_CHANGE_CONV_RESET | + CXL_MBOX_CONFIG_CHANGE_CXL_RESET | + CXL_MBOX_IMMEDIATE_CONFIG_CHANGE | + CXL_MBOX_IMMEDIATE_DATA_CHANGE)}, }; =20 /* --=20 2.47.2