title: Detect transaction from PCIe endpoint to host memory in Linux
body: <p>I'm building an FPGA design in which some devices (CPU, UART, GPIO controller) are connected to an AXI4 bus. The AXI4 bus is connected to the host via Xilinx' "AXI Memory Mapped to PCI Express (PCIe) Gen2 v2.6 LogiCORE IP", which acts as a bridge. The subsystem residing on the FPGA interfaces via PCIe with a Linux driver. This driver creates a device file to provide an interface to a computer system simulator running on the host, a so-called virtual platform (VP). Part of the system components will be simulated in the VP, whereas the rest of the components are implemented on the FPGA. The system bus of the VP is connected transparently to the AXI4 bus on the FPGA via the driver and the aforementioned bridge. Transactions originating on the host are already implemented and working correctly.</p>
  
  <p>I'd like to know if there's a way of detecting a PCIe read or write transaction within a Linux driver, whereas the transaction is issued by the PCIe endpoint acting as a bus master.</p>
  
  <p>So far, my ideas are:
  (i) to instantiate a DMA controller on the FPGA, which issues a message-signaled interrupt (MSI) to the host at the end of each transfer. The driver can then retrieve the starting address and size of the transfer from the DMA's control registers.
  (ii) to allocate a buffer on the host, from / to which the PCIe bus master reads / writes. This buffer would need to be polled in order to detect changes, which to me seems inefficient, especially for large buffers.</p>
  
  <p>Does somebody have an idea for a better solution? This is my first question here. Please excuse that my question became a bit lengthy. Any feedback will be highly appreciated.</p>