Hi Jason, Thank you for your reply. On Fri, Aug 30, 2019 at 2:12 AM Jason Wang <jasowang@xxxxxxxxxx> wrote: > - Is there a doc for this endpoint device? The doc for the board is https://www.xilinx.com/support/documentation/boards_and_kits/vcu118/ug1224-vcu118-eval-bd.pdf, but this is not all that useful. The more important information is actually in the endpoint controller source code, drivers/pci/controller/dwc/pcie-designware-ep.c and drivers/pci/controller/dwc/pcie-designware-ep.h. > - You refer virtio specification in the above, does it mean your device > is fully compatible with virtio (or only datapath is compatible?) I discussed this issue with Kishon in the previous emails a lot. Theoretically this should be compatible with all virtio devices, but right now the code is closely coupled with virtio_net only. The reason is that this endpoint function does not use the intended datapath of virtio. I will explain in the answer to the next question. > - What's the reason for introducing kthreads for some kinds of > translation or copying of descriptor? So there is a virtio_device A on the endpoint, there is another virtio_device B on the endpoint that acts as a virtio_net device for the PCI host. Then I copied data from the tx virtqueue of B to rx virtqueue of A, and vice versa, directly. The PCI endpoint can interrupt the host but the host cannot interrupt the endpoint. Therefore, the endpoint has two dedicated kthreads that constantly poll for notifications and data changes that happen on the host side, one for tx and one for rx. Therefore, there is really no "vhost" involved. Data is transferred between two virtio_devices directly. The descriptors are not copied. The data indicated by the physical addresses in those descriptors are copied using pci endpoint framework API. The problem is that this only works for virtio_net with the split virtio_ring configuration. > - Is it possible to reuse e.g vringh (by introducing new accesor) and > virtio core codes? Two structures are used that are not in source files. One is struct vring_virtqueue and the other is struct virtnet_info. After some thought, I can reduce the use of vring_virtqueue to be only in the function static void epf_virtio_interrupt(struct vring *, struct device *) This function emulates the following function in virtio_ring.c irqreturn_t vring_interruptp(int irq, void *_vq) The motivation is that for the local virtio_device A, it does not need to use interrupt at all. When the a kthread got something from the PCI host and placed data in the rx queue of A, that same kthread could call the callback function associated with the rx queue directly. Specifically I need to access the fields "last_used_idx" and "broken" of vring_virtqueue somehow. virtnet_info can be solved more easily. For a virtio_net device. ((struct virtnet_info *)virtio_device->priv)->dev is the struct net_device created together with the virtio_device. I just need a pointer to that struct net_device after all. > Btw, I'm going to post mdev transport for virtio (with a sample of > vringh loopback device). Technically, this can go through mdev bus as well. I am not that familiar with mdev, but will read up on it. Thank you for the info. Best, Haotian