dpdk CUSE

As the Userspace I/O HOWTO says

For many types of devices, creating a Linux kernel driver is overkill. All that is really needed is some way to handle an interrupt and provide access to the memory space of the device. The logic of controlling the device does not necessarily have to be within the kernel, as the device does not need to take advantage of any of other resources that the kernel provides. One such common class of devices that are like this are for industrial I/O cards.

To address this situation, the userspace I/O system (UIO) was designed. For typical industrial I/O cards, only a very small kernel module is needed. The main part of the driver will run in user space. This simplifies development and reduces the risk of serious bugs within a kernel module.

http://bryanpendleton.blogspot.com/2011/02/fuse-cuse-and-uio.html

CUSE is an extension of FUSE allowing character devices to be implemented in userspace, it has been contributed by Tejun Heo (SUSE)

https://kernelnewbies.org/Linux_2_6_31#head-80b05215d438e437ec0d6fd9430e3d13dbcee14d

https://lwn.net/Articles/308445/

https://github.com/spotify/linux/blob/master/fs/fuse/cuse.c

http://dpdk.org/doc/guides-16.04/prog_guide/vhost_lib.html

The vhost library implements a user space vhost driver. It supports both vhost-cuse (cuse: user space character device) and vhost-user(user space socket server).

vhost-cuse通过字符设备接收qemu控制命令,而vhost-user通过socket。

25.1. Vhost API Overview

  • Vhost driver registration

    rte_vhost_driver_register registers the vhost driver into the system. For vhost-cuse, character device file will be created under the /dev directory. Character device name is specified as the parameter. For vhost-user, a Unix domain socket server will be created with the parameter as the local socket path.

  • Vhost session start

    rte_vhost_driver_session_start starts the vhost session loop. Vhost session is an infinite blocking loop. Put the session in a dedicate DPDK thread.

  • Callback register

    Vhost supported vSwitch could call rte_vhost_driver_callback_register to register two callbacks, new_destory and destroy_device. When virtio device is activated or deactivated by guest virtual machine, the callback will be called, then vSwitch could put the device onto data core or remove the device from data core by setting or unsetting VIRTIO_DEV_RUNNING on the device flags.

  • Read/write packets from/to guest virtual machine

    rte_vhost_enqueue_burst transmit host packets to guest. rte_vhost_dequeue_burst receives packets from guest.

  • Feature enable/disable

    Now one negotiate-able feature in vhost is merge-able. vSwitch could enable/disable this feature for performance consideration.

原文地址:https://www.cnblogs.com/allcloud/p/7809343.html