Skip to contentSkip to conversation

Introduce a PCIe endpoint virtio console

RFC PATCH Superseded Shunsuke Mie 3 participants 12 messages Apr 14, 2023 – Apr 24, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Introduce a PCIe endpoint virtio console

PCIe endpoint framework provides APIs to implement PCIe endpoint function. This framework allows defining various PCIe endpoint function behaviors in software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the conciseness of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver using the extended PCIe endpoint framework for virtio. It can be communicate host and endpoint over virtio as console.

An architecture of the function driver is following:

 ┌────────────┐         ┌──────────────────────┬────────────┐
 │virtio      │         │                      │virtio      │
 │console drv │         ├───────────────┐      │console drv │
 ├────────────┤         │(virtio console│      ├────────────┤
 │ virtio bus │         │ device)       │◄────►│ virtio bus │
 ├────────────┤         ├---------------┤      └────────────┤
 │            │         │ pci ep virtio │                   │
 │  pci bus   │         │  console drv  │                   │
 │            │  pcie   ├───────────────┤                   │
 │            │ ◄─────► │  pci ep Bus   │                   │
 └────────────┘         └───────────────┴───────────────────┘
   PCIe Root              PCIe Endpoint

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side

- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is adding a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

 drivers/pci/endpoint/functions/Kconfig        |  19 +
 drivers/pci/endpoint/functions/Makefile       |   2 +
 drivers/pci/endpoint/functions/pci-epf-vcon.c | 554 ++++++++++++++++++
 .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
 .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
 include/uapi/linux/virtio_pci.h               |   3 +
 6 files changed, 1170 insertions(+)
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h
Signature · 1 line
2.25.1
#1 lore raw

RFC PATCH 1/3 PCI: endpoint: introduce a helper to implement pci ep virtio function

The Linux PCIe Endpoint framework supports to implement PCIe endpoint functions using a PCIe controller operating in endpoint mode. It is possble to realize the behavior of PCIe device, such as virtio PCI device. This patch introduces a setof helper functions and data structures to implement a PCIe endpoint function that behaves as a virtio device.

Those functions enable the implementation PCIe endpoint function that comply with the virtio lecacy specification. Because modern virtio specifications require devices to implement custom PCIe capabilities, which are not currently supported by either PCIe controllers/drivers or the PCIe endpoint framework.

The helper functions work with the new struct epf_virtio, which is initialized and finalized using the following functions:

- int epf_virtio_init();
- void epf_virtio_final()

Once initialized, the PCIe configuration space can be read and written using the following functions:

- epf_virtio_cfg_{read,write}#size()
- epf_virtio_cfg_{set,clear}#size()
- epf_virtio_cfg_memcpy_toio()

The size is supported 8, 16 and 32bits. The content of configuration space varies depending on the type of virtio device.

After the setup, launch the kernel thread for negotiation with host virtio drivers and detection virtqueue notifications with the function:

- epf_virtio_launch_bgtask()

Also there are functions to shutdown and reset the kthread.

- epf_virtio_terminate_bgtask()
- epf_virtio_terminate_reset()

Data transfer function is also provide.

- epf_virtio_vrh_memcpy()

This function copy data indicated descriptor of PCIe host and endpoint virtqueue to each other. The virtqueue manage as vringh and copy direction is specified by enum epf_virtio_copy_dir, which is defined as follows:
This function copies data between the PCIe host and endpoint virtqueues. The each virtqueues are managed using vringh, and the copy direction is specified by an enum called epf_virtio_copy_dir, which is defined as follows:

enum epf_virtio_copy_dir {
EPF_VIRTIO_COPY_DIR_FROM_DEV,
EPF_VIRTIO_COPY_DIR_TO_DEV,
};

While this patch provides functions for negotiating with host drivers and copying data, each PCIe function driver must impl ement operations that depend on each specific device, such as network, block, etc.

---
 drivers/pci/endpoint/functions/Kconfig        |   7 +
 drivers/pci/endpoint/functions/Makefile       |   1 +
 .../pci/endpoint/functions/pci-epf-virtio.c   | 469 ++++++++++++++++++
 .../pci/endpoint/functions/pci-epf-virtio.h   | 123 +++++
 4 files changed, 600 insertions(+)
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h
drivers/pci/endpoint/functions/Kconfig +7 -0
index 9fd560886871..cf16d33c9585 100644
@@ -37,3 +37,10 @@ config PCI_EPF_VNTB
 	  between PCI Root Port and PCIe Endpoint.
 
 	  If in doubt, say "N" to disable Endpoint NTB driver.
+
+config PCI_EPF_VIRTIO
+	tristate
+	depends on PCI_ENDPOINT
+	select VHOST_IOMEM
+	help
+	  Helpers to implement PCI virtio Endpoint function
drivers/pci/endpoint/functions/Makefile +1 -0
index 5c13001deaba..a96f127ce900 100644
@@ -6,3 +6,4 @@
 obj-$(CONFIG_PCI_EPF_TEST)		+= pci-epf-test.o
 obj-$(CONFIG_PCI_EPF_NTB)		+= pci-epf-ntb.o
 obj-$(CONFIG_PCI_EPF_VNTB) 		+= pci-epf-vntb.o
+obj-$(CONFIG_PCI_EPF_VIRTIO)		+= pci-epf-virtio.o
drivers/pci/endpoint/functions/pci-epf-virtio.c new file +469 -0

469 lines not on this page · raw message

drivers/pci/endpoint/functions/pci-epf-virtio.h new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

RFC PATCH 2/3 virtio_pci: add a definition of queue flag in ISR

In reply to Shunsuke Mie

Already it has beed defined a config changed flag of ISR, but not the queue flag. Add a macro for it.

---
 include/uapi/linux/virtio_pci.h | 3 +++
 1 file changed, 3 insertions(+)
include/uapi/linux/virtio_pci.h +3 -0
index f703afc7ad31..d405bea27240 100644
@@ -94,6 +94,9 @@
 
 #endif /* VIRTIO_PCI_NO_LEGACY */
 
+/* Bits for ISR status field:only when if MSI-X is disabled */
+/* The bit of the ISR which indicates a queue entry update. */
+#define VIRTIO_PCI_ISR_QUEUE		0x1
 /* The bit of the ISR which indicates a device configuration change. */
 #define VIRTIO_PCI_ISR_CONFIG		0x2
 /* Vector value used to disable MSI for queue */
Signature · 6 lines
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#3 lore raw

RFC PATCH 3/3 PCI: endpoint: Add EP function driver to provide virtio-console functionality

In reply to Shunsuke Mie

Add a new PCIe endpoint function driver that works as a pci virtio-console device. The console connect to endpoint side console. It enables to communicate PCIe host and endpoint.

Architecture is following:

 ┌────────────┐         ┌──────────────────────┬────────────┐
 │virtioe     │         │                      │virtio      │
 │console drv │         ├───────────────┐      │console drv │
 ├────────────┤         │(virtio console│      ├────────────┤
 │ virtio bus │         │ device)       │◄────►│ virtio bus │
 ├────────────┤         ├---------------┤      └────────────┤
 │            │         │ pci ep virtio │                   │
 │  pci bus   │         │  console drv  │                   │
 │            │  pcie   ├───────────────┤                   │
 │            │ ◄─────► │  pci ep Bus   │                   │
 └────────────┘         └───────────────┴───────────────────┘
   PCIe Root              PCIe Endpoint

This driver has two roles. The first is as a PCIe endpoint virtio console function, which is implemented using the PCIe endpoint framework and PCIe EP virtio helpers. The second is as a virtual virtio console device connected to the virtio bus on PCIe endpoint Linux.

Communication between the two is achieved by copying the virtqueue data between PCIe root and endpoint, respectively.

This is a simple implementation and does not include features of virtio-console such as MULTIPORT, EMERG_WRITE, etc. As a result, each virtio console driver only displays /dev/hvc0.

As an example of usage, by setting getty to /dev/hvc0, it is possible to login to another host.

---
 drivers/pci/endpoint/functions/Kconfig        |  12 +
 drivers/pci/endpoint/functions/Makefile       |   1 +
 drivers/pci/endpoint/functions/pci-epf-vcon.c | 554 ++++++++++++++++++
 3 files changed, 567 insertions(+)
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c
drivers/pci/endpoint/functions/Kconfig +12 -0
index cf16d33c9585..890e07b51cbe 100644
@@ -44,3 +44,15 @@ config PCI_EPF_VIRTIO
 	select VHOST_IOMEM
 	help
 	  Helpers to implement PCI virtio Endpoint function
