<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body smarttemplateinserted="true" text="#000000" bgcolor="#FFFFFF">
    <div id="smartTemplate4-template">
      <p>After registering e.g. MSI 0 with</p>
      <p>   <tt> __s32 msifd = eventfd(0, 0);</tt></p>
      <p><tt>    struct vfio_irq_set *irq_set;</tt><tt><br>
        </tt><tt><br>
        </tt><tt>    irq_set=(struct vfio_irq_set *)malloc(sizeof(struct
          vfio_irq_set) + sizeof(__s32));</tt><tt><br>
        </tt><tt><br>
        </tt><tt>    irq_set->argsz = sizeof(struct vfio_irq_set) +
          sizeof(__s32);</tt><tt><br>
        </tt><tt>    irq_set->index = VFIO_PCI_MSI_IRQ_INDEX;</tt><tt><br>
        </tt><tt>    irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD |
          VFIO_IRQ_SET_ACTION_TRIGGER;</tt><tt><br>
        </tt><tt>    irq_set->start = 0;</tt><tt><br>
        </tt><tt>    irq_set->count = 1;</tt><tt><br>
        </tt><tt>    *(__s32*)&irq_set->data = msifd;</tt><tt><br>
        </tt><tt>    ioctl(device, VFIO_DEVICE_SET_IRQS, irq_set);</tt></p>
      <p>any read by<br>
      </p>
      <p><tt>    __u64 value = 0;</tt><tt><br>
        </tt><tt>    int ret = read(msifd,&value,sizeof(value));</tt><tt><br>
        </tt></p>
      should acknowledge the MSI, right? Or did I miss something? <br>
    </div>
    <br>
    <div id="smartTemplate4-quoteHeader"><br>
      <hr style="color:#62B3FF"><br>
      <div style="background-color: #DDDDDD; font-size:10pt"><b>From:</b>
        <a title="alex.williamson@redhat.com"
          href="mailto:alex.williamson@redhat.com">Alex Williamson</a><br>
        <b>Sent:</b> Wednesday, February 14, 2018 10:18PM<br>
        <b>To:</b> <a title="oliver.heid@h-next.de"
          href="mailto:oliver.heid@h-next.de">Heid, Oliver</a><br>
        <b>Cc:</b> <a title="vfio-users@redhat.com"
          href="mailto:vfio-users@redhat.com">Vfio-users</a><br>
        <b>Subject:</b> Re: [vfio-users] VFIO for PCIe streaming from/to
        user space</div>
      <br>
      <br>
    </div>
    <span type="cite" cite="mid:20180214141854.32f707df@w520.home"
      style="display: block; word-break: break-all; margin: 8px 0 0 0;
      padding: 0; line-height:0"></span>
    <pre wrap="">On Wed, 14 Feb 2018 22:06:35 +0100
Oliver Heid <a class="moz-txt-link-rfc2396E" href="mailto:oliver.heid@h-next.de"><oliver.heid@h-next.de></a> wrote:

</pre>
    <blockquote type="cite">
      <pre wrap="">Regarding the vfio_device_info struct: I get 9 device regions, of which 
region 0, 2 and 4 seem to be the three BAR regions. Is that so? Always? 
What do the other regions do?
</pre>
    </blockquote>
    <pre wrap="">
This is all answered in the API:

<a class="moz-txt-link-freetext" href="https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vfio.h">https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/vfio.h</a>

/*
 * The VFIO-PCI bus driver makes use of the following fixed region and
 * IRQ index mapping.  Unimplemented regions return a size of zero.
 * Unimplemented IRQ types return a count of zero.
 */
enum {
        VFIO_PCI_BAR0_REGION_INDEX,
        VFIO_PCI_BAR1_REGION_INDEX,
        VFIO_PCI_BAR2_REGION_INDEX,
        VFIO_PCI_BAR3_REGION_INDEX,
        VFIO_PCI_BAR4_REGION_INDEX,
        VFIO_PCI_BAR5_REGION_INDEX,
        VFIO_PCI_ROM_REGION_INDEX,
        VFIO_PCI_CONFIG_REGION_INDEX,
        /*
         * Expose VGA regions defined for PCI base class 03, subclass 00.
         * This includes I/O port ranges 0x3b0 to 0x3bb and 0x3c0 to 0x3df
         * as well as the MMIO range 0xa0000 to 0xbffff.  Each implemented
         * range is found at it's identity mapped offset from the region
         * offset, for example 0x3b0 is region_info.offset + 0x3b0.  Areas
         * between described ranges are unimplemented.
         */
        VFIO_PCI_VGA_REGION_INDEX,
        VFIO_PCI_NUM_REGIONS = 9 /* Fixed user ABI, region indexes >=9 use */
                                 /* device specific cap to define content. */
};

 
</pre>
    <blockquote type="cite">
      <pre wrap="">And by mmap of PCIe config space you mean mapping the files 
/sys/bus/pci/devices/0000:xx:yy.z/resource0 ?!
</pre>
    </blockquote>
    <pre wrap="">
No, use the VFIO_PCI_CONFIG_REGION_INDEX region.
</pre>
    <br>
  </body>
</html>