From patchwork Tue Aug 2 09:50:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 594856 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:b345:0:0:0:0 with SMTP id w5csp4208461maz; Tue, 2 Aug 2022 03:13:11 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u06QBIwU5YiQNYSDI1/VnpjxniGR7mBX2iWqxQcvkwmo1EC9gBUrCeYeQP256wHa9VQq+G X-Received: by 2002:a05:620a:4310:b0:6ac:f9df:178d with SMTP id u16-20020a05620a431000b006acf9df178dmr15058557qko.773.1659435190894; Tue, 02 Aug 2022 03:13:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659435190; cv=none; d=google.com; s=arc-20160816; b=AOXX2tAdzVSFH998dqXg2/bmAAErYHzgbr8REi+RLx41EwkZjEH2dyjTy5VS7Hep8H AFrktl2zX5CyK4VB6TA+G3PrZ251mzKvmthq3+IP6XxwynT3fNBMbUv6ohURtzH09QFv HrrOGB7yZ8cXsoSS3Fe+397Vp16BoXW1M3WSmkBWAOiEJWUGrV4zm1Hd0y+2wYxAalZZ yY1tdIuEJryGjyW49CBGiEK28qPI53Ck1VXiPJb+coG9Tdbkn3JUjB3/SsMc83uyVNQR 5l4Bv1irPB3pBuqhVgJgMNtO8b649LCIozonJJ8TZ8GP+dyw5MUJf54Qp3ze9VNd9AVr 9pQQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=0wWKmm9g65j27GDvpDeMx+m2gI5jbmxa+1Q08BNV3h/aQaAZiw+1eA9hnSnbeLk7Jf DfjYVlWwFMyODE8eweYcfyF4wA+ob6iGNaYSnYX1QwdVdzOqQsT/JGscieQC02+W16wh n2CAHWTsn7xUdFx7kJaqPJDLPKJNdFsjrx9w37a+WkVr30LaXDFrEWvu/zSYkSuquKqw 6MPDvlkpTiV7zqInSLhayLlNEo60+DmNJYpzyeb/rxYs7grNm16gAnqU8yiFC9e5S0v9 k4lpZsxIPf/tkmYBdAQLRZ8DUwM2D9pM9ibcCu9Ns4BIGy8eS3fpLXTBGs2ri95TcDoz H8UA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uGRZuCp+; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id eq4-20020ad45964000000b00476b2567ddbsi2259133qvb.406.2022.08.02.03.13.10 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 02 Aug 2022 03:13:10 -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=@linaro.org header.s=google header.b=uGRZuCp+; 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=linaro.org Received: from localhost ([::1]:58180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oIoti-00074f-F9 for patch@linaro.org; Tue, 02 Aug 2022 06:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oIoXr-0001X7-FU for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:35 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]:35554) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oIoXp-0002WD-Mf for qemu-devel@nongnu.org; Tue, 02 Aug 2022 05:50:35 -0400 Received: by mail-wm1-x335.google.com with SMTP id v131-20020a1cac89000000b003a4bb3f786bso2898128wme.0 for ; Tue, 02 Aug 2022 02:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=uGRZuCp+Zbp3xdIldAdE5QKkEql/6hR8zK2yfY/RMh3PejTP1GNesyFfYlaElvRR/t 52R4JI8rAdsBQqyjQeF2FhlcNCFkKtVXTqfoj9GXJ7CLoOiNREBvN/GjEhoEbObINRMJ pdhWOrLDHJtDZjKyrin74pdelsRH/aGHktLYkdcy+1qRXJt8Uje5mOuPpG//ZbI6Or2Q YDs1LnT06HdOde6zK8uU8/itOJZ0WokgHXzI1zBb9QDRARmsOiGOC9OwKCl4LAxjFd9Z sbYcM+tdwPIForc1YduWWhCGrXOMs0pYmNw03MCQv8dk2wk+W5lgrOAxA8ZFIpn2Jm89 6AFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=UmxR2E4mbxJZdFKpR2RK7UtJOZ7yVasaorcYyzhlbQs=; b=w5Xc88Ki3cUYMP5rTqRPKQZevD6tnkai4u74Lf42J/QctWLmvwORED1BhxVypKSsYc r2zjsy/sliDoZxRSePmF8i0R9gAJYvUxNshJsISIIJCHZcdAL64VHUbMZu4k1lo+YwRq 35Hd44l9oQeTVCXpcoX+fFpQdbSu+1td1nOE8BB0Wbs1bXBc4tWFXMEJEk8dndABZd9t rBOyuVzdpekJ+X2SyzV2Ah2/PXmSFzuyMqGcU/eL3Syea01ZS2JulQgwbX/QbJrjPfg4 hNN0jD2VFJ9nXC0bQjDYWunWbsVoxH4djmLP1ktEExroFK0ktOYbp8GHaeixrg2lSuyJ lWow== X-Gm-Message-State: AJIora9CtCqNZVmNQS2S8+Af+8S9Hhqs5yC15jKwRkIMQlDtWi8yGZ03 dKyev0EMyXLk7U8t4cMbPHQkjfImKK9txQ== X-Received: by 2002:a1c:7915:0:b0:3a3:11a3:7452 with SMTP id l21-20020a1c7915000000b003a311a37452mr13421975wme.27.1659433831298; Tue, 02 Aug 2022 02:50:31 -0700 (PDT) Received: from zen.linaroharston ([185.81.254.11]) by smtp.gmail.com with ESMTPSA id d14-20020adfef8e000000b0021d6dad334bsm14645190wro.4.2022.08.02.02.50.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Aug 2022 02:50:22 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id E6B1B1FFC5; Tue, 2 Aug 2022 10:50:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: slp@redhat.com, mst@redhat.com, marcandre.lureau@redhat.com, stefanha@redhat.com, mathieu.poirier@linaro.org, viresh.kumar@linaro.org, =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH v4 13/22] hw/virtio: add vhost-user-gpio-pci boilerplate Date: Tue, 2 Aug 2022 10:50:01 +0100 Message-Id: <20220802095010.3330793-14-alex.bennee@linaro.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220802095010.3330793-1-alex.bennee@linaro.org> References: <20220802095010.3330793-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.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, 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, 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+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 --- v4 - tweak MAINTAINER --- 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 2c4749a110..bb526df674 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'))