diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2008-08-13 13:45:39 +0100 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2008-08-13 13:45:39 +0100 |
commit | f9307cbb49b5a29a298b0154b651af60d7d08883 (patch) | |
tree | 7be96fa01613f675973e269e5ac083b322ddff09 /tools | |
parent | 68c053e8a96b009f9ba518ebbc01f4df16cbbe4e (diff) | |
download | xen-f9307cbb49b5a29a298b0154b651af60d7d08883.tar.gz xen-f9307cbb49b5a29a298b0154b651af60d7d08883.tar.bz2 xen-f9307cbb49b5a29a298b0154b651af60d7d08883.zip |
MSI-X: enhancement
Signed-off-by: Yu Zhao <yu.zhao@intel.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/ioemu/hw/pass-through.h | 1 | ||||
-rw-r--r-- | tools/ioemu/hw/pt-msi.c | 24 | ||||
-rw-r--r-- | tools/libxc/xc_physdev.c | 10 | ||||
-rw-r--r-- | tools/libxc/xenctrl.h | 2 |
4 files changed, 17 insertions, 20 deletions
diff --git a/tools/ioemu/hw/pass-through.h b/tools/ioemu/hw/pass-through.h index 43a27c5f77..fa5357e14b 100644 --- a/tools/ioemu/hw/pass-through.h +++ b/tools/ioemu/hw/pass-through.h @@ -120,6 +120,7 @@ struct pt_msix_info { int enabled; int total_entries; int bar_index; + uint64_t table_base; uint32_t table_off; uint64_t mmio_base_addr; int mmio_index; diff --git a/tools/ioemu/hw/pt-msi.c b/tools/ioemu/hw/pt-msi.c index 68a952f059..98e485e076 100644 --- a/tools/ioemu/hw/pt-msi.c +++ b/tools/ioemu/hw/pt-msi.c @@ -38,8 +38,8 @@ int pt_msi_setup(struct pt_dev *dev) } if ( xc_physdev_map_pirq_msi(xc_handle, domid, AUTO_ASSIGN, &pirq, - dev->pci_dev->dev << 3 | dev->pci_dev->func, - dev->pci_dev->bus, 0, 1) ) + dev->pci_dev->dev << 3 | dev->pci_dev->func, + dev->pci_dev->bus, 0, 0) ) { PT_LOG("error map msi\n"); return -1; @@ -121,7 +121,8 @@ static int pt_msix_update_one(struct pt_dev *dev, int entry_nr) { ret = xc_physdev_map_pirq_msi(xc_handle, domid, AUTO_ASSIGN, &pirq, dev->pci_dev->dev << 3 | dev->pci_dev->func, - dev->pci_dev->bus, entry_nr, 0); + dev->pci_dev->bus, entry_nr, + dev->msix->table_base); if ( ret ) { PT_LOG("error map msix entry %x\n", entry_nr); @@ -183,7 +184,7 @@ static void pci_msix_writel(void *opaque, target_phys_addr_t addr, uint32_t val) entry = &msix->msix_entry[entry_nr]; offset = ((addr - msix->mmio_base_addr) % 16) / 4; - if ( offset != 3 && msix->enabled && entry->io_mem[3] & 0x1 ) + if ( offset != 3 && msix->enabled && !(entry->io_mem[3] & 0x1) ) { PT_LOG("can not update msix entry %d since MSI-X is already \ function now.\n", entry_nr); @@ -196,7 +197,7 @@ static void pci_msix_writel(void *opaque, target_phys_addr_t addr, uint32_t val) if ( offset == 3 ) { - if ( !(val & 0x1) ) + if ( msix->enabled && !(val & 0x1) ) pt_msix_update_one(dev, entry_nr); mask_physical_msix_entry(dev, entry_nr, entry->io_mem[3] & 0x1); } @@ -280,7 +281,6 @@ int pt_msix_init(struct pt_dev *dev, int pos) uint8_t id; uint16_t control; int i, total_entries, table_off, bar_index; - uint64_t bar_base; struct pci_dev *pd = dev->pci_dev; id = pci_read_byte(pd, pos + PCI_CAP_LIST_ID); @@ -314,18 +314,14 @@ int pt_msix_init(struct pt_dev *dev, int pos) table_off = pci_read_long(pd, pos + PCI_MSIX_TABLE); bar_index = dev->msix->bar_index = table_off & PCI_MSIX_BIR; table_off &= table_off & ~PCI_MSIX_BIR; - bar_base = pci_read_long(pd, 0x10 + 4 * bar_index); - if ( (bar_base & 0x6) == 0x4 ) - { - bar_base &= ~0xf; - bar_base += (uint64_t)pci_read_long(pd, 0x10 + 4 * (bar_index + 1)) << 32; - } - PT_LOG("get MSI-X table bar base %lx\n", bar_base); + dev->msix->table_base = dev->pci_dev->base_addr[bar_index]; + PT_LOG("get MSI-X table bar base %llx\n", + (unsigned long long)dev->msix->table_base); dev->msix->fd = open("/dev/mem", O_RDWR); dev->msix->phys_iomem_base = mmap(0, total_entries * 16, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_LOCKED, - dev->msix->fd, bar_base + table_off); + dev->msix->fd, dev->msix->table_base + table_off); PT_LOG("mapping physical MSI-X table to %lx\n", (unsigned long)dev->msix->phys_iomem_base); return 0; diff --git a/tools/libxc/xc_physdev.c b/tools/libxc/xc_physdev.c index b320f19dc8..ec0ebbeb76 100644 --- a/tools/libxc/xc_physdev.c +++ b/tools/libxc/xc_physdev.c @@ -51,7 +51,7 @@ int xc_physdev_map_pirq_msi(int xc_handle, int devfn, int bus, int entry_nr, - int msi_type) + uint64_t table_base) { int rc; struct physdev_map_pirq map; @@ -63,10 +63,10 @@ int xc_physdev_map_pirq_msi(int xc_handle, map.type = MAP_PIRQ_TYPE_MSI; map.index = index; map.pirq = *pirq; - map.msi_info.devfn = devfn; - map.msi_info.bus = bus; - map.msi_info.entry_nr = entry_nr; - map.msi_info.msi = msi_type; + map.bus = bus; + map.devfn = devfn; + map.entry_nr = entry_nr; + map.table_base = table_base; rc = do_physdev_op(xc_handle, PHYSDEVOP_map_pirq, &map); diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index 0639d3fd23..341d117695 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -917,7 +917,7 @@ int xc_physdev_map_pirq_msi(int xc_handle, int devfn, int bus, int entry_nr, - int msi_type); + uint64_t table_base); int xc_physdev_unmap_pirq(int xc_handle, int domid, |