+
+config PCI_EPF_VCON
+	tristate "PCI Endpoint virito-console driver"
+	depends on PCI_ENDPOINT
+	select VHOST_RING
+	select PCI_EPF_VIRTIO
+	help
+	  PCIe Endpoint virtio-console function implementatino. This module
+	  enables to show the virtio-console as pci device to PCIe host side, and
+	  another virtual virtio-console device registers to endpoint system.
+	  Those devices are connected virtually and can communicate each other.
+
drivers/pci/endpoint/functions/Makefile +1 -0
index a96f127ce900..b4056689ce33 100644
@@ -7,3 +7,4 @@ obj-$(CONFIG_PCI_EPF_TEST)		+= pci-epf-test.o
 obj-$(CONFIG_PCI_EPF_NTB)		+= pci-epf-ntb.o
 obj-$(CONFIG_PCI_EPF_VNTB) 		+= pci-epf-vntb.o
 obj-$(CONFIG_PCI_EPF_VIRTIO)		+= pci-epf-virtio.o
+obj-$(CONFIG_PCI_EPF_VCON)		+= pci-epf-vcon.o
drivers/pci/endpoint/functions/pci-epf-vcon.c new file +554 -0

554 lines not on this page · raw message

Signature · 6 lines
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#4 lore raw

Re: [RFC PATCH 3/3] PCI: endpoint: Add EP function driver to provide virtio-console functionality

kernel test robot noticed the following build errors:

Hi Shunsuke,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:

[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus linus/master v6.3-rc6 next-20230413] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/PCI-endpoint-introduce-a-helper-to-implement-pci-ep-virtio-function/20230414-204118
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20230414123903.896914-4-mie%40igel.co.jp
patch subject: [RFC PATCH 3/3] PCI: endpoint: Add EP function driver to provide virtio-console functionality
config: riscv-allmodconfig (https://download.01.org/0day-ci/archive/20230414/[email protected]/config)
compiler: riscv64-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/1351b90fcb70907e50f3a8c6a4e4e978bd00cda0
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/PCI-endpoint-introduce-a-helper-to-implement-pci-ep-virtio-function/20230414-204118 git checkout 1351b90fcb70907e50f3a8c6a4e4e978bd00cda0
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/pci/endpoint/functions/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All error/warnings (new ones prefixed by >>):

drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_unmap_vq':

>> drivers/pci/endpoint/functions/pci-epf-virtio.c:16:9: error: too many arguments to function 'pci_epc_unmap_addr'
      16 |         pci_epc_unmap_addr(epf->epc, epf->func_no, epf->vfunc_no, vq_phys,
         |         ^~~~~~~~~~~~~~~~~~
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:218:6: note: declared here
     218 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
         |      ^~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_map_vq':
>> drivers/pci/endpoint/functions/pci-epf-virtio.c:32:49: warning: passing argument 5 of 'pci_epc_map_addr' makes integer from pointer without a cast [-Wint-conversion]
      32 |                                    vq_pci_addr, vq_phys, vq_size);
         |                                                 ^~~~~~~
         |                                                 |
         |                                                 phys_addr_t * {aka long long unsigned int *}
   include/linux/pci-epc.h:217:26: note: expected 'u64' {aka 'long long unsigned int'} but argument is of type 'phys_addr_t *' {aka 'long long unsigned int *'}
     217 |                      u64 pci_addr, size_t size);
         |                      ~~~~^~~~~~~~
