From patchwork Tue Apr 18 16:21:35 2023 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: 674515 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp58574wrs; Tue, 18 Apr 2023 09:22:46 -0700 (PDT) X-Google-Smtp-Source: AKy350bFinRAKPdYG2X6YuW10efGxt0qjXP8TZaPKuu96+KHEZbsVId9EEcHATarRHjtEa/p4IiA X-Received: by 2002:ac8:5e4d:0:b0:3ed:164c:6834 with SMTP id i13-20020ac85e4d000000b003ed164c6834mr612773qtx.27.1681834966262; Tue, 18 Apr 2023 09:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681834966; cv=none; d=google.com; s=arc-20160816; b=kGxFrsLPoSm7/CMsRl1g5+Fkv5plJF6KzybOHkwFmb9sth/7CAWX0VRnyHG2NGSfL4 zV649VO2kKm8PikgfcXu/cfL/iuBEHf1BqS3TzwSDUhnXw1K/KhISjulR7dYrvZmqEWc A6PUGwfb0XWXqu8BKyfIXhiZkADnQNYfO2mC7+YE8Jl/XgmO5BOU/rDvDrE7MyrLZHNR MefHe6ZeXOyxG0w1J/TYg23RZeR+zOmOjmvuzXzZn48pWAYq8mI3jCGvZuTudxLrqf6C dEx9FBRM1t8PAxVaK6JWOh0Dl3tslwygSuL/DpBakTUMBR0CcpdDe8W+X4SN0rlbVerd ymOw== 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=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=Nf2lEohp+xn7uJS4wtA9FMDcDijbpL09WwI5r5ZmLsiUssfTkptLPCVdh8ANpH2+o5 0WHmLQwQCmeIZr9fkO917ns/eeiJyrKpOelbh2eb6FwC9Z1bvS2HJdepQPnirer9A4yK axzoCWV/3dFBawEv6vGst1GBRhI8JauNuqV/XO8ikUCgjKcnAU+sIMrU2AFKDdpGlvaP vJGzu8Ls8D/30guU/18E45b2l0vHKNnt3S+nPPKGXKZ3ZJO/lgpKyPjv+oxjVlQuU0xw YAVDTL1bqzbWaVGnxKRzQvijJLmCRQ7vxICQQKxZC60CoUiq9R4HWQblui3v8msm1HPo G2Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xX9KuWOR; 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 k11-20020a05620a0b8b00b0074ae357dfd8si3059113qkh.603.2023.04.18.09.22.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Apr 2023 09:22:46 -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=xX9KuWOR; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1poo5b-0006pQ-47; Tue, 18 Apr 2023 12:21: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 1poo5a-0006pE-37 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:54 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1poo5S-0001BU-T6 for qemu-devel@nongnu.org; Tue, 18 Apr 2023 12:21:53 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-3f178da21b2so8517035e9.1 for ; Tue, 18 Apr 2023 09:21:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681834905; x=1684426905; 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=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=xX9KuWORBVoBfQaDp//Zj0pCE5vi9R8pcHOLPKEJQIUMXddEwHNwZq084NqimIeyhB HuFcJaY/AtdyL1kOOyxH198nMH9K/P/HP+qmddQwx85LZzJujl3jUeF9M2i01toKnPT8 paS0v4aJQ/co9mcaY2FT4MJPfGtPthzwnL17/d/BXS1xRsDrnexwQ0n48m4ZZWKatO63 AduMP3Hpmv2mrlGVvfagKIKaM995d/8qGx7v4PeV9l5dgCktjjW0W78lYWdCS+kcRWPu cqJ/synPvQ2RAMUPgUELdkVLjjoM+T3VuKmdANkLxsUcqdV7e2cASOlr47p1Tu5O0oXd 110w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681834905; x=1684426905; 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=eC5A3sVizk95geXn4I1Vdcti4PHMTBsSCbklkuaCJpg=; b=jWK8vEjXZXGv8OgO51PvJH3MUYAOVxT6NgROVmHc3FfVkgNixnbdS6wFmQfFdx4Twn AztN/HQ4GMXFYrXC9uRU3x95t5gwmgAooUIr9kvBHqZ79dz3NPZfDqcdr1z5uIXV1lLe 3K4PhVj66eGsz0Go+/0G8Hyuvn5IYfa9+Uy2JRb9d0/q2sTYgbeZmPdV2sZxmaoqcbtm E1FIpKWQGxUkf5vpuMN3XRRK3BU9Gv8sJVnip5fxF5SjmmKSTzw7nXKeRH3r/trAa/ET n2X0YNrwiUGmlLGtT/wOwm6RGE34ZkKXEVqyTLAy+OSaze73+6i31QJFTDj/vtJj/5Kw LbHw== X-Gm-Message-State: AAQBX9dj4UC+lUsdx5FBWdK/N0YHv2j2Bck+2x9ajZtZr+Aodd6Go6Y6 TMqbOSPXmNr4Zt4Crek2SxLi6g== X-Received: by 2002:adf:d0c2:0:b0:2f2:86cd:3e11 with SMTP id z2-20020adfd0c2000000b002f286cd3e11mr2405489wrh.36.1681834905522; Tue, 18 Apr 2023 09:21:45 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id e2-20020a5d65c2000000b002ceacff44c7sm13404133wrw.83.2023.04.18.09.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Apr 2023 09:21:43 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 09CE81FFB8; Tue, 18 Apr 2023 17:21:41 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Daniel_?= =?utf-8?q?P=2E_Berrang=C3=A9?= , Eduardo Habkost , Viresh Kumar , Mathieu Poirier , "Gonglei (Arei)" , Markus Armbruster , Erik Schilling , Jason Wang , Mark Cave-Ayland , Gerd Hoffmann , virtio-fs@redhat.com, =?utf-8?q?Marc-And?= =?utf-8?q?r=C3=A9_Lureau?= , Paolo Bonzini , "Michael S. Tsirkin" , Stefan Hajnoczi , Eric Blake Subject: [PATCH v2 08/13] virtio: add PCI stub for vhost-user-device Date: Tue, 18 Apr 2023 17:21:35 +0100 Message-Id: <20230418162140.373219-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230418162140.373219-1-alex.bennee@linaro.org> References: <20230418162140.373219-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32a.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-bounces+patch=linaro.org@nongnu.org This is all pretty much boilerplate. Signed-off-by: Alex Bennée Tested-by: Erik Schilling --- hw/virtio/vhost-user-device-pci.c | 71 +++++++++++++++++++++++++++++++ hw/virtio/meson.build | 1 + 2 files changed, 72 insertions(+) create mode 100644 hw/virtio/vhost-user-device-pci.c diff --git a/hw/virtio/vhost-user-device-pci.c b/hw/virtio/vhost-user-device-pci.c new file mode 100644 index 0000000000..41f9b7905b --- /dev/null +++ b/hw/virtio/vhost-user-device-pci.c @@ -0,0 +1,71 @@ +/* + * Vhost-user generic virtio device PCI glue + * + * Copyright (c) 2023 Linaro Ltd + * Author: Alex Bennée + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/qdev-properties.h" +#include "hw/virtio/vhost-user-device.h" +#include "hw/virtio/virtio-pci.h" + +struct VHostUserDevicePCI { + VirtIOPCIProxy parent_obj; + VHostUserBase vub; +}; + +typedef struct VHostUserDevicePCI VHostUserDevicePCI; + +#define TYPE_VHOST_USER_DEVICE_PCI "vhost-user-device-pci-base" + +DECLARE_INSTANCE_CHECKER(VHostUserDevicePCI, + VHOST_USER_DEVICE_PCI, + TYPE_VHOST_USER_DEVICE_PCI) + +static void vhost_user_device_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) +{ + VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(vpci_dev); + DeviceState *vdev = DEVICE(&dev->vub); + + vpci_dev->nvectors = 1; + qdev_realize(vdev, BUS(&vpci_dev->bus), errp); +} + +static void vhost_user_device_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_device_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_device_pci_instance_init(Object *obj) +{ + VHostUserDevicePCI *dev = VHOST_USER_DEVICE_PCI(obj); + + virtio_instance_init_common(obj, &dev->vub, sizeof(dev->vub), + TYPE_VHOST_USER_DEVICE); +} + +static const VirtioPCIDeviceTypeInfo vhost_user_device_pci_info = { + .base_name = TYPE_VHOST_USER_DEVICE_PCI, + .non_transitional_name = "vhost-user-device-pci", + .instance_size = sizeof(VHostUserDevicePCI), + .instance_init = vhost_user_device_pci_instance_init, + .class_init = vhost_user_device_pci_class_init, +}; + +static void vhost_user_device_pci_register(void) +{ + virtio_pci_types_register(&vhost_user_device_pci_info); +} + +type_init(vhost_user_device_pci_register); diff --git a/hw/virtio/meson.build b/hw/virtio/meson.build index 43e5fa3f7d..c0a86b94ae 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -13,6 +13,7 @@ if have_vhost # fixme - this really should be generic specific_virtio_ss.add(files('vhost-user.c')) softmmu_virtio_ss.add(files('vhost-user-device.c')) + softmmu_virtio_ss.add(when: 'CONFIG_VIRTIO_PCI', if_true: files('vhost-user-device-pci.c')) endif if have_vhost_vdpa specific_virtio_ss.add(files('vhost-vdpa.c', 'vhost-shadow-virtqueue.c'))