RE: [EXT] Re: [RFC PATCH 4/4] PCI: endpoint: function: Add EP function driver to provide virtio net device

From: Frank Li
Date: Fri Feb 03 2023 - 17:16:26 EST


>
> Caution: EXT Email
>
> On Fri, Feb 03, 2023 at 07:04:18PM +0900, Shunsuke Mie wrote:
> > Add a new endpoint(EP) function driver to provide virtio-net device. This
> > function not only shows virtio-net device for PCIe host system, but also
> > provides virtio-net device to EP side(local) system. Virtualy those network
> > devices are connected, so we can use to communicate over IP like a simple
> > NIC.
> >
> > Architecture overview is following:
> >
> > to Host | to Endpoint
> > network stack | network stack
> > | | |
> > +-----------+ | +-----------+ +-----------+
> > |virtio-net | | |virtio-net | |virtio-net |
> > |driver | | |EP function|---|driver |
> > +-----------+ | +-----------+ +-----------+
> > | | |
> > +-----------+ | +-----------+
> > |PCIeC | | |PCIeC |
> > |Rootcomplex|-|-|Endpoint |
> > +-----------+ | +-----------+
> > Host side | Endpoint side
> >
> > This driver uses PCIe EP framework to show virtio-net (pci) device Host
> > side, and generate virtual virtio-net device and register to EP side.
> > A communication date
>
> data?
>
> > is diractly
>
> directly?
>
> > transported between virtqueue level
> > with each other using PCIe embedded DMA controller.
> >
> > by a limitation of the hardware and Linux EP framework, this function
> > follows a virtio legacy specification.
>
> what exactly is the limitation and why does it force legacy?
>
> > This function driver has beed tested on S4 Rcar (r8a779fa-spider) board but
> > just use the PCIe EP framework and depends on the PCIe EDMA.
> >
> > Signed-off-by: Shunsuke Mie <mie@xxxxxxxxxx>
> > Signed-off-by: Takanari Hayama <taki@xxxxxxxxxx>
> > ---
> > drivers/pci/endpoint/functions/Kconfig | 12 +
> > drivers/pci/endpoint/functions/Makefile | 1 +
> > .../pci/endpoint/functions/pci-epf-vnet-ep.c | 343 ++++++++++

It is actually that not related vnet. Just virtio.
I think pci-epf-virtio.c is better.

> > .../pci/endpoint/functions/pci-epf-vnet-rc.c | 635 ++++++++++++++++++

It is epf driver. rc is quite confused.
Maybe you can combine pci-epf-vnet-ep.c and pci-epf-vnet-rc.c to one file.

> > drivers/pci/endpoint/functions/pci-epf-vnet.c | 387 +++++++++++

This file setup dma transfer according virtio-ring.
How about pci-epf-virtio-dma.c ?

> > +
> > + epf_vnet_rc_set_config16(vnet, VIRTIO_PCI_ISR,
> VIRTIO_PCI_ISR_QUEUE);
> > + /*
> > + * Initialize the queue notify and selector to outside of the appropriate
> > + * virtqueue index. It is used to detect change with polling. There is no
> > + * other ways to detect host side driver updateing those values
> > + */

I am try to use gic-its or other msi controller as doorbell.
https://lore.kernel.org/imx/20221125192729.1722913-1-Frank.Li@xxxxxxx/T/#u

but it may need update host side pci virtio driver.

> > + epf_vnet_rc_set_config16(vnet, VIRTIO_PCI_QUEUE_NOTIFY,
> default_qindex);
> > + epf_vnet_rc_set_config16(vnet, VIRTIO_PCI_QUEUE_SEL,
> default_qindex);
> > + /* This pfn is also set to 0 for the polling as well */
> > + epf_vnet_rc_set_config16(vnet, VIRTIO_PCI_QUEUE_PFN, 0);
> > +
> --
> > 2.25.1