qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Proposal of QEMU PCI Endpoint test environment
@ 2023-08-18 13:46 Shunsuke Mie
  2023-08-23  6:09 ` Manivannan Sadhasivam
  2023-09-21  9:11 ` Kishon Vijay Abraham I
  0 siblings, 2 replies; 15+ messages in thread
From: Shunsuke Mie @ 2023-08-18 13:46 UTC (permalink / raw)
  To: Lorenzo Pieralisi, Michael S. Tsirkin
  Cc: Paolo Bonzini, Marcel Apfelbaum, qemu-devel, Rob Herring,
	Bjorn Helgaas, Linux Kernel Mailing List, linux-pci,
	Krzysztof Wilczyński, Manivannan Sadhasivam,
	Kishon Vijay Abraham I

[-- Attachment #1: Type: text/plain, Size: 3236 bytes --]

Hi all,

We are proposing to add a new test syste to Linux for PCIe Endpoint. That
can be run on QEMU without real hardware. At present, partially we have
confirmed that pci-epf-test is working, but it is not yet complete.
However, we would appreciate your comments on the architecture design.

# Background
The background is as follows.

PCI Endpoint function driver is implemented using the PCIe Endpoint
framework, but it requires physical boards for testing, and it is difficult
to test sufficiently. In order to find bugs and hardware-dependent
implementations early, continuous testing is required. Since it is
difficult to automate tests that require hardware, this RFC proposes a
virtual environment for testing PCI endpoint function drivers.

# Architecture
The overview of the architecture is as follows.

  Guest 1                        Guest 2
+-------------------------+    +----------------------------+
| Linux kernel            |    | Linux kernel               |
|                         |    |                            |
| PCI EP function driver  |    |                            |
| (e.g. pci-epf-test)     |    |                            |
|-------------------------|    | PCI Device Driver          |
| (2) QEMU EPC Driver     |    | (e.g. pci_endpoint_test)   |
+-------------------------+    +----------------------------+
+-------------------------+    +----------------------------+
| QEMU                    |    | QEMU                       |
|-------------------------|    |----------------------------|
| (1) QEMU PCI EPC Device *----* (3) QEMU EPF Bridge Device |
+-------------------------+    +----------------------------+

At present, it is designed to work guests only on the same host, and
communication is done through Unix domain sockets.

The three parts shown in the figure were introduced this time.

(1) QEMU PCI Endpoint Controller(EPC) Device
PCI Endpoint Controller implemented as QEMU PCI device.
(2) QEMU PCI Endpoint Controller(EPC) Driver
Linux kernel driver that drives the device (1). It registers a epc device
to linux kernel and handling each operations for the epc device.
(3) QEMU PCI Endpoint function(EPF) Bridge Device
QEMU PCI device that cooperates with (1) and performs accesses to pci
configuration space, BAR and memory space to communicate each guests, and
generates interruptions to the guest 1.

Each projects are:
(1), (3) https://github.com/ShunsukeMie/qemu/tree/epf-bridge/v1
files: hw/misc/{qemu-epc.{c,h}, epf-bridge.c}
(2) https://github.com/ShunsukeMie/linux-virtio-rdma/tree/qemu-epc
files: drivers/pci/controller/pcie-qemu-ep.c

# Protocol

PCI, PCIe has a layer structure that includes Physical, Data Lane and
Transaction. The communicates between the bridge(3) and controller (1)
mimic the Transaction. Specifically, a protocol is implemented for
exchanging fd for communication protocol version check and communication,
in addition to the interaction equivalent to PCIe Transaction Layer Packet
(Read and Write of I/O, Memory, Configuration space and Message). In my
mind, we need to discuss the communication mor.

We also are planning to post the patch set after the code is organized and
the protocol discussion is matured.

Best regards,
Shunsuke

[-- Attachment #2: Type: text/html, Size: 3755 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [RFC] Proposal of QEMU PCI Endpoint test environment
@ 2023-10-04  7:36 Mattias Nissler
  2023-10-05  1:31 ` Shunsuke Mie
  0 siblings, 1 reply; 15+ messages in thread
From: Mattias Nissler @ 2023-10-04  7:36 UTC (permalink / raw)
  To: cz172638
  Cc: bhelgaas, Jagannathan Raman, kishon, kvijayab, kw, levon,
	linux-kernel, linux-pci, lpieralisi, manivannan.sadhasivam,
	Marcel Apfelbaum, mie, Michael S. Tsirkin, Paolo Bonzini,
	qemu-devel, robh, thanos.makatos, vaishnav.a, william.henderson

[-- Attachment #1: Type: text/plain, Size: 2092 bytes --]

>
> hi shunsuke, all,
> what about vfio-user + qemu?
>

FWIW, I have had some good success using VFIO-user to bridge software
components to hardware designs. For the most part, I have been hooking up
software endpoint models to hardware design components speaking the PCIe
transaction layer protocol. The central piece you need is a way to
translate between the VFIO-user protocol and PCIe transaction layer
messages, basically converting ECAM accesses, memory accesses (DMA+MMIO),
and interrupts between the two worlds. I have some code which implements
the basics of that. It's certainly far from complete (TLP is a massive
protocol), but it works well enough for me. I believe we should be able to
open-source this if there's interest, let me know.

One thing to note is that there are currently some limits to bridging
VFIO-user / TLP that I haven't figured out and/or will need further work:
Advanced PCIe concepts like PASID, ATS/PRI, SR-IOV etc. may lack
equivalents on the VFIO-user side that would have to be filled in. The folk
behind libvfio-user[2] have been very approachable and open to improvements
in my experience though.

If I understand correctly, the specific goal here is testing PCIe endpoint
designs against a Linux host. What you'd need for that is a PCI host
controller for the Linux side to talk to and then hooking up endpoints on
the transaction layer. QEMU can simulate host controllers that work with
existing Linux drivers just fine. Then you can put a vfio-user-pci stub
device (I don't think this has landed in qemu yet, but you can find the
code at [1]) on the simulated PCI bus which will expose any software
interactions with the endpoint as VFIO-user protocol messages over unix
domain socket. The piece you need to bring is a VFIO-user server that
handles these messages. Its task is basically translating between VFIO-user
and TLP and then injecting TLP into your hardware design.

[1] https://github.com/oracle/qemu/tree/vfio-user-p3.1 - I believe that's
the latest version, Jagannathan Raman will know best
[2] https://github.com/nutanix/libvfio-user

[-- Attachment #2: Type: text/html, Size: 2513 bytes --]

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2023-10-06 12:08 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-18 13:46 [RFC] Proposal of QEMU PCI Endpoint test environment Shunsuke Mie
2023-08-23  6:09 ` Manivannan Sadhasivam
2023-08-25  8:56   ` Shunsuke Mie
2023-09-21  9:11 ` Kishon Vijay Abraham I
2023-09-26  7:26   ` Christoph Hellwig
2023-09-26  9:47   ` Shunsuke Mie
2023-09-26 12:40     ` Vaishnav Achath
2023-10-03  4:56       ` Shunsuke Mie
2023-10-03 14:31         ` Jiri Kastner
  -- strict thread matches above, loose matches on Subject: below --
2023-10-04  7:36 Mattias Nissler
2023-10-05  1:31 ` Shunsuke Mie
2023-10-05  7:02   ` Mattias Nissler
2023-10-06 11:51     ` Shunsuke Mie
2023-10-06 12:00       ` Mattias Nissler
2023-10-06 12:07       ` Thanos Makatos

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).