From 4c89e3e59368584ae6f34fdfce3c698223b8a918 Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 7 Oct 2013 10:36:37 +0300 Subject: hw/vmxnet3: set interrupts using pci irq wrappers pci_set_irq uses PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. An assert is used to ensure that intx received from the quest OS corresponds to PCI_INTERRUPT_PIN. Signed-off-by: Marcel Apfelbaum Signed-off-by: Michael S. Tsirkin --- hw/net/vmxnet3.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'hw/net') diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c index 49c2466..19687aa 100644 --- a/hw/net/vmxnet3.c +++ b/hw/net/vmxnet3.c @@ -336,7 +336,7 @@ static bool _vmxnet3_assert_interrupt_line(VMXNET3State *s, uint32_t int_idx) } VMW_IRPRN("Asserting line for interrupt %u", int_idx); - qemu_set_irq(d->irq[int_idx], 1); + pci_irq_assert(d); return true; } @@ -356,7 +356,7 @@ static void _vmxnet3_deassert_interrupt_line(VMXNET3State *s, int lidx) assert(!s->msi_used || !msi_enabled(d)); VMW_IRPRN("Deasserting line for interrupt %u", lidx); - qemu_set_irq(d->irq[lidx], 0); + pci_irq_deassert(d); } static void vmxnet3_update_interrupt_line_state(VMXNET3State *s, int lidx) @@ -1299,6 +1299,12 @@ static void vmxnet3_update_features(VMXNET3State *s) } } +static bool vmxnet3_verify_intx(VMXNET3State *s, int intx) +{ + return s->msix_used || s->msi_used || (intx == + (pci_get_byte(s->parent_obj.config + PCI_INTERRUPT_PIN) - 1)); +} + static void vmxnet3_activate_device(VMXNET3State *s) { int i; @@ -1332,6 +1338,7 @@ static void vmxnet3_activate_device(VMXNET3State *s) s->event_int_idx = VMXNET3_READ_DRV_SHARED8(s->drv_shmem, devRead.intrConf.eventIntrIdx); + assert(vmxnet3_verify_intx(s, s->event_int_idx)); VMW_CFPRN("Events interrupt line is %u", s->event_int_idx); s->auto_int_masking = @@ -1364,6 +1371,7 @@ static void vmxnet3_activate_device(VMXNET3State *s) /* Read interrupt number for this TX queue */ s->txq_descr[i].intr_idx = VMXNET3_READ_TX_QUEUE_DESCR8(qdescr_pa, conf.intrIdx); + assert(vmxnet3_verify_intx(s, s->txq_descr[i].intr_idx)); VMW_CFPRN("TX Queue %d interrupt: %d", i, s->txq_descr[i].intr_idx); @@ -1411,6 +1419,7 @@ static void vmxnet3_activate_device(VMXNET3State *s) /* Read interrupt number for this RX queue */ s->rxq_descr[i].intr_idx = VMXNET3_READ_TX_QUEUE_DESCR8(qd_pa, conf.intrIdx); + assert(vmxnet3_verify_intx(s, s->rxq_descr[i].intr_idx)); VMW_CFPRN("RX Queue %d interrupt: %d", i, s->rxq_descr[i].intr_idx); -- cgit v1.1 From 9e64f8a3fcc88a508990a62ecc5a1269e41272ad Mon Sep 17 00:00:00 2001 From: Marcel Apfelbaum Date: Mon, 7 Oct 2013 10:36:39 +0300 Subject: hw: set interrupts using pci irq wrappers pci_set_irq and the other pci irq wrappers use PCI_INTERRUPT_PIN config register to compute device INTx pin to assert/deassert. An irq is allocated using pci_allocate_irq wrapper only if is needed by non pci devices. Removed irq related fields from state if not used anymore. Signed-off-by: Marcel Apfelbaum Signed-off-by: Michael S. Tsirkin --- hw/net/e1000.c | 2 +- hw/net/eepro100.c | 4 ++-- hw/net/ne2000.c | 3 ++- hw/net/pcnet-pci.c | 3 ++- hw/net/rtl8139.c | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) (limited to 'hw/net') diff --git a/hw/net/e1000.c b/hw/net/e1000.c index d3f274c..a37a3df 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -325,7 +325,7 @@ set_interrupt_cause(E1000State *s, int index, uint32_t val) } s->mit_irq_level = (pending_ints != 0); - qemu_set_irq(d->irq[0], s->mit_irq_level); + pci_set_irq(d, s->mit_irq_level); } static void diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index ffa60d5..3b891ca 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -409,7 +409,7 @@ static void disable_interrupt(EEPRO100State * s) { if (s->int_stat) { TRACE(INT, logout("interrupt disabled\n")); - qemu_irq_lower(s->dev.irq[0]); + pci_irq_deassert(&s->dev); s->int_stat = 0; } } @@ -418,7 +418,7 @@ static void enable_interrupt(EEPRO100State * s) { if (!s->int_stat) { TRACE(INT, logout("interrupt enabled\n")); - qemu_irq_raise(s->dev.irq[0]); + pci_irq_assert(&s->dev); s->int_stat = 1; } } diff --git a/hw/net/ne2000.c b/hw/net/ne2000.c index c961258..a94cf74 100644 --- a/hw/net/ne2000.c +++ b/hw/net/ne2000.c @@ -731,7 +731,7 @@ static int pci_ne2000_init(PCIDevice *pci_dev) s = &d->ne2000; ne2000_setup_io(s, DEVICE(pci_dev), 0x100); pci_register_bar(&d->dev, 0, PCI_BASE_ADDRESS_SPACE_IO, &s->io); - s->irq = d->dev.irq[0]; + s->irq = pci_allocate_irq(&d->dev); qemu_macaddr_default_if_unset(&s->c.macaddr); ne2000_reset(s); @@ -752,6 +752,7 @@ static void pci_ne2000_exit(PCIDevice *pci_dev) memory_region_destroy(&s->io); qemu_del_nic(s->nic); + qemu_free_irq(s->irq); } static Property ne2000_properties[] = { diff --git a/hw/net/pcnet-pci.c b/hw/net/pcnet-pci.c index a893165..311594d 100644 --- a/hw/net/pcnet-pci.c +++ b/hw/net/pcnet-pci.c @@ -282,6 +282,7 @@ static void pci_pcnet_uninit(PCIDevice *dev) { PCIPCNetState *d = PCI_PCNET(dev); + qemu_free_irq(d->state.irq); memory_region_destroy(&d->state.mmio); memory_region_destroy(&d->io_bar); timer_del(d->state.poll_timer); @@ -331,7 +332,7 @@ static int pci_pcnet_init(PCIDevice *pci_dev) pci_register_bar(pci_dev, 1, 0, &s->mmio); - s->irq = pci_dev->irq[0]; + s->irq = pci_allocate_irq(pci_dev); s->phys_mem_read = pci_physical_memory_read; s->phys_mem_write = pci_physical_memory_write; s->dma_opaque = pci_dev; diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index c31199f..7d72b21 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -716,7 +716,7 @@ static void rtl8139_update_irq(RTL8139State *s) DPRINTF("Set IRQ to %d (%04x %04x)\n", isr ? 1 : 0, s->IntrStatus, s->IntrMask); - qemu_set_irq(d->irq[0], (isr != 0)); + pci_set_irq(d, (isr != 0)); } static int rtl8139_RxWrap(RTL8139State *s) -- cgit v1.1