From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH v2] kvm tools: Simplify msi message handling Date: Mon, 24 Oct 2011 11:21:19 +0200 Message-ID: <1319448079-5250-1-git-send-email-levinsasha928@gmail.com> Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com, gorcunov@gmail.com, Sasha Levin To: penberg@cs.helsinki.fi Return-path: Received: from mail-ey0-f174.google.com ([209.85.215.174]:36221 "EHLO mail-ey0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753804Ab1JXIXP (ORCPT ); Mon, 24 Oct 2011 04:23:15 -0400 Received: by eye27 with SMTP id 27so5267634eye.19 for ; Mon, 24 Oct 2011 01:23:14 -0700 (PDT) Sender: kvm-owner@vger.kernel.org List-ID: This patch simplifies passing around msi messages by using 'struct kvm_irq_routing_msi' for storing of msi messages instead of passing all msi parameters around. Signed-off-by: Sasha Levin --- tools/kvm/hw/pci-shmem.c | 5 +---- tools/kvm/include/kvm/irq.h | 4 +++- tools/kvm/include/kvm/pci.h | 7 +++---- tools/kvm/irq.c | 8 ++++---- tools/kvm/virtio/pci.c | 10 ++-------- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/tools/kvm/hw/pci-shmem.c b/tools/kvm/hw/pci-shmem.c index 2907a66..780a377 100644 --- a/tools/kvm/hw/pci-shmem.c +++ b/tools/kvm/hw/pci-shmem.c @@ -124,10 +124,7 @@ int pci_shmem__get_local_irqfd(struct kvm *kvm) return fd; if (pci_shmem_pci_device.msix.ctrl & PCI_MSIX_FLAGS_ENABLE) { - gsi = irq__add_msix_route(kvm, - msix_table[0].low, - msix_table[0].high, - msix_table[0].data); + gsi = irq__add_msix_route(kvm, &msix_table[0].msg); } else { gsi = pci_shmem_pci_device.irq_line; } diff --git a/tools/kvm/include/kvm/irq.h b/tools/kvm/include/kvm/irq.h index 401bee9..61f593d 100644 --- a/tools/kvm/include/kvm/irq.h +++ b/tools/kvm/include/kvm/irq.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include struct kvm; @@ -24,6 +26,6 @@ int irq__register_device(u32 dev, u8 *num, u8 *pin, u8 *line); struct rb_node *irq__get_pci_tree(void); void irq__init(struct kvm *kvm); -int irq__add_msix_route(struct kvm *kvm, u32 low, u32 high, u32 data); +int irq__add_msix_route(struct kvm *kvm, struct msi_msg *msg); #endif diff --git a/tools/kvm/include/kvm/pci.h b/tools/kvm/include/kvm/pci.h index 5ee8005..f71af0b 100644 --- a/tools/kvm/include/kvm/pci.h +++ b/tools/kvm/include/kvm/pci.h @@ -2,8 +2,9 @@ #define KVM__PCI_H #include - +#include #include +#include /* * PCI Configuration Mechanism #1 I/O ports. See Section 3.7.4.1. @@ -26,9 +27,7 @@ struct pci_config_address { }; struct msix_table { - u32 low; - u32 high; - u32 data; + struct msi_msg msg; u32 ctrl; }; diff --git a/tools/kvm/irq.c b/tools/kvm/irq.c index e35bf18..dc2247e 100644 --- a/tools/kvm/irq.c +++ b/tools/kvm/irq.c @@ -167,7 +167,7 @@ void irq__init(struct kvm *kvm) die("Failed setting GSI routes"); } -int irq__add_msix_route(struct kvm *kvm, u32 low, u32 high, u32 data) +int irq__add_msix_route(struct kvm *kvm, struct msi_msg *msg) { int r; @@ -175,9 +175,9 @@ int irq__add_msix_route(struct kvm *kvm, u32 low, u32 high, u32 data) (struct kvm_irq_routing_entry) { .gsi = gsi, .type = KVM_IRQ_ROUTING_MSI, - .u.msi.address_lo = low, - .u.msi.address_hi = high, - .u.msi.data = data, + .u.msi.address_hi = msg->address_hi, + .u.msi.address_lo = msg->address_lo, + .u.msi.data = msg->data, }; r = ioctl(kvm->vm_fd, KVM_SET_GSI_ROUTING, irq_routing); diff --git a/tools/kvm/virtio/pci.c b/tools/kvm/virtio/pci.c index f01851b..73d55a9 100644 --- a/tools/kvm/virtio/pci.c +++ b/tools/kvm/virtio/pci.c @@ -126,20 +126,14 @@ static bool virtio_pci__specific_io_out(struct kvm *kvm, struct virtio_pci *vpci case VIRTIO_MSI_CONFIG_VECTOR: vec = vpci->config_vector = ioport__read16(data); - gsi = irq__add_msix_route(kvm, - vpci->msix_table[vec].low, - vpci->msix_table[vec].high, - vpci->msix_table[vec].data); + gsi = irq__add_msix_route(kvm, &vpci->msix_table[vec].msg); vpci->config_gsi = gsi; break; case VIRTIO_MSI_QUEUE_VECTOR: { vec = vpci->vq_vector[vpci->queue_selector] = ioport__read16(data); - gsi = irq__add_msix_route(kvm, - vpci->msix_table[vec].low, - vpci->msix_table[vec].high, - vpci->msix_table[vec].data); + gsi = irq__add_msix_route(kvm, &vpci->msix_table[vec].msg); vpci->gsis[vpci->queue_selector] = gsi; break; } -- 1.7.7