>> drivers/pci/endpoint/functions/pci-epf-virtio.c:31:17: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      31 |         vq_virt = pci_epc_map_addr(epf->epc, epf->func_no, epf->vfunc_no,
         |                 ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_alloc_vringh':
>> drivers/pci/endpoint/functions/pci-epf-virtio.c:75:15: error: implicit declaration of function 'vringh_init_iomem'; did you mean 'vringh_init_iotlb'? [-Werror=implicit-function-declaration]
      75 |         err = vringh_init_iomem(&evrh->vrh, features, num, false, GFP_KERNEL,
         |               ^~~~~~~~~~~~~~~~~
         |               vringh_init_iotlb
   drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_vrh_memcpy':
>> drivers/pci/endpoint/functions/pci-epf-virtio.c:402:15: error: implicit declaration of function 'vringh_getdesc'; did you mean 'vringh_getdesc_kern'? [-Werror=implicit-function-declaration]
     402 |         err = vringh_getdesc(svrh, siov, NULL, &shead);
         |               ^~~~~~~~~~~~~~
         |               vringh_getdesc_kern
   drivers/pci/endpoint/functions/pci-epf-virtio.c:431:72: warning: passing argument 5 of 'pci_epc_map_addr' makes integer from pointer without a cast [-Wint-conversion]
     431 |                                                  epf->vfunc_no, sbase, &phys,
         |                                                                        ^~~~~
         |                                                                        |
         |                                                                        phys_addr_t * {aka long long unsigned int *}
   include/linux/pci-epc.h:217:26: note: expected 'u64' {aka 'long long unsigned int'} but argument is of type 'phys_addr_t *' {aka 'long long unsigned int *'}
     217 |                      u64 pci_addr, size_t size);
         |                      ~~~~^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:430:31: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     430 |                         svirt = pci_epc_map_addr(epf->epc, epf->func_no,
         |                               ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c:442:25: error: too many arguments to function 'pci_epc_unmap_addr'
     442 |                         pci_epc_unmap_addr(epf->epc, epf->func_no,
         |                         ^~~~~~~~~~~~~~~~~~
   include/linux/pci-epc.h:218:6: note: declared here
     218 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
         |      ^~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:447:72: warning: passing argument 5 of 'pci_epc_map_addr' makes integer from pointer without a cast [-Wint-conversion]
     447 |                                                  epf->vfunc_no, dbase, &phys,
         |                                                                        ^~~~~
         |                                                                        |
         |                                                                        phys_addr_t * {aka long long unsigned int *}
   include/linux/pci-epc.h:217:26: note: expected 'u64' {aka 'long long unsigned int'} but argument is of type 'phys_addr_t *' {aka 'long long unsigned int *'}
     217 |                      u64 pci_addr, size_t size);
         |                      ~~~~^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:446:31: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     446 |                         dvirt = pci_epc_map_addr(epf->epc, epf->func_no,
         |                               ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c:457:25: error: too many arguments to function 'pci_epc_unmap_addr'
     457 |                         pci_epc_unmap_addr(epf->epc, epf->func_no,
         |                         ^~~~~~~~~~~~~~~~~~
   include/linux/pci-epc.h:218:6: note: declared here
     218 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
         |      ^~~~~~~~~~~~~~~~~~
>> drivers/pci/endpoint/functions/pci-epf-virtio.c:462:9: error: implicit declaration of function 'vringh_complete'; did you mean 'vringh_complete_kern'? [-Werror=implicit-function-declaration]
     462 |         vringh_complete(svrh, shead, total_len);
         |         ^~~~~~~~~~~~~~~
         |         vringh_complete_kern

cc1: some warnings being treated as errors
--
In file included from include/linux/cpumask.h:15,
from include/linux/smp.h:13,
from include/linux/lockdep.h:14,
from include/linux/spinlock.h:63,
from include/linux/kref.h:16,
from include/linux/configfs.h:25,
from include/linux/pci-epf.h:12,
from drivers/pci/endpoint/functions/pci-epf-vcon.c:6:
drivers/pci/endpoint/functions/pci-epf-vcon.c: In function 'epf_vcon_vdev_find_vqs':

>> include/linux/gfp_types.h:329:25: warning: passing argument 5 of 'vringh_init_kern' makes pointer from integer without a cast [-Wint-conversion]
     329 | #define GFP_KERNEL      (__GFP_RECLAIM | __GFP_IO | __GFP_FS)
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         |                         |
         |                         unsigned int
   drivers/pci/endpoint/functions/pci-epf-vcon.c:343:66: note: in expansion of macro 'GFP_KERNEL'
     343 |                                        virtio_queue_size, false, GFP_KERNEL,
         |                                                                  ^~~~~~~~~~
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:7,
                    from drivers/pci/endpoint/functions/pci-epf-vcon.c:12:
   include/linux/vringh.h:174:41: note: expected 'struct vring_desc *' but argument is of type 'unsigned int'
     174 |                      struct vring_desc *desc,
         |                      ~~~~~~~~~~~~~~~~~~~^~~~
>> drivers/pci/endpoint/functions/pci-epf-vcon.c:344:45: error: passing argument 6 of 'vringh_init_kern' from incompatible pointer type [-Werror=incompatible-pointer-types]
     344 |                                        vring->desc, vring->avail, vring->used);
         |                                        ~~~~~^~~~~~
         |                                             |
         |                                             vring_desc_t * {aka struct vring_desc *}
   include/linux/vringh.h:175:42: note: expected 'struct vring_avail *' but argument is of type 'vring_desc_t *' {aka 'struct vring_desc *'}
     175 |                      struct vring_avail *avail,
         |                      ~~~~~~~~~~~~~~~~~~~~^~~~~
   drivers/pci/endpoint/functions/pci-epf-vcon.c:344:58: error: passing argument 7 of 'vringh_init_kern' from incompatible pointer type [-Werror=incompatible-pointer-types]
     344 |                                        vring->desc, vring->avail, vring->used);
         |                                                     ~~~~~^~~~~~~
         |                                                          |
         |                                                          vring_avail_t * {aka struct vring_avail *}
   include/linux/vringh.h:176:41: note: expected 'struct vring_used *' but argument is of type 'vring_avail_t *' {aka 'struct vring_avail *'}
     176 |                      struct vring_used *used);
         |                      ~~~~~~~~~~~~~~~~~~~^~~~
>> drivers/pci/endpoint/functions/pci-epf-vcon.c:342:23: error: too many arguments to function 'vringh_init_kern'
     342 |                 err = vringh_init_kern(&vcon->vdev_vrhs[i], vcon->features,
         |                       ^~~~~~~~~~~~~~~~

include/linux/vringh.h:172:5: note: declared here
172 | int vringh_init_kern(struct vringh *vrh, u64 features,
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

vim +/vringh_init_kern +344 drivers/pci/endpoint/functions/pci-epf-vcon.c

305
306 static int epf_vcon_vdev_find_vqs(struct virtio_device *vdev, unsigned int nvqs,

   307					  struct virtqueue *vqs[],
   308					  vq_callback_t *callback[],
   309					  const char *const names[], const bool *ctx,
   310					  struct irq_affinity *desc)
   311	{
   312		struct epf_vcon *vcon = vdev_to_vcon(vdev);
   313		int err;
   314		int qidx, i;
   315	
   316		if (nvqs > epf_vcon_get_nvq(vcon))
   317			return -EINVAL;
   318	
   319		for (qidx = 0, i = 0; i < nvqs; i++) {
   320			struct virtqueue *vq;
   321			const struct vring *vring;
   322	
   323			if (!names[i]) {
   324				vqs[i] = NULL;
   325				continue;
   326			}
   327	
   328			vq = vring_create_virtqueue(qidx++, virtio_queue_size,
   329						    VIRTIO_PCI_VRING_ALIGN, vdev, true,
   330						    false, ctx ? ctx[i] : false,
   331						    epf_vcon_vdev_vq_notify,
   332						    callback[i], names[i]);
   333			if (!vq) {
   334				err = -ENOMEM;
   335				goto err_del_vqs;
   336			}
   337	
   338			vqs[i] = vq;
   339			vcon->vdev_vqs[i] = vq;
   340	
   341			vring = virtqueue_get_vring(vq);
 > 342			err = vringh_init_kern(&vcon->vdev_vrhs[i], vcon->features,
   343					       virtio_queue_size, false, GFP_KERNEL,
 > 344					       vring->desc, vring->avail, vring->used);

345 if (err) {
346 pr_err("failed to init vringh for vring %d\n", i);
347 goto err_del_vqs;
348 }
349 }
350
351 return 0;
352
353 err_del_vqs:
354 for (; i >= 0; i--) {
355 if (!names[i])
356 continue;
357
358 if (!vqs[i])
359 continue;
360
361 vring_del_virtqueue(vqs[i]);
362 }
363 return err;
364 }
365

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#5 lore raw

Re: [RFC PATCH 3/3] PCI: endpoint: Add EP function driver to provide virtio-console functionality

In reply to Shunsuke Mie
kernel test robot noticed the following build warnings:

Hi Shunsuke,

[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:

[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus linus/master v6.3-rc6 next-20230413] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Shunsuke-Mie/PCI-endpoint-introduce-a-helper-to-implement-pci-ep-virtio-function/20230414-204118
base:   https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link:    https://lore.kernel.org/r/20230414123903.896914-4-mie%40igel.co.jp
patch subject: [RFC PATCH 3/3] PCI: endpoint: Add EP function driver to provide virtio-console functionality
config: i386-allyesconfig (https://download.01.org/0day-ci/archive/20230415/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0

reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/1351b90fcb70907e50f3a8c6a4e4e978bd00cda0
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Shunsuke-Mie/PCI-endpoint-introduce-a-helper-to-implement-pci-ep-virtio-function/20230414-204118 git checkout 1351b90fcb70907e50f3a8c6a4e4e978bd00cda0
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=i386 olddefconfig
make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/pci/endpoint/functions/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_unmap_vq':
drivers/pci/endpoint/functions/pci-epf-virtio.c:16:9: error: too many arguments to function 'pci_epc_unmap_addr'

      16 |         pci_epc_unmap_addr(epf->epc, epf->func_no, epf->vfunc_no, vq_phys,
         |         ^~~~~~~~~~~~~~~~~~
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:218:6: note: declared here
     218 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
         |      ^~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_map_vq':
   drivers/pci/endpoint/functions/pci-epf-virtio.c:32:49: warning: passing argument 5 of 'pci_epc_map_addr' makes integer from pointer without a cast [-Wint-conversion]
      32 |                                    vq_pci_addr, vq_phys, vq_size);
         |                                                 ^~~~~~~
         |                                                 |
         |                                                 phys_addr_t * {aka unsigned int *}
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:217:26: note: expected 'u64' {aka 'long long unsigned int'} but argument is of type 'phys_addr_t *' {aka 'unsigned int *'}
     217 |                      u64 pci_addr, size_t size);
         |                      ~~~~^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:31:17: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      31 |         vq_virt = pci_epc_map_addr(epf->epc, epf->func_no, epf->vfunc_no,
         |                 ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_alloc_vringh':
   drivers/pci/endpoint/functions/pci-epf-virtio.c:75:15: error: implicit declaration of function 'vringh_init_iomem'; did you mean 'vringh_init_iotlb'? [-Werror=implicit-function-declaration]
      75 |         err = vringh_init_iomem(&evrh->vrh, features, num, false, GFP_KERNEL,
         |               ^~~~~~~~~~~~~~~~~
         |               vringh_init_iotlb
   drivers/pci/endpoint/functions/pci-epf-virtio.c: In function 'epf_virtio_vrh_memcpy':
   drivers/pci/endpoint/functions/pci-epf-virtio.c:402:15: error: implicit declaration of function 'vringh_getdesc'; did you mean 'vringh_getdesc_kern'? [-Werror=implicit-function-declaration]
     402 |         err = vringh_getdesc(svrh, siov, NULL, &shead);
         |               ^~~~~~~~~~~~~~
         |               vringh_getdesc_kern
>> drivers/pci/endpoint/functions/pci-epf-virtio.c:420:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     420 |                 sbase = (u64)siov->iov[siov->i].iov_base;
         |                         ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c:422:25: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     422 |                 dbase = (u64)diov->iov[diov->i].iov_base;
         |                         ^
   In file included from include/asm-generic/bug.h:22,
                    from arch/x86/include/asm/bug.h:87,
                    from include/linux/bug.h:5,
                    from include/linux/virtio_config.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:6:
   include/linux/kern_levels.h:5:25: warning: format '%ld' expects argument of type 'long int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:427:25: note: in definition of macro 'printk_index_wrap'
     427 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:498:9: note: in expansion of macro 'printk'
     498 |         printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~
   include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR        KERN_SOH "3"    /* error conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:498:16: note: in expansion of macro 'KERN_ERR'
     498 |         printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |                ^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:425:25: note: in expansion of macro 'pr_err'
     425 |                         pr_err("no space %ld < %ld\n", dlen, slen);
         |                         ^~~~~~
   include/linux/kern_levels.h:5:25: warning: format '%ld' expects argument of type 'long int', but argument 3 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
       5 | #define KERN_SOH        "\001"          /* ASCII Start Of Header */
         |                         ^~~~~~
   include/linux/printk.h:427:25: note: in definition of macro 'printk_index_wrap'
     427 |                 _p_func(_fmt, ##__VA_ARGS__);                           \
         |                         ^~~~
   include/linux/printk.h:498:9: note: in expansion of macro 'printk'
     498 |         printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |         ^~~~~~
   include/linux/kern_levels.h:11:25: note: in expansion of macro 'KERN_SOH'
      11 | #define KERN_ERR        KERN_SOH "3"    /* error conditions */
         |                         ^~~~~~~~
   include/linux/printk.h:498:16: note: in expansion of macro 'KERN_ERR'
     498 |         printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
         |                ^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:425:25: note: in expansion of macro 'pr_err'
     425 |                         pr_err("no space %ld < %ld\n", dlen, slen);
         |                         ^~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:431:72: warning: passing argument 5 of 'pci_epc_map_addr' makes integer from pointer without a cast [-Wint-conversion]
     431 |                                                  epf->vfunc_no, sbase, &phys,
         |                                                                        ^~~~~
         |                                                                        |
         |                                                                        phys_addr_t * {aka unsigned int *}
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:217:26: note: expected 'u64' {aka 'long long unsigned int'} but argument is of type 'phys_addr_t *' {aka 'unsigned int *'}
     217 |                      u64 pci_addr, size_t size);
         |                      ~~~~^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:430:31: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     430 |                         svirt = pci_epc_map_addr(epf->epc, epf->func_no,
         |                               ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c:442:25: error: too many arguments to function 'pci_epc_unmap_addr'
     442 |                         pci_epc_unmap_addr(epf->epc, epf->func_no,
         |                         ^~~~~~~~~~~~~~~~~~
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:218:6: note: declared here
     218 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
         |      ^~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:447:72: warning: passing argument 5 of 'pci_epc_map_addr' makes integer from pointer without a cast [-Wint-conversion]
     447 |                                                  epf->vfunc_no, dbase, &phys,
         |                                                                        ^~~~~
         |                                                                        |
         |                                                                        phys_addr_t * {aka unsigned int *}
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:217:26: note: expected 'u64' {aka 'long long unsigned int'} but argument is of type 'phys_addr_t *' {aka 'unsigned int *'}
     217 |                      u64 pci_addr, size_t size);
         |                      ~~~~^~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:446:31: warning: assignment to 'void *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
     446 |                         dvirt = pci_epc_map_addr(epf->epc, epf->func_no,
         |                               ^
   drivers/pci/endpoint/functions/pci-epf-virtio.c:457:25: error: too many arguments to function 'pci_epc_unmap_addr'
     457 |                         pci_epc_unmap_addr(epf->epc, epf->func_no,
         |                         ^~~~~~~~~~~~~~~~~~
   In file included from drivers/pci/endpoint/functions/pci-epf-virtio.h:6,
                    from drivers/pci/endpoint/functions/pci-epf-virtio.c:9:
   include/linux/pci-epc.h:218:6: note: declared here
     218 | void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
         |      ^~~~~~~~~~~~~~~~~~
   drivers/pci/endpoint/functions/pci-epf-virtio.c:462:9: error: implicit declaration of function 'vringh_complete'; did you mean 'vringh_complete_kern'? [-Werror=implicit-function-declaration]
     462 |         vringh_complete(svrh, shead, total_len);
         |         ^~~~~~~~~~~~~~~
         |         vringh_complete_kern

cc1: some warnings being treated as errors

vim +420 drivers/pci/endpoint/functions/pci-epf-virtio.c

7a5dfc758cfa25 Shunsuke Mie 2023-04-14  375  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  376  /**
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  377   * epf_virtio_vrh_memcpy - copy a data with CPU between remote and local vring.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  378   * @evio: struct epf_virtio
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  379   * @svrh: vringh for source virtqueue.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  380   * @siov: iovec to store buffer info for source virtqueue
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  381   * @dvrh: vringh for destination virtqueue.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  382   * @diov: iovec to store buffer info for destination virtqueue
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  383   * @dir: direction of the copy.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  384   *
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  385   * Returns zero, one or a negative.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  386   * 0: there is no data in src virtio ring.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  387   * 1: success to transfer data.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  388   * negative: errors.
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  389   */
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  390  int epf_virtio_vrh_memcpy(struct epf_virtio *evio, struct vringh *svrh,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  391  			  struct vringh_kiov *siov, struct vringh *dvrh,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  392  			  struct vringh_kiov *diov,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  393  			  enum epf_virtio_copy_dir dir)
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  394  {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  395  	int err;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  396  	u16 shead, dhead;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  397  	size_t slen, dlen, total_len;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  398  	void *svirt, *dvirt;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  399  	phys_addr_t sbase, dbase, phys;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  400  	struct pci_epf *epf = evio->epf;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  401  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  402  	err = vringh_getdesc(svrh, siov, NULL, &shead);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  403  	if (err <= 0) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  404  		if (err < 0)
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  405  			pr_err("s err %d\n", err);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  406  		return err;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  407  	}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  408  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  409  	err = vringh_getdesc(dvrh, NULL, diov, &dhead);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  410  	if (err <= 0) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  411  		if (err < 0)
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  412  			pr_err("d err %d\n", err);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  413  		return err;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  414  	}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  415  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  416  	total_len = vringh_kiov_length(siov);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  417  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  418  	for (; siov->i < siov->used; siov->i++, diov->i++) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  419  		slen = siov->iov[siov->i].iov_len;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14 @420  		sbase = (u64)siov->iov[siov->i].iov_base;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  421  		dlen = diov->iov[diov->i].iov_len;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  422  		dbase = (u64)diov->iov[diov->i].iov_base;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  423  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  424  		if (dlen < slen) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  425  			pr_err("no space %ld < %ld\n", dlen, slen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  426  			return -ENOSPC;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  427  		}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  428  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  429  		if (dir == EPF_VIRTIO_COPY_DIR_FROM_DEV) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  430  			svirt = pci_epc_map_addr(epf->epc, epf->func_no,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  431  						 epf->vfunc_no, sbase, &phys,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  432  						 slen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  433  			if (IS_ERR(svirt)) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  434  				pr_err("pci_epc_map_addr s %ld\n",
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  435  				       PTR_ERR(svirt));
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  436  				return PTR_ERR(svirt);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  437  			}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  438  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  439  			dvirt = phys_to_virt(dbase);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  440  			memcpy_fromio(dvirt, svirt, slen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  441  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  442  			pci_epc_unmap_addr(epf->epc, epf->func_no,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  443  					   epf->vfunc_no, phys, svirt, slen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  444  		} else {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  445  			svirt = phys_to_virt(sbase);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  446  			dvirt = pci_epc_map_addr(epf->epc, epf->func_no,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  447  						 epf->vfunc_no, dbase, &phys,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  448  						 dlen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  449  			if (IS_ERR(dvirt)) {
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  450  				pr_err("pci_epc_map_addr d %ld\n",
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  451  				       PTR_ERR(dvirt));
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  452  				return PTR_ERR(dvirt);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  453  			}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  454  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  455  			memcpy_toio(dvirt, svirt, slen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  456  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  457  			pci_epc_unmap_addr(epf->epc, epf->func_no,
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  458  					   epf->vfunc_no, phys, dvirt, dlen);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  459  		}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  460  	}
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  461  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  462  	vringh_complete(svrh, shead, total_len);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  463  	vringh_complete(dvrh, dhead, total_len);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  464  
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  465  	return 1;
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  466  }
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  467  EXPORT_SYMBOL_GPL(epf_virtio_vrh_memcpy);
7a5dfc758cfa25 Shunsuke Mie 2023-04-14  468  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#6 lore raw
In reply to Shunsuke Mie
Quoted 42 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Friday, April 14, 2023 7:39 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Shunsuke Mie <[email protected]>; Frank Li <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

PCIe endpoint framework provides APIs to implement PCIe endpoint function.
This framework allows defining various PCIe endpoint function behaviors in software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the conciseness of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver using the extended PCIe endpoint framework for virtio. It can be communicate host and endpoint over virtio as console.

An architecture of the function driver is following:

 ┌────────────┐         ┌──────────────
────────┬────────────┐
 │virtio      │         │                      │virtio      │
 │console drv │         ├───────────────┐      │console
drv │
 ├────────────┤         │(virtio console│      ├─────
───────┤
 │ virtio bus │         │ device)       │◄────►│ virtio bus │
 ├────────────┤         ├---------------┤      └──────
Quoted 9 lines
──────┤
 │            │         │ pci ep virtio │                   │
 │  pci bus   │         │  console drv  │                   │
 │            │  pcie   ├───────────────┤                   │
 │            │ ◄─────► │  pci ep Bus   │                   │
 └────────────┘         └──────────────
─┴───────────────────┘
   PCIe Root              PCIe Endpoint

[Frank Li] Some basic question,
I see you call register_virtio_device at epf_vcon_setup_vdev, Why call it as virtio console? I suppose it should be virtiobus directly?

Previous you use virtio-net, why change to virtio-console here? Does it matter? All virtio-XXX should work?

You removed EDMA support this version?

Quoted 55 lines

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side link:
https://lore.k/
ernel.org%2Flinux-pci%2F20230113090350.1103494-1- mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf 4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C %7C%7C&sdata=jYgy%2Bxk84ZXZRVfqm0GCXoRnCTLMrX4zTfV%2Bs5Mmsvo %3D&reserved=0
- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory link:
https://lore.k/
ernel.org%2Fvirtualization%2F20230202090934.549556-1- mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf 4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C %7C%7C&sdata=K4El76GSAGtsWkNBXJK5%2Fn7flCN20eEMZpZYTX2WIZ0%3 D&reserved=0

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is adding a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

 drivers/pci/endpoint/functions/Kconfig        |  19 +
 drivers/pci/endpoint/functions/Makefile       |   2 +
 drivers/pci/endpoint/functions/pci-epf-vcon.c | 554 ++++++++++++++++++
 .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
 .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
 include/uapi/linux/virtio_pci.h               |   3 +
 6 files changed, 1170 insertions(+)
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c
 create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h

--
2.25.1

#7 lore raw
Quoted 50 lines · Frank Li
Quoted 41 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Friday, April 14, 2023 7:39 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Shunsuke Mie <[email protected]>; Frank Li <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

PCIe endpoint framework provides APIs to implement PCIe endpoint function.
This framework allows defining various PCIe endpoint function behaviors in software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the conciseness of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver using the extended PCIe endpoint framework for virtio. It can be communicate host and endpoint over virtio as console.

An architecture of the function driver is following:

  ┌────────────┐         ┌──────────────
────────┬────────────┐
  │virtio      │         │                      │virtio      │
  │console drv │         ├───────────────┐      │console
drv │
  ├────────────┤         │(virtio console│      ├─────
───────┤
  │ virtio bus │         │ device)       │◄────►│ virtio bus │
  ├────────────┤         ├---------------┤      └──────
Quoted 9 lines
──────┤
  │            │         │ pci ep virtio │                   │
  │  pci bus   │         │  console drv  │                   │
  │            │  pcie   ├───────────────┤                   │
  │            │ ◄─────► │  pci ep Bus   │                   │
  └────────────┘         └──────────────
─┴───────────────────┘
    PCIe Root              PCIe Endpoint
Quoted 3 lines

[Frank Li] Some basic question,
I see you call register_virtio_device at epf_vcon_setup_vdev, Why call it as virtio console? I suppose it should be virtiobus directly?

I'm sorry I didn't understand your question. What do you mean the virtiobus directly?

Quoted 2 lines

Previous you use virtio-net, why change to virtio-console here? Does it matter?

No, it doesn't. Just I'd like to break down the changes into smaller steps to make it easier to review and merge the changes.

As a first step, I propose adding a simplest virtio function driver with the extension defined in pci-epf-virtio.{h,c}.

Quoted 1 line

All virtio-XXX should work?

Yes, the extension is designed to use any type of virtio device.

Quoted 2 lines

You removed EDMA support this version?

I planed the support will be added with epf virtio-net patches.

Quoted 56 lines
Quoted 56 lines

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side link:
https://lore.k/
ernel.org%2Flinux-pci%2F20230113090350.1103494-1- mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf 4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C %7C%7C&sdata=jYgy%2Bxk84ZXZRVfqm0GCXoRnCTLMrX4zTfV%2Bs5Mmsvo %3D&reserved=0
- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory link:
https://lore.k/
ernel.org%2Fvirtualization%2F20230202090934.549556-1- mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf 4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C %7C%7C&sdata=K4El76GSAGtsWkNBXJK5%2Fn7flCN20eEMZpZYTX2WIZ0%3 D&reserved=0

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is adding a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

  drivers/pci/endpoint/functions/Kconfig        |  19 +
  drivers/pci/endpoint/functions/Makefile       |   2 +
  drivers/pci/endpoint/functions/pci-epf-vcon.c | 554 ++++++++++++++++++
  .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
  .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
  include/uapi/linux/virtio_pci.h               |   3 +
  6 files changed, 1170 insertions(+)

create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h

--
2.25.1

#8 lore raw
Quoted 76 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Sunday, April 16, 2023 9:12 PM
To: Frank Li <[email protected]>; Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

Quoted 15 lines · Frank Li
Quoted 15 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Friday, April 14, 2023 7:39 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Shunsuke Mie <[email protected]>; Frank Li <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Quoted 5 lines
Quoted 5 lines

Caution: EXT Email

PCIe endpoint framework provides APIs to implement PCIe endpoint function.
This framework allows defining various PCIe endpoint function behaviors

in

Quoted 3 lines
Quoted 3 lines

software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the

conciseness

Quoted 4 lines
Quoted 4 lines

of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver

using

Quoted 6 lines
Quoted 6 lines

the extended PCIe endpoint framework for virtio. It can be communicate host and endpoint over virtio as console.

An architecture of the function driver is following:

┌────────────┐ ┌────────────

──
>> ────────┬────────────┐
>>   │virtio      │         │                      │virtio      │
>>   │console drv │         ├───────────────┐      │

console

Quoted 2 lines
Quoted 2 lines
drv │
  ├────────────┤         │(virtio console│      ├───
──
>> ───────┤
>>   │ virtio bus │         │ device)       │◄────►│ virtio bus │
>>   ├────────────┤         ├---------------┤      └────
──
>> ──────┤
>>   │            │         │ pci ep virtio │                   │
>>   │  pci bus   │         │  console drv  │                   │
>>   │            │  pcie   ├───────────────┤                   │
>>   │            │ ◄─────► │  pci ep Bus   │                   │
>>   └────────────┘         └────────────
──
>> ─┴───────────────────┘
>>     PCIe Root              PCIe Endpoint
Quoted 1 line
Quoted 1 line
Quoted 6 lines
Quoted 3 lines

[Frank Li] Some basic question,
I see you call register_virtio_device at epf_vcon_setup_vdev, Why call it as virtio console? I suppose it should be virtiobus directly?

I'm sorry I didn't understand your question. What do you mean the virtiobus directly?

I go through your code again. I think I understand why you need pci-epf-vcon.c. Actually, my means is like virtio_mmio_probe.

vm_dev->vdev.id.device = readl(vm_dev->base + VIRTIO_MMIO_DEVICE_ID); vm_dev->vdev.id.vendor = readl(vm_dev->base + VIRTIO_MMIO_VENDOR_ID);

I am not sure that if VIRTIO_MMIO_VENDOR_ID and VIRTIO_MMIO_DEVICE_ID reuse PCI's vendor ID and Device ID. If yes, you can directly get such information from epf. If no, a customer field can been added at epf driver.

So you needn't write pci-epf-vcon and pci-epf-vnet .....

Of cause it will be wonderful if directly use virtio_mmio_probe by dynmatic create platform Devices. It may have some difficult because pci memory map requirement.

Quoted 95 lines
Quoted 3 lines

Previous you use virtio-net, why change to virtio-console here? Does it

matter?

No, it doesn't. Just I'd like to break down the changes into smaller steps to make it easier to review and merge the changes.

As a first step, I propose adding a simplest virtio function driver with the extension defined in pci-epf-virtio.{h,c}.

Quoted 1 line

All virtio-XXX should work?

Yes, the extension is designed to use any type of virtio device.

Quoted 2 lines

You removed EDMA support this version?

I planed the support will be added with epf virtio-net patches.

Quoted 7 lines
Quoted 7 lines

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

Quoted 5 lines
Quoted 5 lines

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908db3 ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315 3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB 5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Flinux-pci%2F20230113090350.1103494-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf

Quoted 1 line
Quoted 1 line

4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7

Quoted 1 line
Quoted 1 line

C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w

Quoted 1 line
Quoted 1 line

LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line

%7C%7C&sdata=jYgy%2Bxk84ZXZRVfqm0GCXoRnCTLMrX4zTfV%2Bs5Mm

svo

Quoted 4 lines
Quoted 4 lines

%3D&reserved=0
- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908db3 ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315 3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB 5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Fvirtualization%2F20230202090934.549556-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf

Quoted 1 line
Quoted 1 line

4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7

Quoted 1 line
Quoted 1 line

C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w

Quoted 1 line
Quoted 1 line

LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line

%7C%7C&sdata=K4El76GSAGtsWkNBXJK5%2Fn7flCN20eEMZpZYTX2WIZ0

%3

Quoted 15 lines
Quoted 15 lines

D&reserved=0

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is adding a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

Quoted 3 lines
Quoted 3 lines
  drivers/pci/endpoint/functions/Kconfig        |  19 +
  drivers/pci/endpoint/functions/Makefile       |   2 +
  drivers/pci/endpoint/functions/pci-epf-vcon.c | 554

++++++++++++++++++

Quoted 10 lines
Quoted 10 lines
  .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
  .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
  include/uapi/linux/virtio_pci.h               |   3 +
  6 files changed, 1170 insertions(+)

create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h

--
2.25.1

#9 lore raw
Quoted 85 lines · Frank Li
Quoted 74 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Sunday, April 16, 2023 9:12 PM
To: Frank Li <[email protected]>; Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

Quoted 14 lines · Frank Li
Quoted 14 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Friday, April 14, 2023 7:39 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Shunsuke Mie <[email protected]>; Frank Li <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Quoted 5 lines
Quoted 5 lines

Caution: EXT Email

PCIe endpoint framework provides APIs to implement PCIe endpoint function.
This framework allows defining various PCIe endpoint function behaviors

in

Quoted 3 lines
Quoted 3 lines

software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the

conciseness

Quoted 4 lines
Quoted 4 lines

of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver

using

Quoted 6 lines
Quoted 6 lines

the extended PCIe endpoint framework for virtio. It can be communicate host and endpoint over virtio as console.

An architecture of the function driver is following:

┌────────────┐ ┌────────────

──
>> ────────┬────────────┐
>>    │virtio      │         │                      │virtio      │
>>    │console drv │         ├───────────────┐      │

console

Quoted 2 lines
Quoted 2 lines
drv │
   ├────────────┤         │(virtio console│      ├───
──
>> ───────┤
>>    │ virtio bus │         │ device)       │◄────►│ virtio bus │
>>    ├────────────┤         ├---------------┤      └────
──
>> ──────┤
>>    │            │         │ pci ep virtio │                   │
>>    │  pci bus   │         │  console drv  │                   │
>>    │            │  pcie   ├───────────────┤                   │
>>    │            │ ◄─────► │  pci ep Bus   │                   │
>>    └────────────┘         └────────────
──
>> ─┴───────────────────┘
>>      PCIe Root              PCIe Endpoint
Quoted 1 line
Quoted 1 line
Quoted 5 lines
Quoted 3 lines

[Frank Li] Some basic question,
I see you call register_virtio_device at epf_vcon_setup_vdev, Why call it as virtio console? I suppose it should be virtiobus directly?

I'm sorry I didn't understand your question. What do you mean the virtiobus directly?

I go through your code again. I think I understand why you need pci-epf-vcon.c. Actually, my means is like virtio_mmio_probe.

vm_dev->vdev.id.device = readl(vm_dev->base + VIRTIO_MMIO_DEVICE_ID); vm_dev->vdev.id.vendor = readl(vm_dev->base + VIRTIO_MMIO_VENDOR_ID);

Quoted 8 lines

I am not sure that if VIRTIO_MMIO_VENDOR_ID and VIRTIO_MMIO_DEVICE_ID reuse PCI's vendor ID and Device ID. If yes, you can directly get such information from epf. If no, a customer field can been added at epf driver.

So you needn't write pci-epf-vcon and pci-epf-vnet .....

Of cause it will be wonderful if directly use virtio_mmio_probe by dynmatic create platform Devices. It may have some difficult because pci memory map requirement.

I think that some fields are shared between the vdev and epf device. However, we need to implement device emulation because each virtio device has its specific set of tasks. For example, the virtio-net device has a control queue, and the driver can request MAC filters, VLANs, and other settings via this queue. These requests have to be processed by the virtio device that we are implementing in pci-epf-vnet.

The simplest virtio-console device doesn’t have these tasks, but the other virtio devices requireprocessing them.

That's why the current pci-epf-virtio design requires a specific implementation for each virtio device.

Is this what you meant?

Quoted 84 lines
Quoted 84 lines
Quoted 2 lines

Previous you use virtio-net, why change to virtio-console here? Does it

matter?

No, it doesn't. Just I'd like to break down the changes into smaller steps to make it easier to review and merge the changes.

As a first step, I propose adding a simplest virtio function driver with the extension defined in pci-epf-virtio.{h,c}.

Quoted 1 line

All virtio-XXX should work?

Yes, the extension is designed to use any type of virtio device.

Quoted 1 line

You removed EDMA support this version?

I planed the support will be added with epf virtio-net patches.

Quoted 11 lines
Quoted 11 lines

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908db3 ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315 3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB 5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Flinux-pci%2F20230113090350.1103494-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf 4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line

%7C%7C&sdata=jYgy%2Bxk84ZXZRVfqm0GCXoRnCTLMrX4zTfV%2Bs5Mm

svo

Quoted 4 lines
Quoted 4 lines

%3D&reserved=0
- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908db3 ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315 3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB 5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Fvirtualization%2F20230202090934.549556-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf 4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line

%7C%7C&sdata=K4El76GSAGtsWkNBXJK5%2Fn7flCN20eEMZpZYTX2WIZ0

%3

Quoted 15 lines
Quoted 15 lines

D&reserved=0

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is adding a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

Quoted 3 lines
Quoted 3 lines
   drivers/pci/endpoint/functions/Kconfig        |  19 +
   drivers/pci/endpoint/functions/Makefile       |   2 +
   drivers/pci/endpoint/functions/pci-epf-vcon.c | 554

++++++++++++++++++

Quoted 8 lines
Quoted 8 lines
   .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
   .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
   include/uapi/linux/virtio_pci.h               |   3 +
   6 files changed, 1170 insertions(+)

create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

--
2.25.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#10 lore raw
Quoted 137 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Tuesday, April 18, 2023 5:31 AM
To: Frank Li <[email protected]>; Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

Quoted 13 lines · Frank Li
Quoted 13 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Sunday, April 16, 2023 9:12 PM
To: Frank Li <[email protected]>; Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio

console

Quoted 10 lines
Quoted 10 lines

Caution: EXT Email

Quoted 6 lines · Frank Li
Quoted 6 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Friday, April 14, 2023 7:39 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>;

Bjorn

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Helgaas <[email protected]>; Michael S. Tsirkin

<[email protected]>;

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Jason Wang <[email protected]>; Shunsuke Mie

<[email protected]>;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Frank Li <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie

<[email protected]>;

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

[email protected]; [email protected]; [email protected]
Subject: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

PCIe endpoint framework provides APIs to implement PCIe endpoint function.
This framework allows defining various PCIe endpoint function

behaviors

Quoted 11 lines
Quoted 11 lines

in

Quoted 3 lines
Quoted 3 lines

software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the

conciseness

Quoted 4 lines
Quoted 4 lines

of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver

using

Quoted 1 line
Quoted 1 line

the extended PCIe endpoint framework for virtio. It can be

communicate

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

host and endpoint over virtio as console.

An architecture of the function driver is following:

┌────────────┐ ┌───────────

─
>> ──
>>>> ────────┬────────────┐
>>>>    │virtio      │         │                      │virtio      │
>>>>    │console drv │         ├───────────────┐      │
Quoted 3 lines
Quoted 3 lines

console

Quoted 2 lines
Quoted 2 lines
drv │
   ├────────────┤         │(virtio console│      ├──
─
>> ──
>>>> ───────┤
>>>>    │ virtio bus │         │ device)       │◄────►│ virtio bus │
>>>>    ├────────────┤         ├---------------┤      └───
─
>> ──
>>>> ──────┤
>>>>    │            │         │ pci ep virtio │                   │
>>>>    │  pci bus   │         │  console drv  │                   │
>>>>    │            │  pcie   ├───────────────┤
│
>>>>    │            │ ◄─────► │  pci ep Bus   │                   │
>>>>    └────────────┘         └───────────
─
>> ──
>>>> ─┴───────────────────┘
>>>>      PCIe Root              PCIe Endpoint
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

[Frank Li] Some basic question,
I see you call register_virtio_device at epf_vcon_setup_vdev, Why call it as virtio console? I suppose it should be virtiobus directly?

I'm sorry I didn't understand your question. What do you mean the virtiobus directly?

I go through your code again. I think I understand why you need pci-epf-

vcon.c.

Quoted 3 lines

Actually, my means is like virtio_mmio_probe.

vm_dev->vdev.id.device = readl(vm_dev->base +

VIRTIO_MMIO_DEVICE_ID);

Quoted 1 line

vm_dev->vdev.id.vendor = readl(vm_dev->base +

VIRTIO_MMIO_VENDOR_ID);

Quoted 2 lines

I am not sure that if VIRTIO_MMIO_VENDOR_ID and

VIRTIO_MMIO_DEVICE_ID

Quoted 1 line

reuse PCI's vendor ID and Device ID. If yes, you can directly get such

information

Quoted 5 lines

from epf. If no, a customer field can been added at epf driver.

So you needn't write pci-epf-vcon and pci-epf-vnet .....

Of cause it will be wonderful if directly use virtio_mmio_probe by dynmatic

create platform

Quoted 1 line

Devices. It may have some difficult because pci memory map requirement.

I think that some fields are shared between the vdev and epf device. However, we need to implement device emulation because each virtio device
has its specific set of tasks. For example, the virtio-net device has a control queue, and the driver can request MAC filters, VLANs, and other settings via this queue. These requests have to be processed by the virtio device that we are implementing in pci-epf-vnet.

Quoted 7 lines

The simplest virtio-console device doesn’t have these tasks, but the other virtio devices requireprocessing them.

That's why the current pci-epf-virtio design requires a specific implementation for each virtio device.

Is this what you meant

I see. Thank you for explain.
Thing may become complex. How to implement composite at EPF driver? Such as console + net

Quoted 118 lines
Quoted 21 lines
Quoted 21 lines
Quoted 3 lines

Previous you use virtio-net, why change to virtio-console here? Does it

matter?

No, it doesn't. Just I'd like to break down the changes into smaller steps to make it easier to review and merge the changes.

As a first step, I propose adding a simplest virtio function driver with the extension defined in pci-epf-virtio.{h,c}.

Quoted 1 line

All virtio-XXX should work?

Yes, the extension is designed to use any type of virtio device.

Quoted 1 line

You removed EDMA support this version?

I planed the support will be added with epf virtio-net patches.

Quoted 6 lines
Quoted 6 lines

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7C80a237184ff4420a96de08db 3ff80d78%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817410683 2489955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LSP LeFzTYpUVTZpymoM00Es9kOpxlN90%2BDM6ceDJMFE%3D&reserved=0

Quoted 1 line
Quoted 1 line

%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908

db3

Quoted 1 line
Quoted 1 line

ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315

Quoted 1 line
Quoted 1 line

3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV

Quoted 1 line
Quoted 1 line

2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB

Quoted 4 lines
Quoted 4 lines

5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Flinux-pci%2F20230113090350.1103494-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf

Quoted 1 line
Quoted 1 line

4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7

Quoted 1 line
Quoted 1 line

C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w

Quoted 1 line
Quoted 1 line

LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%7C%7C&sdata=jYgy%2Bxk84ZXZRVfqm0GCXoRnCTLMrX4zTfV%2Bs5

Mm

Quoted 6 lines
Quoted 6 lines

svo

Quoted 4 lines
Quoted 4 lines

%3D&reserved=0
- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7C80a237184ff4420a96de08db 3ff80d78%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817410683 2489955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LSP LeFzTYpUVTZpymoM00Es9kOpxlN90%2BDM6ceDJMFE%3D&reserved=0

Quoted 1 line
Quoted 1 line

%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908

db3

Quoted 1 line
Quoted 1 line

ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315

Quoted 1 line
Quoted 1 line

3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV

Quoted 1 line
Quoted 1 line

2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB

Quoted 4 lines
Quoted 4 lines

5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Fvirtualization%2F20230202090934.549556-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf

Quoted 1 line
Quoted 1 line

4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7

Quoted 1 line
Quoted 1 line

C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w

Quoted 1 line
Quoted 1 line

LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%7C%7C&sdata=K4El76GSAGtsWkNBXJK5%2Fn7flCN20eEMZpZYTX2WI

Z0

Quoted 5 lines
Quoted 5 lines

%3

Quoted 4 lines
Quoted 4 lines

D&reserved=0

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is

adding

Quoted 25 lines
Quoted 25 lines
Quoted 11 lines
Quoted 11 lines

a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

Quoted 3 lines
Quoted 3 lines
   drivers/pci/endpoint/functions/Kconfig        |  19 +
   drivers/pci/endpoint/functions/Makefile       |   2 +
   drivers/pci/endpoint/functions/pci-epf-vcon.c | 554

++++++++++++++++++

Quoted 10 lines
Quoted 10 lines
   .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
   .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
   include/uapi/linux/virtio_pci.h               |   3 +
   6 files changed, 1170 insertions(+)

create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h

--
2.25.1

#11 lore raw

2023年4月19日(水) 1:42 Frank Li <[email protected]>:

Quoted 141 lines
Quoted 141 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Tuesday, April 18, 2023 5:31 AM
To: Frank Li <[email protected]>; Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

Quoted 13 lines · Frank Li
Quoted 13 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Sunday, April 16, 2023 9:12 PM
To: Frank Li <[email protected]>; Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>; Bjorn Helgaas <[email protected]>; Michael S. Tsirkin <[email protected]>; Jason Wang <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Subject: Re: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio

console

Quoted 10 lines
Quoted 10 lines

Caution: EXT Email

Quoted 6 lines · Frank Li
Quoted 6 lines

-----Original Message-----
From: Shunsuke Mie <[email protected]>
Sent: Friday, April 14, 2023 7:39 AM
To: Lorenzo Pieralisi <[email protected]>
Cc: Krzysztof Wilczyński <[email protected]>; Manivannan Sadhasivam <[email protected]>; Kishon Vijay Abraham I <[email protected]>;

Bjorn

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Helgaas <[email protected]>; Michael S. Tsirkin

<[email protected]>;

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

Jason Wang <[email protected]>; Shunsuke Mie

<[email protected]>;

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

Frank Li <[email protected]>; Jon Mason <[email protected]>; Randy Dunlap <[email protected]>; Ren Zhijie

<[email protected]>;

Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines

[email protected]; [email protected]; [email protected]
Subject: [EXT] [RFC PATCH 0/3] Introduce a PCIe endpoint virtio console

Caution: EXT Email

PCIe endpoint framework provides APIs to implement PCIe endpoint function.
This framework allows defining various PCIe endpoint function

behaviors

Quoted 11 lines
Quoted 11 lines

in

Quoted 3 lines
Quoted 3 lines

software. This patch extend the framework for virtio pci device. The virtio is defined to communicate guest on virtual machine and host side. Advantage of the virtio is the efficiency of data transfer and the

conciseness

Quoted 4 lines
Quoted 4 lines

of implementation device using software. It also be applied to PCIe endpoint function.

We designed and implemented a PCIe EP virtio console function driver

using

Quoted 1 line
Quoted 1 line

the extended PCIe endpoint framework for virtio. It can be

communicate

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

host and endpoint over virtio as console.

An architecture of the function driver is following:

┌────────────┐ ┌───────────

─
>> ──
>>>> ────────┬────────────┐
>>>>    │virtio      │         │                      │virtio      │
>>>>    │console drv │         ├───────────────┐      │
Quoted 3 lines
Quoted 3 lines

console

Quoted 2 lines
Quoted 2 lines
drv │
   ├────────────┤         │(virtio console│      ├──
─
>> ──
>>>> ───────┤
>>>>    │ virtio bus │         │ device)       │◄────►│ virtio bus │
>>>>    ├────────────┤         ├---------------┤      └───
─
>> ──
>>>> ──────┤
>>>>    │            │         │ pci ep virtio │                   │
>>>>    │  pci bus   │         │  console drv  │                   │
>>>>    │            │  pcie   ├───────────────┤
│
>>>>    │            │ ◄─────► │  pci ep Bus   │                   │
>>>>    └────────────┘         └───────────
─
>> ──
>>>> ─┴───────────────────┘
>>>>      PCIe Root              PCIe Endpoint
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line

[Frank Li] Some basic question,
I see you call register_virtio_device at epf_vcon_setup_vdev, Why call it as virtio console? I suppose it should be virtiobus directly?

I'm sorry I didn't understand your question. What do you mean the virtiobus directly?

I go through your code again. I think I understand why you need pci-epf-

vcon.c.

Quoted 3 lines

Actually, my means is like virtio_mmio_probe.

vm_dev->vdev.id.device = readl(vm_dev->base +

VIRTIO_MMIO_DEVICE_ID);

Quoted 1 line

vm_dev->vdev.id.vendor = readl(vm_dev->base +

VIRTIO_MMIO_VENDOR_ID);

Quoted 2 lines

I am not sure that if VIRTIO_MMIO_VENDOR_ID and

VIRTIO_MMIO_DEVICE_ID

Quoted 1 line

reuse PCI's vendor ID and Device ID. If yes, you can directly get such

information

Quoted 5 lines

from epf. If no, a customer field can been added at epf driver.

So you needn't write pci-epf-vcon and pci-epf-vnet .....

Of cause it will be wonderful if directly use virtio_mmio_probe by dynmatic

create platform

Quoted 1 line

Devices. It may have some difficult because pci memory map requirement.

I think that some fields are shared between the vdev and epf device. However, we need to implement device emulation because each virtio device
has its specific set of tasks. For example, the virtio-net device has a control queue, and the driver can request MAC filters, VLANs, and other settings via this queue. These requests have to be processed by the virtio device that we are implementing in pci-epf-vnet.

The simplest virtio-console device doesn’t have these tasks, but the other virtio devices requireprocessing them.

Quoted 8 lines
Quoted 4 lines

That's why the current pci-epf-virtio design requires a specific implementation for each virtio device.

Is this what you meant

I see. Thank you for explain.
Thing may become complex. How to implement composite at EPF driver? Such as console + net

I'm not sure your suggestion. Could you tell me the advantages?

Quoted 116 lines
Quoted 116 lines
Quoted 21 lines
Quoted 21 lines
Quoted 3 lines

Previous you use virtio-net, why change to virtio-console here? Does it

matter?

No, it doesn't. Just I'd like to break down the changes into smaller steps to make it easier to review and merge the changes.

As a first step, I propose adding a simplest virtio function driver with the extension defined in pci-epf-virtio.{h,c}.

Quoted 1 line

All virtio-XXX should work?

Yes, the extension is designed to use any type of virtio device.

Quoted 1 line

You removed EDMA support this version?

I planed the support will be added with epf virtio-net patches.

Quoted 6 lines
Quoted 6 lines

Introduced driver is pci ep virtio console drv in the figure. It works as ep function for PCIe root and virtual virtio console device for PCIe endpoint. Each side of virtio console driver has virtqueue, and introduced driver transfers data on the virtqueue to each other. A data on root tx queue is transfered to endpoint rx queue and vice versa.

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

This patchset is depend follwing patches which are under discussion.

- [RFC PATCH 0/3] Deal with alignment restriction on EP side link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7C80a237184ff4420a96de08db 3ff80d78%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817410683 2489955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LSP LeFzTYpUVTZpymoM00Es9kOpxlN90%2BDM6ceDJMFE%3D&reserved=0

Quoted 1 line
Quoted 1 line

%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908

db3

Quoted 1 line
Quoted 1 line

ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315

Quoted 1 line
Quoted 1 line

3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV

Quoted 1 line
Quoted 1 line

2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB

Quoted 4 lines
Quoted 4 lines

5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Flinux-pci%2F20230113090350.1103494-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf

Quoted 1 line
Quoted 1 line

4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7

Quoted 1 line
Quoted 1 line

C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w

Quoted 1 line
Quoted 1 line

LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%7C%7C&sdata=jYgy%2Bxk84ZXZRVfqm0GCXoRnCTLMrX4zTfV%2Bs5

Mm

Quoted 6 lines
Quoted 6 lines

svo

Quoted 4 lines
Quoted 4 lines

%3D&reserved=0
- [RFC PATCH v2 0/7] Introduce a vringh accessor for IO memory link:

https://lore.k/
%2F&data=05%7C01%7Cfrank.li%40nxp.com%7C80a237184ff4420a96de08db 3ff80d78%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817410683 2489955%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV 2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=LSP LeFzTYpUVTZpymoM00Es9kOpxlN90%2BDM6ceDJMFE%3D&reserved=0

Quoted 1 line
Quoted 1 line

%2F&data=05%7C01%7Cfrank.li%40nxp.com%7Cff59a16f88c643913e3908

db3

Quoted 1 line
Quoted 1 line

ee91ca8%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63817294315

Quoted 1 line
Quoted 1 line

3821831%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV

Quoted 1 line
Quoted 1 line

2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=hTB

Quoted 4 lines
Quoted 4 lines

5UDaJoJfta9ohMG%2BrxCVJY34ANn10iSLP9iCHX3M%3D&reserved=0

Quoted 2 lines
Quoted 2 lines

ernel.org%2Fvirtualization%2F20230202090934.549556-1-

mie%40igel.co.jp%2F&data=05%7C01%7CFrank.Li%40nxp.com%7Cea6513dbf

Quoted 1 line
Quoted 1 line

4084b80ced208db3ce54133%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7

Quoted 1 line
Quoted 1 line

C0%7C638170727558800720%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4w

Quoted 1 line
Quoted 1 line

LjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

%7C%7C&sdata=K4El76GSAGtsWkNBXJK5%2Fn7flCN20eEMZpZYTX2WI

Z0

Quoted 5 lines
Quoted 5 lines

%3

Quoted 4 lines
Quoted 4 lines

D&reserved=0

First of this patchset is introduce a helper function to realize pci virtio function using PCIe endpoint framework. The second one is

adding

Quoted 23 lines
Quoted 23 lines
Quoted 11 lines
Quoted 11 lines

a missing definition for virtio pci header. The last one is for PCIe endpoint virtio console driver.

This is tested on linux-20230406 and RCar S4 board as PCIe endpoint.

Shunsuke Mie (3):
PCI: endpoint: introduce a helper to implement pci ep virtio function
virtio_pci: add a definition of queue flag in ISR
PCI: endpoint: Add EP function driver to provide virtio-console
functionality

Quoted 3 lines
Quoted 3 lines
   drivers/pci/endpoint/functions/Kconfig        |  19 +
   drivers/pci/endpoint/functions/Makefile       |   2 +
   drivers/pci/endpoint/functions/pci-epf-vcon.c | 554

++++++++++++++++++

Quoted 8 lines
Quoted 8 lines
   .../pci/endpoint/functions/pci-epf-virtio.c   | 469 +++++++++++++++
   .../pci/endpoint/functions/pci-epf-virtio.h   | 123 ++++
   include/uapi/linux/virtio_pci.h               |   3 +
   6 files changed, 1170 insertions(+)

create mode 100644 drivers/pci/endpoint/functions/pci-epf-vcon.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.c create mode 100644 drivers/pci/endpoint/functions/pci-epf-virtio.h

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

--
2.25.1

Best regards,
Shunsuike