From nobody Thu Dec 18 23:09:38 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1652697842; cv=none; d=zohomail.com; s=zohoarc; b=IkvongtznsW9XKhBd8AfbliAbGhyzt7SE7ka44Y/a1bAn52pOLe3sEnxCJXSPckNmGkIjuHWixz8u7DYzVSyLzlbB6SD3ypz2L6jiUXnXoK/Kq73CBA2NLNBDpC7e3ZMOP8M1ieBAnINDSvWu2NCkqqroF7S50wB/ySOBpB7QLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652697842; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PLHFEalNlKqumlMci78Jl5CbY0h9TorlDb5jQrCnN0s=; b=VbhROaxiNJaLzVOSRGew0dEgrfsIRZsI7eDe/h8EDP8TtWxwV132E49jYA8ii9JWko45oc6IbM/5UXSnry8g6fYlmkD5sUJ6ak+kHTjOxXlmyN1E71XxF7M6MaS0DBcBHKjSsygH9j5D4AGtWbi0iXQJM0yLeMKePygmB5mIUmQ= 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 1652697842278138.4626060219298; Mon, 16 May 2022 03:44:02 -0700 (PDT) Received: from localhost ([::1]:49560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqYCn-0006D8-68 for importer@patchew.org; Mon, 16 May 2022 06:44:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47796) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY4u-0005kv-OW for qemu-devel@nongnu.org; Mon, 16 May 2022 06:35:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41906) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY4s-00052n-US for qemu-devel@nongnu.org; Mon, 16 May 2022 06:35:52 -0400 Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-600-xKpYo57vP0q9P0DbtYu1gA-1; Mon, 16 May 2022 06:35:49 -0400 Received: by mail-wm1-f70.google.com with SMTP id t184-20020a1c46c1000000b00394209f54f1so6559117wma.4 for ; Mon, 16 May 2022 03:35:49 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id j33-20020a05600c1c2100b00396fbf6f524sm4755569wms.1.2022.05.16.03.35.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:35:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697350; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PLHFEalNlKqumlMci78Jl5CbY0h9TorlDb5jQrCnN0s=; b=KRMHuRXrgruVC/L1NGwTUgJAitcQ3pIkKAbTKq2wUugV3G8iLEOMxTZPrQUs7EUG/+zSS7 ovMGmpLZDPjnunMQV+2KP7TK9DIb+LPPPBBCS1MnbyCN8KMGVCDRAvr6O8HY8QGCDPqxF4 zEf4mrRw6Lte3rZXCYuFswBJCDtho28= X-MC-Unique: xKpYo57vP0q9P0DbtYu1gA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=PLHFEalNlKqumlMci78Jl5CbY0h9TorlDb5jQrCnN0s=; b=AxKCjHpSnPQgBJEKUEdKJRn9+AQNG72oouDO29Ve1ryAwQZ5z5cYMWb3H0mzHDxMW9 wR2n6O3E+n0r94K9Rd0x6S5Mi1bOtxwEZTnscPT3YGhrcKXvIkQpLHZh3GDag5DzklgG ZIkdOPX2UodP1XdRQMiTEkQPsWqp9zsXY4g92I8eWuk9SjETtd2w/aQVG8bQo34YcFMZ z52rM1lowG/A06Yk0rE0tP0oidvV0FpGuQF8XBFSfwBer8g56xmRnkdsZUuxlQ3+nOwY /l1AcBGpt92QHf2X6hMec4N33+fObBc6mP1qkrZLOKPxdMCheAdCzVvm8zAOP7wHzaa8 RFrw== X-Gm-Message-State: AOAM531u6nbRbZGn5b3C97eeHIwGfE8fO4GJ2rfQISGh0zzLjXfoItqb 4LJ0r/hZzAVgFjuTIgPl4bTDRYVxix886uqCTrJe3lrHxNLQSMI7RZkUtsqE9f+NLyomli7xXnj i8gg+aazMVZgyUL6NV07mTozQ65xPXIcd7pHiycVElvUCh0yN7P1KQZihK12b X-Received: by 2002:a05:600c:220e:b0:394:2695:ce9b with SMTP id z14-20020a05600c220e00b003942695ce9bmr15965499wml.64.1652697347905; Mon, 16 May 2022 03:35:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzbvi6taUWchhD2Be9jEvdBH9Nio2YY6Vo4bbODvKj+Rj26UC3J+3B0IGsIVifXZlPSTSCqkw== X-Received: by 2002:a05:600c:220e:b0:394:2695:ce9b with SMTP id z14-20020a05600c220e00b003942695ce9bmr15965482wml.64.1652697347664; Mon, 16 May 2022 03:35:47 -0700 (PDT) Date: Mon, 16 May 2022 06:35:44 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ben Widawsky , Jonathan Cameron , Alex =?utf-8?Q?Benn=C3=A9e?= , Adam Manzanares , Marcel Apfelbaum Subject: [PULL 03/91] hw/pci/cxl: Add a CXL component type (interface) Message-ID: <20220516095448.507876-4-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220516095448.507876-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=170.10.133.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652697843244100001 From: Ben Widawsky A CXL component is a hardware entity that implements CXL component registers from the CXL 2.0 spec (8.2.3). Currently these represent 3 general types. 1. Host Bridge 2. Ports (root, upstream, downstream) 3. Devices (memory, other) A CXL component can be conceptually thought of as a PCIe device with extra functionality when enumerated and enabled. For this reason, CXL does here, and will continue to add on to existing PCI code paths. Host bridges will typically need to be handled specially and so they can implement this newly introduced interface or not. All other components should implement this interface. Implementing this interface allows the core PCI code to treat these devices as special where appropriate. Signed-off-by: Ben Widawsky Signed-off-by: Jonathan Cameron Reviewed-by: Alex Benn=C3=A9e Reviewed-by: Adam Manzanares Message-Id: <20220429144110.25167-2-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci.h | 8 ++++++++ hw/pci/pci.c | 10 ++++++++++ 2 files changed, 18 insertions(+) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 3a32b8dd40..98f0d1b844 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -194,6 +194,8 @@ enum { QEMU_PCIE_LNKSTA_DLLLA =3D (1 << QEMU_PCIE_LNKSTA_DLLLA_BITNR), #define QEMU_PCIE_EXTCAP_INIT_BITNR 9 QEMU_PCIE_EXTCAP_INIT =3D (1 << QEMU_PCIE_EXTCAP_INIT_BITNR), +#define QEMU_PCIE_CXL_BITNR 10 + QEMU_PCIE_CAP_CXL =3D (1 << QEMU_PCIE_CXL_BITNR), }; =20 #define TYPE_PCI_DEVICE "pci-device" @@ -201,6 +203,12 @@ typedef struct PCIDeviceClass PCIDeviceClass; DECLARE_OBJ_CHECKERS(PCIDevice, PCIDeviceClass, PCI_DEVICE, TYPE_PCI_DEVICE) =20 +/* + * Implemented by devices that can be plugged on CXL buses. In the spec, t= his is + * actually a "CXL Component, but we name it device to match the PCI namin= g. + */ +#define INTERFACE_CXL_DEVICE "cxl-device" + /* Implemented by devices that can be plugged on PCI Express buses */ #define INTERFACE_PCIE_DEVICE "pci-express-device" =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 9c58f02853..eb884adef9 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -200,6 +200,11 @@ static const TypeInfo pci_bus_info =3D { .class_init =3D pci_bus_class_init, }; =20 +static const TypeInfo cxl_interface_info =3D { + .name =3D INTERFACE_CXL_DEVICE, + .parent =3D TYPE_INTERFACE, +}; + static const TypeInfo pcie_interface_info =3D { .name =3D INTERFACE_PCIE_DEVICE, .parent =3D TYPE_INTERFACE, @@ -2182,6 +2187,10 @@ static void pci_qdev_realize(DeviceState *qdev, Erro= r **errp) pci_dev->cap_present |=3D QEMU_PCI_CAP_EXPRESS; } =20 + if (object_class_dynamic_cast(klass, INTERFACE_CXL_DEVICE)) { + pci_dev->cap_present |=3D QEMU_PCIE_CAP_CXL; + } + pci_dev =3D do_pci_register_device(pci_dev, object_get_typename(OBJECT(qdev)), pci_dev->devfn, errp); @@ -2938,6 +2947,7 @@ static void pci_register_types(void) type_register_static(&pci_bus_info); type_register_static(&pcie_bus_info); type_register_static(&conventional_pci_interface_info); + type_register_static(&cxl_interface_info); type_register_static(&pcie_interface_info); type_register_static(&pci_device_type_info); } --=20 MST