From: Kirti Wankhede Subject: Re: [PATCH 2/3] VFIO driver for mediated PCI device Date: Wed, 29 Jun 2016 00:15:23 +0530 Message-ID: <75c10494-b983-d3a9-489f-66accc68c1ae@nvidia.com> References: <1466440308-4961-1-git-send-email-kwankhede@nvidia.com> <1466440308-4961-3-git-send-email-kwankhede@nvidia.com> <20160621164827.5289530a@t450s.home> <20160624134556.2826529c@t450s.home> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Cc: , , , , , , , , , To: Alex Williamson Return-path: Received: from hqemgate16.nvidia.com ([216.228.121.65]:2463 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751419AbcF1Spl (ORCPT ); Tue, 28 Jun 2016 14:45:41 -0400 In-Reply-To: <20160624134556.2826529c@t450s.home> Sender: kvm-owner@vger.kernel.org List-ID: On 6/25/2016 1:15 AM, Alex Williamson wrote: > On Sat, 25 Jun 2016 00:04:27 +0530 > Kirti Wankhede wrote: > >>>> + >>>> +static int mdev_get_irq_count(struct vfio_mdev *vmdev, int irq_type) >>>> +{ >>>> + /* Don't support MSIX for now */ >>>> + if (irq_type == VFIO_PCI_MSIX_IRQ_INDEX) >>>> + return -1; >>>> + >>>> + return 1; >>> >>> Too much hard coding here, the mediated driver should define this. >>> >> >> I'm testing INTX and MSI, I don't have a way to test MSIX for now. So we >> thought we can add supported for MSIX later. Till then hard code it to 1. > > To me it screams that there needs to be an interface to the mediated > device here. How do you even know that the mediated device intends to > support MSI? What if it wants to emulated a VF and not support INTx? > This is basically just a big "TODO" flag that needs to be addressed > before a non-RFC. > VFIO user space app reads emulated PCI config space of mediated device. In PCI capability list when MSI capability (PCI_CAP_ID_MSI) is present, it calls VFIO_DEVICE_SET_IRQS ioctl with irq_set->index set to VFIO_PCI_MSI_IRQ_INDEX. Similarly, MSIX is identified from emulated config space of mediated device that checks if MSI capability is present and number of vectors extracted from PCI_MSI_FLAGS_QSIZE flag. vfio_mpci modules don't need to query it from vendor driver of mediated device. Depending on which interrupt to support, mediated driver should emulate PCI config space. Thanks, Kirti.