* VFIO MSIX Query
@ 2016-05-03 18:42 Saxena, Nitin
0 siblings, 0 replies; 5+ messages in thread
From: Saxena, Nitin @ 2016-05-03 18:42 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
I am a newbie to VFIO framework and trying to use it for MSIX interrupt handling in my userspace application. My userspace application is like intel's dpdk.
My query is why vfio kernel code does not support msix masking/ unmasking i.e VFIO_SET_ACTION_TRIGGER is not implemented in kernel vfio code for MSIX but its present for legacy INTX?
Another question since MSIX interrupt masking is absent in kernel who is supposed to mask/unmask msix interrupt? does userspace needs to mask/unmask interrupt after getting notified by eventfd. Is there any usecase where MSIX handling is done via VFIO framework?
Thanks,
Nitin
Regards,
Nitin
^ permalink raw reply [flat|nested] 5+ messages in thread
* VFIO MSIX Query
[not found] <CAB995Mu0==PJ0iU4h_3oAMGo-VYDFrjOg_BO757M=PDWgMWtCw@mail.gmail.com>
@ 2016-05-03 20:02 ` Alex Williamson
2016-05-04 2:12 ` Saxena, Nitin
[not found] ` <CAB995MsFjv=GvHSmo029fmuTWhGiYev3-2A358orFz_dq724Fw@mail.gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Alex Williamson @ 2016-05-03 20:02 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
On Tue, 3 May 2016 23:56:38 +0530
Nitin Saxena <nitin.lnx@gmail.com> wrote:
> Hi,
>
> I am a newbie to VFIO framework and trying to use it for MSIX interrupt
> handling in my userspace application. My userspace application is like
> intel's dpdk.
>
> My query is why vfio kernel code does not support msix masking/ unmasking
> i.e VFIO_SET_ACTION_TRIGGER is not implemented in kernel vfio code for MSIX
> but its present for legacy INTX?
I think you mean VFIO_IRQ_SET_ACTION_MASK and
VFIO_IRQ_SET_ACTION_UNMASK are not implemented for MSI/X,
VFIO_IRQ_SET_ACTION_TRIGGER is the only one that is implemented. It
mostly comes down to it hasn't been needed. We would just need to
verify that disable_irq() and enable_irq() do the right thing and
enable the features through the existing VFIO API. The reason we have
these for INTx is that INTx is level triggered and we must mask the
interrupt on the host while it's serviced by the user because the
interrupt will continue to assert and we have no service guarantees
from the user. MSI/X is of course edge triggered, so doesn't have this
problem. The device would need to continue to re-assert the
interrupt. In cases like a QEMU user, we might want to continue to
receive guest masked interrupts to QEMU for emulating the pending bits
array, so even if we had VFIO masking support for these interrupts, QEMU
probably would not use it. If MSI/X masking is useful for you vs simply
ignoring the eventfd, patches welcome.
> Another question since MSIX interrupt masking is absent in kernel who is
> supposed to mask/unmask msix interrupt? does userspace needs to mask/unmask
> interrupt after getting notified by eventfd. Is there any usecase where
> MSIX handling is done via VFIO framework?
MSI/X is edge triggered and VFIO does not set the AUTOMASKED flag on
them, so there is simply no masking of them at all aside from fully
disabling them. QEMU has full support for MSI/X through VFIO that you
can use for reference. Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* VFIO MSIX Query
2016-05-03 20:02 ` VFIO MSIX Query Alex Williamson
@ 2016-05-04 2:12 ` Saxena, Nitin
[not found] ` <CAB995MsFjv=GvHSmo029fmuTWhGiYev3-2A358orFz_dq724Fw@mail.gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Saxena, Nitin @ 2016-05-04 2:12 UTC (permalink / raw)
To: linux-arm-kernel
Got it. Thanks Alex. I may have future queries as well on this. Will get back to you.
Thanks,
Nitin
> On 04-May-2016, at 01:33, Alex Williamson <alex.williamson@redhat.com> wrote:
>
> Hi,
>
> On Tue, 3 May 2016 23:56:38 +0530
> Nitin Saxena <nitin.lnx@gmail.com> wrote:
>
>> Hi,
>>
>> I am a newbie to VFIO framework and trying to use it for MSIX interrupt
>> handling in my userspace application. My userspace application is like
>> intel's dpdk.
>>
>> My query is why vfio kernel code does not support msix masking/ unmasking
>> i.e VFIO_SET_ACTION_TRIGGER is not implemented in kernel vfio code for MSIX
>> but its present for legacy INTX?
>
> I think you mean VFIO_IRQ_SET_ACTION_MASK and
> VFIO_IRQ_SET_ACTION_UNMASK are not implemented for MSI/X,
> VFIO_IRQ_SET_ACTION_TRIGGER is the only one that is implemented. It
> mostly comes down to it hasn't been needed. We would just need to
> verify that disable_irq() and enable_irq() do the right thing and
> enable the features through the existing VFIO API. The reason we have
> these for INTx is that INTx is level triggered and we must mask the
> interrupt on the host while it's serviced by the user because the
> interrupt will continue to assert and we have no service guarantees
> from the user. MSI/X is of course edge triggered, so doesn't have this
> problem. The device would need to continue to re-assert the
> interrupt. In cases like a QEMU user, we might want to continue to
> receive guest masked interrupts to QEMU for emulating the pending bits
> array, so even if we had VFIO masking support for these interrupts, QEMU
> probably would not use it. If MSI/X masking is useful for you vs simply
> ignoring the eventfd, patches welcome.
>
>> Another question since MSIX interrupt masking is absent in kernel who is
>> supposed to mask/unmask msix interrupt? does userspace needs to mask/unmask
>> interrupt after getting notified by eventfd. Is there any usecase where
>> MSIX handling is done via VFIO framework?
>
> MSI/X is edge triggered and VFIO does not set the AUTOMASKED flag on
> them, so there is simply no masking of them at all aside from fully
> disabling them. QEMU has full support for MSI/X through VFIO that you
> can use for reference. Thanks,
>
> Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* VFIO MSIX Query
[not found] ` <CAB995MsFjv=GvHSmo029fmuTWhGiYev3-2A358orFz_dq724Fw@mail.gmail.com>
@ 2016-05-08 1:50 ` Alex Williamson
[not found] ` <CAB995MvxU+mN9uxr_20nLkoezyhedUAHdFWawk-GG_bj0YjSYw@mail.gmail.com>
0 siblings, 1 reply; 5+ messages in thread
From: Alex Williamson @ 2016-05-08 1:50 UTC (permalink / raw)
To: linux-arm-kernel
Hi Nitin,
On Sat, 7 May 2016 21:09:09 +0530
Nitin Saxena <nitin.lnx@gmail.com> wrote:
> Hi Alex,
>
> I have specific questions related to the problem I am facing in using VFIO
> for MSIX interrupt.
>
> My userspace program running on x86 talks to NIC connected via PCIe
> interface. Current program works fine in poll mode with no VF and SRIOV
> requirement. I am changing my app from poll mode to interrupt mode using
> VFIO NOIOMMU feature as I am interested in getting MSIX interrupts only
> (For this I have ported VFIO-NOIOMMU feature patch from kernel 4.5 to 3.10
> SL7). After applying the patch I can see /dev/vfio/noiommu-X and I could
> assign my PCI device to /dev/vfio/noiommu-0. Seems like kernel patch
> applied from 4.5 to 3.10 working fine. Also MSIX interrupts works fine with
> another kernel application but I am facing issues in using MSIX interrupts
> with my userspace program integrated with VFIO. I am running single process
> only with one MSIX interrupt requirement
>
> Few Questions:
>
> Q1) VFIO_GROUP_GET_DEVICE_FD ioctl call stops poll mode data traffic. Why?
> I used my poll mode data path loop (where I am not waiting for MSIX) with
> my vfio_init() API I found that if I call follow VFIO sequence in
> vfio_init():
> a) create container fd (b) get group_fd (c) VFIO_SET_IOMMU as NOIOMMU ==>
> then my poll mode data path works fine
> but if I call a) create container fd (b) get group_fd (c) VFIO_SET_IOMMU as
> NOIOMMU (d) VFIO_GROUP_GET_DEVICE_FD ==> then my poll mode data path does
> not work. I don't know why
It sounds like you're trying to mix VFIO with some other access to the
device, perhaps through pci-sysfs. This is not compatible with VFIO.
Use VFIO for all access to the device or none. When the device is
initially opened via the GET_DEVICE_FD ioctl, we go through an
initialization sequence on the device, including a device reset. VFIO
is not meant to only provide MSI-X on top of a some other access
mechanism.
> Q2)Does MSIX bar/table mapping required for my case. Why?
> Even if VFIO is not used in my userspace program, BAR0 and BAR1 was already
> mmapped to process but not MSIX table. Do I need to mmap MSIX table in my
> interrupt based data path as I saw this mmaping of MSIX table in QEMU and
> dpdk both but I think these software must be using VFIO_IOMMU_TYPE1 and not
> VFIO_NOIOMMU which is my case. So can you confirm is it needed for me to
> mmap MSIX table.
Again, no mixing interfaces. Use VFIO for all access to the device or
don't use VFIO at all. Regardless, there's no need to mmap the MSI-X
table. VFIO does not currently allow mmap of the MSI-X table. If at
some point it is allowed, attempting to manipulate MSI-X via the device
vector table directly is not supported. Only the SET_IRQS ioctl is
used for configuring device interrupts.
> Q3) Does VFIO_DEVICE_RESET required, when and why ?
> My userspace program implicitly resets PCI hardware and then I call my
> vfio_init() API and then start data path. So at what point I should can
> VFIO_DEVICE_RESET?
This is wrong, VFIO is the access to the device, any combination of
other access mechanisms plus VFIO is not supported and not intended to
work. VFIO will attempt to reset the device when opened, any other
reset is at the user driver's discretion.
> Q4) Is there any Do's and Dont's document for VFIO so that I can follow
> proper sequence.
Don't #1: Don't attempt to add VFIO only for MSI-X support, use it for
all access to the device or don't use it at all. There's
Documentation/vfio.txt and QEMU as the de facto standard usage example,
that's it afaik. Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
* VFIO MSIX Query
[not found] ` <CAB995MvxU+mN9uxr_20nLkoezyhedUAHdFWawk-GG_bj0YjSYw@mail.gmail.com>
@ 2016-05-09 15:20 ` Alex Williamson
0 siblings, 0 replies; 5+ messages in thread
From: Alex Williamson @ 2016-05-09 15:20 UTC (permalink / raw)
To: linux-arm-kernel
On Sun, 8 May 2016 20:45:10 +0530
Nitin Saxena <nitin.lnx@gmail.com> wrote:
> Hi Alex,
>
> Thanks for your answer. I got the point that all access to device must be
> VFIO.
> I have few more questions.
>
> >> When the device is initially opened via the VFIO_GET_DEVICE_FD ioctl, we
> go through an initialization sequence on the device, including a device
> reset
> Does this mean only one process (primary in multiprocess app) can only
> perform VFIO_GROUP_GET_DEVICE_FD ioctl ? which I doubt as I saw in dpdk
> that each process (regardless primary or not) does VFIO_GROUP_GET_DEVICE_FD
> ioctl. Kindly confirm.
Users can call GET_DEVICE_FD multiple times, but note that the group
file descriptor can only be opened once, so you'd need to pass
device file descriptors off to other threads.
> >> Use VFIO for all access to the device or don't use VFIO at all.
> I will map PCI BARS via VFIO but what about hugepages for each process.
> Since I am using VFIO_NOIOMMU do I need to call VFIO_IOMMU_MAP_DMA ioctl
> for each hugepage of each process? I think this is not needed in my case.
> Please confirm.
No-IOMMU mode does not have MAP_DMA or UNMAP_DMA ioctls. If you want
to support a safe operating mode, with an IOMMU providing DMA
isolation, then yes, you would need to map DMA targets for the device
using those ioctls for the type1 IOMMU backend.
> Can you please also confirm about the patch I attached. Is there any thing
> missing in the patch that I needed to incorporate from kernel 4.5 to make
> VFO NOIOMMU work? Patch
I can't confirm or deny whether the backport is accurate. Thanks,
Alex
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-05-09 15:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAB995Mu0==PJ0iU4h_3oAMGo-VYDFrjOg_BO757M=PDWgMWtCw@mail.gmail.com>
2016-05-03 20:02 ` VFIO MSIX Query Alex Williamson
2016-05-04 2:12 ` Saxena, Nitin
[not found] ` <CAB995MsFjv=GvHSmo029fmuTWhGiYev3-2A358orFz_dq724Fw@mail.gmail.com>
2016-05-08 1:50 ` Alex Williamson
[not found] ` <CAB995MvxU+mN9uxr_20nLkoezyhedUAHdFWawk-GG_bj0YjSYw@mail.gmail.com>
2016-05-09 15:20 ` Alex Williamson
2016-05-03 18:42 Saxena, Nitin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).