From patchwork Mon Oct 10 17:29:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 613769 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp2128147pvb; Mon, 10 Oct 2022 10:54:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6yY5yDJscLyVwkN6+7gTJMPFv1O+IP/rF7ep9CVT+00T87dbt45NyZayO9quT4SuE5UCO7 X-Received: by 2002:a05:620a:56f:b0:6ed:208f:7d0b with SMTP id p15-20020a05620a056f00b006ed208f7d0bmr3493241qkp.327.1665424498858; Mon, 10 Oct 2022 10:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665424498; cv=none; d=google.com; s=arc-20160816; b=xDQSe14OIj/uV7djoyH0K42pQTzBDKVRgyU/EWa5dOo5JmQii0c7iPDNYVxglt0YPm KsACzmDIgPmUJgh8hR9scK5suEFKHU43+7aGJD7P6udwjB1vryxvkFRaWK6DGwhmgNPf 8BAdjhbZTjBWqmLT/XXsy3EIdg9WKx4+dj6+aA37yWxd3uICSQNqRyjxVWMiRC39wlPx pGnB7z7RBZ8jEIvGg9Bx6Z+TC7GZZqJ5+DOVPEjS55J3ZYzg3LGQmuL1hbqcJib5Lu8J HfarITMoWQF6CsthrbTMm9MEPQ43HsvFGICMSNLfNsFo3wavada7tvS1EWjZqgkjEa1F 7PDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8FzTRqu6X76Q9LWCqleedY0GTIZa238RHANVu9yOyt8=; b=idsfQL9Zo9wnsSo7qCfp5dqv+XVkhBbPqimTO3QeGNzmnYheGgJ9q9OyJOFNBwUQYI hgftbDSY32OenFRyz5ty/nEyuN+YweKbeRr6ZQ8g4o3fjQ8owYNFsYbDsl9wKXuSUJR9 9FlrVSsrM88W50fcWH7q+Kk3pwWgW2qs2S8AqCdPiSjNXAdVIdhQZEraySfgiyRyxLiQ ZZ/B8us81WFV7nsXzqMcuUrz+tl3lzpKkNRgY5Ot5m4j0Xdnp4NGQiXKPj/wS2CVh4cu P1hV9THHqU1BHvdGw+BDlr7fdqUt5wUpLE+hoSeNd91jPxpmf8yJmvi3rI3LExdoDoVa 2WwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1ByyL9r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ay41-20020a05622a22a900b00397ab6a0413si4287096qtb.30.2022.10.10.10.54.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Oct 2022 10:54:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1ByyL9r; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:60250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohwzS-0003SK-BM for patch@linaro.org; Mon, 10 Oct 2022 13:54:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwav-0000qy-9E for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57949) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohwan-0006Y2-RH for qemu-devel@nongnu.org; Mon, 10 Oct 2022 13:29:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665422969; 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=8FzTRqu6X76Q9LWCqleedY0GTIZa238RHANVu9yOyt8=; b=Q1ByyL9rTSpWWx+E02x/zruXf4ZiREt2mAdPFJHl1EZEk3+0NVzGLNn5MuDJB8G9N4HWhM ikgl8arNHfmYkumx975AJG2bdDydUp8k6gq6SJQCRggp5tASumhksFVcPbnY3s/2tud8Ay scLKwypOuBZ4/HsuHd7U9/7Sb8Zjij4= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-176-drUkLtInMXCm52P2XPdnTQ-1; Mon, 10 Oct 2022 13:29:27 -0400 X-MC-Unique: drUkLtInMXCm52P2XPdnTQ-1 Received: by mail-wr1-f70.google.com with SMTP id d22-20020adfa356000000b0022e224b21c0so2950599wrb.9 for ; Mon, 10 Oct 2022 10:29:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8FzTRqu6X76Q9LWCqleedY0GTIZa238RHANVu9yOyt8=; b=JE5yWs2/9STMLsKcq953bX3rwEIg+4r723TjDVuGRaBodFsAnWTces3bHE5jsWZvI6 0J578R8/WzoLHCGjGJ6wSXAcvk7DHMez/G8Su5Au5HfrL58quEmi/6WOPZ8xbMVe/wuQ nw1R4JmRsbyfaVyr4lKwUvkgLUlhBBB78vZlxeQScpFXfKg6wCxwqm01vkDJ899jGBen tuHXEgAvMgSnk+CtNe67RQdCijl1264ViekjeXdjsY0N/9x2jVq4VyY2RyEmXaIVdzMv yOSKZhg2PAxVYeRXwyT+xGMyfSZZa+j+ujLVD7Ky9/IPnpLnGzi8XL9Cgo/06UXKttkd hA+w== X-Gm-Message-State: ACrzQf0DPxwq3Oa9Zkdnj9AfTPO9rjbec6Ug/KeWbAP8dZkc9A4L8qAK GMaUnWupH+kF2c7iUp8mQCQjz4BZ5asVXoW0dkEArUxc6HUdh0HSCuSLiB4t+r00hs98tnpn4HP GkKG593CKKxrjLaw2npJfD4Mh/IqlREZZ+foyxX9L1XU7stQ7I4PNeyN77LWG X-Received: by 2002:a5d:64c2:0:b0:22e:41b0:42ca with SMTP id f2-20020a5d64c2000000b0022e41b042camr12556947wri.411.1665422965110; Mon, 10 Oct 2022 10:29:25 -0700 (PDT) X-Received: by 2002:a5d:64c2:0:b0:22e:41b0:42ca with SMTP id f2-20020a5d64c2000000b0022e41b042camr12556929wri.411.1665422964744; Mon, 10 Oct 2022 10:29:24 -0700 (PDT) Received: from redhat.com ([2.55.183.131]) by smtp.gmail.com with ESMTPSA id i18-20020a5d5592000000b0021e51c039c5sm9460696wrv.80.2022.10.10.10.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Oct 2022 10:29:24 -0700 (PDT) Date: Mon, 10 Oct 2022 13:29:21 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Viresh Kumar , Alex =?utf-8?q?Benn=C3=A9e?= Subject: [PULL 10/55] hw/virtio: add vhost-user-gpio-pci boilerplate Message-ID: <20221010172813.204597-11-mst@redhat.com> References: <20221010172813.204597-1-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221010172813.204597-1-mst@redhat.com> X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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-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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Viresh Kumar This allows is to instantiate a vhost-user-gpio device as part of a PCI bus. It is mostly boilerplate which looks pretty similar to the vhost-user-fs-pci device. Signed-off-by: Viresh Kumar Reviewed-by: Alex Bennée Message-Id: <5f560cab92d0d789b1c94295ec74b9952907d69d.1641987128.git.viresh.kumar@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20220802095010.3330793-14-alex.bennee@linaro.org> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/vhost-user-gpio-pci.c | 69 +++++++++++++++++++++++++++++++++ MAINTAINERS | 2 +- hw/virtio/meson.build | 1 + 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 hw/virtio/vhost-user-gpio-pci.c diff --git a/hw/virtio/vhost-user-gpio-pci.c b/hw/virtio/vhost-user-gpio-pci.c new file mode 100644 index 0000000000..b3028a24a1 --- /dev/null +++ b/hw/virtio/vhost-user-gpio-pci.c @@ -0,0 +1,69 @@ +/* + * Vhost-user gpio virtio device PCI glue + * + * Copyright (c) 2022 Viresh Kumar + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-gpio.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserGPIOPCI { + VirtIOPCIProxy parent_obj; + VHostUserGPIO vdev; +}; + +typedef struct VHostUserGPIOPCI VHostUserGPIOPCI; + +#define TYPE_VHOST_USER_GPIO_PCI "vhost-user-gpio-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserGPIOPCI, VHOST_USER_GPIO_PCI, + TYPE_VHOST_USER_GPIO_PCI) + +static void vhost_user_gpio_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserGPIOPCI *dev = VHOST_USER_GPIO_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vdev); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_gpio_pci_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioPCIClass *k = VIRTIO_PCI_CLASS(klass); + PCIDeviceClass *pcidev_k = PCI_DEVICE_CLASS(klass); + k->realize = vhost_user_gpio_pci_realize; + set_bit(DEVICE_CATEGORY_INPUT, dc->categories); + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = 0; /* Set by virtio-pci based on virtio id */ + pcidev_k->revision = 0x00; + pcidev_k->class_id = PCI_CLASS_COMMUNICATION_OTHER; +} + +static void vhost_user_gpio_pci_instance_init(Object *obj) +{ + VHostUserGPIOPCI *dev = VHOST_USER_GPIO_PCI(obj); + + virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), + TYPE_VHOST_USER_GPIO); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_gpio_pci_info = { + .base_name = TYPE_VHOST_USER_GPIO_PCI, + .non_transitional_name = "vhost-user-gpio-pci", + .instance_size = sizeof(VHostUserGPIOPCI), + .instance_init = vhost_user_gpio_pci_instance_init, + .class_init = vhost_user_gpio_pci_class_init, +}; + +static void vhost_user_gpio_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_gpio_pci_info); +} + +type_init(vhost_user_gpio_pci_register); diff --git a/MAINTAINERS b/MAINTAINERS index 66d519fe35..beccce4a7a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2102,7 +2102,7 @@ vhost-user-gpio M: Alex Bennée R: Viresh Kumar S: Maintained -F: hw/virtio/vhost-user-gpio.c +F: hw/virtio/vhost-user-gpio* F: include/hw/virtio/vhost-user-gpio.h virtio-crypto diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 33c8e71fab..c14e3db10a 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -30,6 +30,7 @@ virtio_ss.add(when: 'CONFIG_VIRTIO_MEM', if_true: files('virtio-mem.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_I2C', if_true: files('vhost-user-i2c.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_RNG', if_true: files('vhost-user-rng.c')) virtio_ss.add(when: 'CONFIG_VHOST_USER_GPIO', if_true: files('vhost-user-gpio.c')) +virtio_ss.add(when: ['CONFIG_VIRTIO_PCI', 'CONFIG_VHOST_USER_GPIO'], if_true: files('vhost-user-gpio-pci.c')) virtio_pci_ss = ss.source_set() virtio_pci_ss.add(when: 'CONFIG_VHOST_VSOCK', if_true: files('vhost-vsock-pci.c'))