From patchwork Fri Apr 14 16:04:27 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: 673133 Delivered-To: patch@linaro.org Received: by 2002:adf:fcce:0:0:0:0:0 with SMTP id f14csp262339wrs; Fri, 14 Apr 2023 09:05:41 -0700 (PDT) X-Google-Smtp-Source: AKy350b3EpPtIy5M09oxgO4a7xQ/aZxmp9c16ER1KNgXUFGJ3HjmUgF4WAqJ1fXWKGJPBIc7ITdB X-Received: by 2002:a05:6214:e49:b0:56c:37a:58b2 with SMTP id o9-20020a0562140e4900b0056c037a58b2mr3905460qvc.15.1681488341368; Fri, 14 Apr 2023 09:05:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681488341; cv=none; d=google.com; s=arc-20160816; b=sq8hJw9uvGwdrcjdamSC7x/xtpVSO86Qwce2i8twNs95KMQ3vrXCljcQlzFtdsMHTM yUXaqsxcNhaMO4WEyfFoPbBgTu1h9C98lIrKjWygGT89OXT8VfGE+eo7SVpwA7oqiWZC 8qcFIuVXvcue845UbEoBgorVqDdgSFo5K571Hne9DN+uFqHWM2fGEXz55saYVmzlvX2n /l7HlcgReRx7nBgCZcgN1Fo5YtNfdZQm1Fr27fYujmTCeR98AFVhsJlaTpPTt6F8J+vr Q+OEbnWKOx9CIjyqMZcgz+UZ5vAEE/HWfuqZzGVBn30rsvSbVDisWD6PwX8bwG8kAs7v wh6Q== 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=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=AAhtxdVqEcD70GglwOiiFQWrFyQDQAH8CtTnQx1U6NmH4Cb7g5RlARPzPF3Y/OB71o aZ0nWsOKiXFjZLxN0UoRzNd5kB7KnF7N4wOYGSzSd8qHlFeCvLEer5Uw7aePcNUg+9Yt mkfUriTxOpYIjWlpEG8tUjlJWkrDqKPq53BoLjUTW3QCUstTSNGuvaYUGMBGz4BrDD9V GHAhplasZ+2vDaqjUFWwF5J7/3Yd3X0D/r9yo2mSz2QuXZN1L8l3tMeyPZ07XxVNEqVo vQDJPrYClfe9qQqAnitXhYa/5sjwpiYJUCgp9sIFGtNKYY+Vp0O+4n5mhVIuaPYsTOxy 4Waw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=oQki8JcC; 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 t22-20020a05620a451600b00745657d6a58si3048649qkp.37.2023.04.14.09.05.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 14 Apr 2023 09:05:41 -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=oQki8JcC; 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 1pnLv2-0006h4-Jn; Fri, 14 Apr 2023 12:05:00 -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 1pnLul-0006SG-Ah for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:47 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pnLui-0007zV-L1 for qemu-devel@nongnu.org; Fri, 14 Apr 2023 12:04:43 -0400 Received: by mail-wr1-x435.google.com with SMTP id v6so18017484wrv.8 for ; Fri, 14 Apr 2023 09:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681488279; x=1684080279; 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=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=oQki8JcCOBUDtxvcJydmEBkY0xGHK9Li0fWLu09OdcGLn/8/v105xW8W85N/lzoP7e aERWlwhD6ZoSOONni39zElEg3RM8o1w2rB8xzsYSGulSfCwSlJeACwdvvMHZURW6fF29 qzxcOOyPgNbLR2AELKGqAyDdL39d7FRgV8WBznDT7njOrlBu6vsFkUVPrfoeMp4fnTCk 9mij9WAJEFdNjNkV+/gO/ahfI/SSVohQtBZUuUY0kDg1jLxlpiwF57M52OYnY9eAXv40 Hy0/DbP0tLZ6/vHfilDyGeSEXqmgsn8hEU7mxV+TXVkNxlxO0+rSL35Zrt3NsKHQxgTb 0JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681488279; x=1684080279; 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=qzkS2+7HizjSf39YyqA8Cq2rMvvTCIuBSsfqveXGmXY=; b=Ihprbsh7NiyHdMIIaFtxWpUyD9eUQyfPGRVdb8T7S/yZBWH/5nhbzKVRXiHS8xp/Xt UpSKcUn2rl0JAaRZ9X8l2DY6+i6pGV0j+JttP5lIBxwVc2bX3UYZlCoYfoVJlub4x5W5 EoOf22aRdN4TJTcZWfVMGIhfj5wH3roOHbQ2zK2agV08NNdiLkut0l646AKuhYiRIsWu 2/venQ1A7Y3wgeDt1R71vgj43F0LE7f4p88i4Mbgt34qL48tiGkL9vCvzB2e6Ks8gnfk bGb/gH6ac49Et7Q69mq/B15fSij5kwlOyR/cv8uhtS3KF4WX4QKyBZ5jWubgyWfLaF/T vl2Q== X-Gm-Message-State: AAQBX9dj5Ii/wtw8HVimCQhPAjHGGgw4ME/rECk/JP7f3y8KXYkg/iDs 7cFsdjMp9loVkpwWS2E3LT732w== X-Received: by 2002:a05:6000:1818:b0:2f5:4b0b:a323 with SMTP id m24-20020a056000181800b002f54b0ba323mr4631230wrh.7.1681488278774; Fri, 14 Apr 2023 09:04:38 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id y18-20020adff6d2000000b002daf0b52598sm3865268wrp.18.2023.04.14.09.04.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Apr 2023 09:04:36 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7DC7E1FFBE; Fri, 14 Apr 2023 17:04:34 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: "Gonglei (Arei)" , Paolo Bonzini , "Michael S. Tsirkin" , virtio-fs@redhat.com, Erik Schilling , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Marc-Andr?= =?utf-8?q?=C3=A9_Lureau?= , Eduardo Habkost , Stefan Hajnoczi , Eric Blake , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Jason Wang , Viresh Kumar , Mathieu Poirier , Gerd Hoffmann , Markus Armbruster Subject: [PATCH 06/12] virtio: add PCI stub for vhost-user-device Date: Fri, 14 Apr 2023 17:04:27 +0100 Message-Id: <20230414160433.2096866-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230414160433.2096866-1-alex.bennee@linaro.org> References: <20230414160433.2096866-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x435.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..96bf99d5fd --- /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; + VHostUserDevice vdev; +}; + +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->vdev); + + 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->vdev, sizeof(dev->vdev), + 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'))