From patchwork Mon Jul 10 15:35:10 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: 701029 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp5243441wrs; Mon, 10 Jul 2023 08:37:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFpkHvvh/1Z5sg8aVob6LWWOmbU6rsRxNE3Tump1R70UfWn9JWD9M2n6k18EgI7Gd3dwbY6 X-Received: by 2002:a05:620a:2809:b0:765:4878:9d20 with SMTP id f9-20020a05620a280900b0076548789d20mr12544293qkp.61.1689003444353; Mon, 10 Jul 2023 08:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689003444; cv=none; d=google.com; s=arc-20160816; b=BHjRo6jCPpv6DsNUkPyUQVeZEwCQ60x5wlrjlNnt4kWCivLmN7kahWPyRO5Mw/BRU5 CA2KcAyylBo8zxtDgchtnNZF64hQxQFDY6P06CED5FrIX7U7vDkbc9Y2TQ3YVMBXon7M QeZ5oz9BD3zYfMRt98F0VYDrz8OQXkV7J1v3EUqzBbdk3pqRYtrNTV/4zxCN0XmlUQhY s2fU5ts6Rx/2H2lJpV6L5n3Nsc8qMmOQHwcREEy1NiTMnEcoGjt+Qm2D4zf8I41poOYC 5gsU4cw3j0PZY1EMAi6aCLVIXPW3VxNK/So20brCr3JNwD4v1hUEvH18fWJYixmF1Ple i/mA== 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=9tMjRjVxXlcAyveN1BbPQH3Nll2IHvq76/Eq339lGng=; fh=pHpVzH22N3up2JSv0jV3vGkBG2/OCgsTpbbdQUlofss=; b=QSingfxsHAgNuYCOUiPFRh40sueoG57CcrR1p0aGm3cghu7mm2lptZsvnojagRBoZw EKlxtHcejeLDtpW5NnH4hIqVWS6ou6dMzBeWl6PVP4R6Hv4tkhiGw4Bwj5oMkuIPJTmM eBBf50Mm+hZEPQrz4FSFdajkIWlW55mlxn498m/JBZOUXT6XC1PRIv1QK7nd+Zjdw08m elpvG/0p8TxekVtnI/Rw2pBMB8PnBMU0hZ9Ryhp4egVn8EUdJgFupuraSRrnx7uyutCg opccB52nzvQJ/CBmMK3xyspZWnXH6/FU1M2+5TZO8H2o4N5frKe3ySU3RDKAhSQB4wLH D/bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cFywZH65; 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 c21-20020a05620a11b500b007608c82b593si5742270qkk.215.2023.07.10.08.37.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Jul 2023 08:37:24 -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=cFywZH65; 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 1qIsvi-0005xa-Ma; Mon, 10 Jul 2023 11:36:02 -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 1qIsvX-0005py-PQ for qemu-devel@nongnu.org; Mon, 10 Jul 2023 11:35:52 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qIsvG-0004mA-3w for qemu-devel@nongnu.org; Mon, 10 Jul 2023 11:35:50 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fbf1b82de7so34220695e9.1 for ; Mon, 10 Jul 2023 08:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689003332; x=1691595332; 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=9tMjRjVxXlcAyveN1BbPQH3Nll2IHvq76/Eq339lGng=; b=cFywZH65UhJ2Zn1R3CgaqM6BYfFdCW0Yj3VxquSqETsDyfA+KJZjJRIW6OUhvcqPQd zJi0/bHT+9HdYfAeOTLHZOk6L3fAllmPYDtD20KsYbPyROgJs1sFrXsfzlRW40R5vxv+ MBy/RS9K/WxjFg9LaSzuqki7fzXzXhia0PhE2TUpg6TQqoBYOMFE6TmVcu4PvnSYBZ6s iZbNQ+6vR6bOf9Q5fX+BpDpwxDWLIIvuwSohm5Fc1hxjT59NFa3yQLfZfc/t0vAKIKel TQ5fORkMHNia2Cec4y07yxltaaPPAUOtkifD3qm0Vm3gvGox45kwbH2OoyOH29nlAkUl 7k6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689003332; x=1691595332; 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=9tMjRjVxXlcAyveN1BbPQH3Nll2IHvq76/Eq339lGng=; b=e+K2Lwq2s5aCEsB5DXVq3E752VRsk59Wvzx1u+tAYek1qlBrJlJ2yPzUefu3oZLGu4 G6bJmdzb7PYSoJZDY/PZMfFyQ5v+xC5TiBtzSzy2PL2b4HTbM4v/yBPVUAaj2cTwgrcP 7xAU+B0Z1zWb1F9uQdbdN5hrGPvfBnDAR99kFqksRELqJm0DG4pR4z+aeyJBAwEiM7t8 3iL1cS9J/SrofnqEGKACwbRTQlBiyrvCkxlHPZHz4R+8gXdhm2kAOf5hiGbzk/sIUwEa yMGspSs7qKKzyYo+P3WRtl7j1xtoikGiFpa/+gzTB6OcOIRzXIeVc6P7LERDozlT8vc7 kZwQ== X-Gm-Message-State: ABy/qLbNIOyN110TvEjWswRvnOEdGGKJW8dMchLvCxjgdfKprN+a1wlW VgkTt6TmsFynry8q7sF5eIYNUw== X-Received: by 2002:a05:600c:35c3:b0:3fa:125c:8d65 with SMTP id r3-20020a05600c35c300b003fa125c8d65mr14771442wmq.3.1689003332066; Mon, 10 Jul 2023 08:35:32 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id s21-20020a7bc395000000b003fbc89af035sm183251wmj.17.2023.07.10.08.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jul 2023 08:35:29 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 1D95A1FFC3; Mon, 10 Jul 2023 16:35:23 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , Jason Wang , Viresh Kumar , Raphael Norwitz , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , qemu-block@nongnu.org, Eric Blake , "Michael S. Tsirkin" , Mark Cave-Ayland , Kevin Wolf , Markus Armbruster , Gerd Hoffmann , Mathieu Poirier , Hanna Reitz , =?utf-8?q?Alex_Benn=C3=A9e?= , Erik Schilling , "Gonglei (Arei)" , Eduardo Habkost , Fam Zheng , virtio-fs@redhat.com, Stefan Hajnoczi Subject: [PATCH v3 08/20] virtio: add PCI stub for vhost-user-device Date: Mon, 10 Jul 2023 16:35:10 +0100 Message-Id: <20230710153522.3469097-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230710153522.3469097-1-alex.bennee@linaro.org> References: <20230710153522.3469097-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32b; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32b.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, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=unavailable 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 b87c5523e7..1e1df77783 100644 --- a/hw/virtio/meson.build +++ b/hw/virtio/meson.build @@ -18,6 +18,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'))