All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <levinsasha928@gmail.com>
To: penberg@cs.helsinki.fi
Cc: kvm@vger.kernel.org, mingo@elte.hu, asias.hejun@gmail.com,
	gorcunov@gmail.com, Sasha Levin <levinsasha928@gmail.com>
Subject: [PATCH] kvm tools: Simplify msi message handling
Date: Fri, 21 Oct 2011 13:35:10 +0200	[thread overview]
Message-ID: <1319196910-1184-1-git-send-email-levinsasha928@gmail.com> (raw)

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 <levinsasha928@gmail.com>
---
 tools/kvm/hw/pci-shmem.c    |    5 +----
 tools/kvm/include/kvm/irq.h |    3 ++-
 tools/kvm/include/kvm/pci.h |    6 ++----
 tools/kvm/irq.c             |    6 ++----
 tools/kvm/virtio/pci.c      |   10 ++--------
 5 files changed, 9 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..3df795d 100644
--- a/tools/kvm/include/kvm/irq.h
+++ b/tools/kvm/include/kvm/irq.h
@@ -4,6 +4,7 @@
 #include <linux/types.h>
 #include <linux/rbtree.h>
 #include <linux/list.h>
+#include <linux/kvm.h>
 
 struct kvm;
 
@@ -24,6 +25,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 kvm_irq_routing_msi *msg);
 
 #endif
diff --git a/tools/kvm/include/kvm/pci.h b/tools/kvm/include/kvm/pci.h
index 5ee8005..61753a0 100644
--- a/tools/kvm/include/kvm/pci.h
+++ b/tools/kvm/include/kvm/pci.h
@@ -2,7 +2,7 @@
 #define KVM__PCI_H
 
 #include <linux/types.h>
-
+#include <linux/kvm.h>
 #include <linux/pci_regs.h>
 
 /*
@@ -26,9 +26,7 @@ struct pci_config_address {
 };
 
 struct msix_table {
-	u32 low;
-	u32 high;
-	u32 data;
+	struct kvm_irq_routing_msi msg;
 	u32 ctrl;
 };
 
diff --git a/tools/kvm/irq.c b/tools/kvm/irq.c
index e35bf18..f1002d8 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 kvm_irq_routing_msi *msg)
 {
 	int r;
 
@@ -175,9 +175,7 @@ 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 = *msg,
 		};
 
 	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


             reply	other threads:[~2011-10-21 11:35 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21 11:35 Sasha Levin [this message]
2011-10-23 11:23 ` [PATCH] kvm tools: Simplify msi message handling Pekka Enberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319196910-1184-1-git-send-email-levinsasha928@gmail.com \
    --to=levinsasha928@gmail.com \
    --cc=asias.hejun@gmail.com \
    --cc=gorcunov@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=penberg@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.