From patchwork Thu Mar 7 17:29:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1053162 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="p7523rdt"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44Fdlw4YQPz9s7T for ; Fri, 8 Mar 2019 05:03:24 +1100 (AEDT) Received: from localhost ([127.0.0.1]:56544 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1xMY-0004dx-Fl for incoming@patchwork.ozlabs.org; Thu, 07 Mar 2019 13:03:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39884) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h1wrB-0003fX-IV for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h1wrA-0008Ru-Fk for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:57 -0500 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]:39936) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h1wrA-0008RL-7m for qemu-devel@nongnu.org; Thu, 07 Mar 2019 12:30:56 -0500 Received: by mail-wr1-x42c.google.com with SMTP id y6so3260070wrn.7 for ; Thu, 07 Mar 2019 09:30:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=ONpxlFM8KN/oydwuZ3QtAxwwDeeXEMkw+n+ylFICszU=; b=p7523rdtCgRliR8BI8609tbZHQ0HkTAvMdlxE+Y2bdgAEYDDzVy23xYzuXK9BE1LpK zEyISLNRHTU/rx5b9jUG5U2Q4gq4lB425YiDCDlf0vX3yqU/i2iwEzX3LNVThD4r3wVC UafF+TNkm2O74BomsZv+4ONjyKnXq3RmJrf+nqUjZ7XPC+kg7SrvcrqBbIFCQu963eWO Cs66Pj7p6Mojf5gGfraXPbIzM6xpC6h9rnqsELa08tltEjMmHlVFPpW12CiXj1DYhXY0 ZUuQnfYPr1YsEv0LPKRWSzr7ZQC63XBsEmB2Gey8lBN6DrIlLAE8Svf9UFgV7eb6XHAe NaHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=ONpxlFM8KN/oydwuZ3QtAxwwDeeXEMkw+n+ylFICszU=; b=Xt/ir0FW3/ZYAntGHiQOUm4BnK0ogf0xG67t6CHqhwGULFSS3fCSGhcV5Uh7ZMWRyM lDJ/Vx1KaK6triK+bC3sW3Zbu/s7Cf58fEMFQPTbPh4guVh180t9BdU9rTrXtqlJBWVs gngXmKtBfYDuO7WOyGs3h35b47pWsi3M95A71AW4x1YG3Tuq4CUojrGDVjsnaEAvNcRz pNofVFLiJjDwF5lhLw2nACZThQDwUvJ8WY3sdn4c65/vW2NVloYWPARm+FdaOL0VYWEs JCnN7YCL3QfvkR7gb5VH1/ssIF/fzqPlRXOHAHMe9FBiqYs+icOHTpR6eXj6DBvjvEED s3Zw== X-Gm-Message-State: APjAAAUlPU3Jn4GwkNzor7YAggH7x4nGGEGQy7WxF0PrBm+nDLW92dhR uNuInRc1gA07xKA9MGpZJrxDHnYS X-Google-Smtp-Source: APXvYqwgcXvvr2DKzzyNjEXiMIs70YlGS8BAL4x1/rSamScbHdPcDP8sB7KcgFSnDWjA3ZG18QV5kA== X-Received: by 2002:adf:dd4d:: with SMTP id u13mr8394452wrm.284.1551979854908; Thu, 07 Mar 2019 09:30:54 -0800 (PST) Received: from 640k.localdomain ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id d206sm9979753wmc.11.2019.03.07.09.30.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Mar 2019 09:30:54 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Thu, 7 Mar 2019 18:29:50 +0100 Message-Id: <1551979804-6060-44-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> References: <1551979804-6060-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42c Subject: [Qemu-devel] [PULL 43/57] tests/libqos: remove pre-qgraph QVirtioPCIDevice API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thuth@redhat.com, lviver@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Remove the qvirtio_pci_device_find* and qvirtio_pci_device_free APIs, now that they do not have any users. Signed-off-by: Paolo Bonzini --- tests/libqos/virtio-pci.c | 112 +++++++--------------------------------------- tests/libqos/virtio-pci.h | 4 -- 2 files changed, 17 insertions(+), 99 deletions(-) diff --git a/tests/libqos/virtio-pci.c b/tests/libqos/virtio-pci.c index 0b58b74..993d347 100644 --- a/tests/libqos/virtio-pci.c +++ b/tests/libqos/virtio-pci.c @@ -35,14 +35,6 @@ * original qvirtio_pci_destructor and qvirtio_pci_start_hw. */ -typedef struct QVirtioPCIForeachData { - void (*func)(QVirtioDevice *d, void *data); - uint16_t device_type; - bool has_slot; - int slot; - void *user_data; -} QVirtioPCIForeachData; - static inline bool qvirtio_pci_is_big_endian(QVirtioPCIDevice *dev) { QPCIBus *bus = dev->pdev->bus; @@ -51,50 +43,6 @@ static inline bool qvirtio_pci_is_big_endian(QVirtioPCIDevice *dev) return qtest_big_endian(bus->qts); } -void qvirtio_pci_device_free(QVirtioPCIDevice *dev) -{ - g_free(dev->pdev); -} - -static void qvirtio_pci_init_from_pcidev(QVirtioPCIDevice *dev, QPCIDevice *pci_dev) -{ - dev->pdev = pci_dev; - dev->vdev.device_type = qpci_config_readw(pci_dev, PCI_SUBSYSTEM_ID); - - dev->config_msix_entry = -1; - - dev->vdev.bus = &qvirtio_pci; - dev->vdev.big_endian = qvirtio_pci_is_big_endian(dev); - - /* each virtio-xxx-pci device should override at least this function */ - dev->obj.get_driver = NULL; - dev->obj.start_hw = qvirtio_pci_start_hw; - dev->obj.destructor = qvirtio_pci_destructor; -} - -static void qvirtio_pci_foreach_callback( - QPCIDevice *dev, int devfn, void *data) -{ - QVirtioPCIForeachData *d = data; - QVirtioPCIDevice *vpcidev = g_new0(QVirtioPCIDevice, 1); - - qvirtio_pci_init_from_pcidev(vpcidev, dev); - if (vpcidev->vdev.device_type == d->device_type && - (!d->has_slot || vpcidev->pdev->devfn == d->slot << 3)) { - d->func(&vpcidev->vdev, d->user_data); - } else { - qvirtio_pci_device_free(vpcidev); - g_free(vpcidev); - } -} - -static void qvirtio_pci_assign_device(QVirtioDevice *d, void *data) -{ - QVirtioPCIDevice **vpcidev = data; - assert(!*vpcidev); - *vpcidev = container_of(d, QVirtioPCIDevice, vdev); -} - #define CONFIG_BASE(dev) (VIRTIO_PCI_CONFIG_OFF((dev)->pdev->msix_enabled)) static uint8_t qvirtio_pci_config_readb(QVirtioDevice *d, uint64_t off) @@ -317,48 +265,6 @@ const QVirtioBus qvirtio_pci = { .virtqueue_kick = qvirtio_pci_virtqueue_kick, }; -/* TODO: delete this once qgraph is completed */ -static void qvirtio_pci_foreach(QPCIBus *bus, uint16_t device_type, - bool has_slot, int slot, - void (*func)(QVirtioDevice *d, void *data), void *data) -{ - QVirtioPCIForeachData d = { .func = func, - .device_type = device_type, - .has_slot = has_slot, - .slot = slot, - .user_data = data }; - - qpci_device_foreach(bus, PCI_VENDOR_ID_REDHAT_QUMRANET, -1, - qvirtio_pci_foreach_callback, &d); -} - -QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type) -{ - QVirtioPCIDevice *dev = NULL; - - qvirtio_pci_foreach(bus, device_type, false, 0, - qvirtio_pci_assign_device, &dev); - - if (dev) { - dev->vdev.bus = &qvirtio_pci; - } - - return dev; -} - -QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus, - uint16_t device_type, int slot) -{ - QVirtioPCIDevice *dev = NULL; - - qvirtio_pci_foreach(bus, device_type, true, slot, - qvirtio_pci_assign_device, &dev); - - dev->vdev.bus = &qvirtio_pci; - - return dev; -} - void qvirtio_pci_device_enable(QVirtioPCIDevice *d) { qpci_device_enable(d->pdev); @@ -445,7 +351,7 @@ void qvirtio_pci_destructor(QOSGraphObject *obj) { QVirtioPCIDevice *dev = (QVirtioPCIDevice *)obj; qvirtio_pci_device_disable(dev); - qvirtio_pci_device_free(dev); + g_free(dev->pdev); } void qvirtio_pci_start_hw(QOSGraphObject *obj) @@ -455,6 +361,22 @@ void qvirtio_pci_start_hw(QOSGraphObject *obj) qvirtio_start_device(&dev->vdev); } +static void qvirtio_pci_init_from_pcidev(QVirtioPCIDevice *dev, QPCIDevice *pci_dev) +{ + dev->pdev = pci_dev; + dev->vdev.device_type = qpci_config_readw(pci_dev, PCI_SUBSYSTEM_ID); + + dev->config_msix_entry = -1; + + dev->vdev.bus = &qvirtio_pci; + dev->vdev.big_endian = qvirtio_pci_is_big_endian(dev); + + /* each virtio-xxx-pci device should override at least this function */ + dev->obj.get_driver = NULL; + dev->obj.start_hw = qvirtio_pci_start_hw; + dev->obj.destructor = qvirtio_pci_destructor; +} + void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr) { QPCIDevice *pci_dev = qpci_device_find(bus, addr->devfn); diff --git a/tests/libqos/virtio-pci.h b/tests/libqos/virtio-pci.h index 5631352..728b471 100644 --- a/tests/libqos/virtio-pci.h +++ b/tests/libqos/virtio-pci.h @@ -35,10 +35,6 @@ extern const QVirtioBus qvirtio_pci; void virtio_pci_init(QVirtioPCIDevice *dev, QPCIBus *bus, QPCIAddress * addr); QVirtioPCIDevice *virtio_pci_new(QPCIBus *bus, QPCIAddress * addr); -QVirtioPCIDevice *qvirtio_pci_device_find(QPCIBus *bus, uint16_t device_type); -QVirtioPCIDevice *qvirtio_pci_device_find_slot(QPCIBus *bus, - uint16_t device_type, int slot); -void qvirtio_pci_device_free(QVirtioPCIDevice *dev); /* virtio-pci object functions available for subclasses that * override the original start_hw and destroy