>From 9d8ae91934b34d303f43ff3c7613eb75bf519d3b Mon Sep 17 00:00:00 2001 From: Vadim Rozenfeld <vrozenfe@xxxxxxxxxx> Date: Mon, 2 May 2011 14:07:49 +0300 Subject: [COMMIT] [viostor] check if msi-x is enabled --- viostor/virtio_pci.c | 2 +- viostor/virtio_stor.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ viostor/virtio_stor.h | 1 + 3 files changed, 65 insertions(+), 1 deletions(-) diff --git a/viostor/virtio_pci.c b/viostor/virtio_pci.c index 6bc75a1..33693c4 100644 --- a/viostor/virtio_pci.c +++ b/viostor/virtio_pci.c @@ -67,7 +67,7 @@ VirtIODeviceGet( RhelDbgPrint(TRACE_LEVEL_VERBOSE, ("%s\n", __FUNCTION__)); - ioaddr = adaptExt->device_base + VIRTIO_PCI_CONFIG((adaptExt->msix_vectors > 0)) + offset; + ioaddr = adaptExt->device_base + VIRTIO_PCI_CONFIG(adaptExt->msix_enabled) + offset; for (i = 0; i < len; i++) { ptr[i] = ScsiPortReadPortUchar((PUCHAR)(ioaddr + i)); diff --git a/viostor/virtio_stor.c b/viostor/virtio_stor.c index 52e023b..0e683c0 100644 --- a/viostor/virtio_stor.c +++ b/viostor/virtio_stor.c @@ -198,6 +198,12 @@ VirtIoFindAdapter( ULONG vq_sz; USHORT pageNum; +#ifdef MSI_SUPPORTED + PPCI_COMMON_CONFIG pPciConf = NULL; + UCHAR pci_cfg_buf[256]; + ULONG pci_cfg_len; +#endif + UNREFERENCED_PARAMETER( HwContext ); UNREFERENCED_PARAMETER( BusInformation ); UNREFERENCED_PARAMETER( ArgumentString ); @@ -294,6 +300,63 @@ VirtIoFindAdapter( return SP_RETURN_ERROR; } + adaptExt->msix_enabled = FALSE; + +#ifdef MSI_SUPPORTED + pci_cfg_len = StorPortGetBusData (DeviceExtension, + PCIConfiguration, + ConfigInfo->SystemIoBusNumber, + (ULONG)ConfigInfo->SlotNumber, + (PVOID)pci_cfg_buf, + (ULONG)256); + if (pci_cfg_len == 256) + { + UCHAR CapOffset; + PPCI_MSIX_CAPABILITY pMsixCapOffset; + + pPciConf = (PPCI_COMMON_CONFIG)pci_cfg_buf; + if ( (pPciConf->Status & PCI_STATUS_CAPABILITIES_LIST) == 0) + { + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("NO CAPABILITIES_LIST \n")); + } + else + { + if ( (pPciConf->HeaderType & (~PCI_MULTIFUNCTION)) == PCI_DEVICE_TYPE ) + { + CapOffset = pPciConf->u.type0.CapabilitiesPtr; + while (CapOffset != 0) + { + pMsixCapOffset = (PPCI_MSIX_CAPABILITY)(pci_cfg_buf + CapOffset); + if ( pMsixCapOffset->Header.CapabilityID == PCI_CAPABILITY_ID_MSIX ) + { + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("MessageControl.TableSize = %d\n", pMsixCapOffset->MessageControl.TableSize)); + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("MessageControl.FunctionMask = %d\n", pMsixCapOffset->MessageControl.FunctionMask)); + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("MessageControl.MSIXEnable = %d\n", pMsixCapOffset->MessageControl.MSIXEnable)); + + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("MessageTable = %p\n", pMsixCapOffset->MessageTable)); + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("PBATable = %d\n", pMsixCapOffset->PBATable)); + adaptExt->msix_enabled = (pMsixCapOffset->MessageControl.MSIXEnable == 1); + break; + } + else + { + CapOffset = pMsixCapOffset->Header.Next; + RhelDbgPrint(TRACE_LEVEL_INFORMATION, ("CapabilityID = %x, Next CapOffset = %x\n", pMsixCapOffset->Header.CapabilityID, CapOffset)); + } + } + } + else + { + RhelDbgPrint(TRACE_LEVEL_FATAL, ("NOT A PCI_DEVICE_TYPE \n")); + } + } + } + else + { + RhelDbgPrint(TRACE_LEVEL_FATAL, ("CANNOT READ PCI CONFIGURATION SPACE %d\n", pci_cfg_len)); + } +#endif + VirtIODeviceReset(DeviceExtension); ScsiPortWritePortUshort((PUSHORT)(adaptExt->device_base + VIRTIO_PCI_QUEUE_SEL), (USHORT)0); if (adaptExt->dump_mode) { diff --git a/viostor/virtio_stor.h b/viostor/virtio_stor.h index 94e8f66..dc0c07a 100644 --- a/viostor/virtio_stor.h +++ b/viostor/virtio_stor.h @@ -114,6 +114,7 @@ typedef struct _ADAPTER_EXTENSION { BOOLEAN dump_mode; LIST_ENTRY list_head; ULONG msix_vectors; + BOOLEAN msix_enabled; ULONG features; BOOLEAN flush_done; #ifdef USE_STORPORT -- 1.7.0.2.msysgit.0 -- To unsubscribe from this list: send the line "unsubscribe kvm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html