mbox

[v3,0/2] vhost: support VIRTIO_F_RING_RESET for vhost-user

Message ID cover.1662952732.git.kangjie.xu@linux.alibaba.com (mailing list archive)
Headers

Message

Kangjie Xu Sept. 12, 2022, 3:36 a.m. UTC
  Add VIRTIO_F_RING_RESET, which indicates that the driver can reset a
virtqueue individually.

VIRTIO_F_RING_RESET feature is added to virtio-spec 1.2. The relevant
information is in
    https://github.com/oasis-tcs/virtio-spec/issues/124
    https://github.com/oasis-tcs/virtio-spec/issues/139

The implementation only adds the feature bit in supported features. We
reuse the existing vhost protocol and make small modifications to
the VHOST_USER_GET_VRING_BASE implementation(do not destroy the device
unless the vq is the last active one in the device).

Virtqueue reset process can be concluded as two parts:
1. The driver can reset a virtqueue. It will send VHOST_USER_GET_VRING_BASE
to DPDK. After received the message, DPDK will stop the virtqueue.

2. After the virtqueue is disabled, the driver may optionally re-enable
it. To avoid confusion with VHOST_USER_SET_VRING_ENABLE, we call this
part as "restart". The virtqueue's information may be changed when
restarting it. Thus, the information of the reset virtqueue should be
updated. This part is basically similar to when the virtqueue is started
for the first time, except that the restart process does not need to set
features and set mem table since they do not change. QEMU will send
messages containing size, base, addr, kickfd and callfd of the virtqueue
in order. Specifically, the DPDK will receive these messages in order:
    a. VHOST_USER_SET_VRING_NUM
    b. VHOST_USER_SET_VRING_BASE
    c. VHOST_USER_SET_VRING_ADDR
    d. VHOST_USER_SET_VRING_KICK
    e. VHOST_USER_SET_VRING_CALL
    f. VHOST_USER_SET_VRING_ENABLE
The last VHOST_USER_SET_VRING_ENABLE message with "payload.state.num" set
to 1, will be sent to enable the virtqueue and the restart process is
finished.

Test environment:
    Host: 5.4.189
    Qemu: QEMU emulator version 7.1.50 (With vq reset support)
    Guest: 5.19.0-rc3 (With vq reset support)
    DPDK: 22.11-rc0
    Test Cmd: ethtool -g eth1; ethtool -G eth1 rx $1 tx $2;
            ethtool -g eth1;

    The driver can resize the virtio queue, then virtio queue reset
    function should be triggered.

Guest Kernel Patch:
    https://lore.kernel.org/bpf/20220801063902.129329-1-xuanzhuo@
linux.alibaba.com/

QEMU Patch:
    https://lore.kernel.org/qemu-devel/cover.1662949366.git.kangjie.xu@
linux.alibaba.com/
    https://lore.kernel.org/qemu-devel/cover.1662916759.git.kangjie.xu@
linux.alibaba.com/

Looking forward to your review and comments.

Kangjie Xu (2):
  vhost: destroy device when all vqs are inactive
  vhost: support VIRTIO_F_RING_RESET for vhost-user

 lib/vhost/vhost.h      |  8 +++++++-
 lib/vhost/vhost_user.c | 10 ++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)