mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-06-16 02:15:47 +00:00
kvm tools: Simplify msi message handling
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> Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
+1
-4
@@ -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;
|
||||
}
|
||||
|
||||
+3
-1
@@ -4,6 +4,8 @@
|
||||
#include <linux/types.h>
|
||||
#include <linux/rbtree.h>
|
||||
#include <linux/list.h>
|
||||
#include <linux/kvm.h>
|
||||
#include <linux/msi.h>
|
||||
|
||||
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
|
||||
|
||||
+3
-4
@@ -2,8 +2,9 @@
|
||||
#define KVM__PCI_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
#include <linux/kvm.h>
|
||||
#include <linux/pci_regs.h>
|
||||
#include <linux/msi.h>
|
||||
|
||||
/*
|
||||
* 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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-8
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user