mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-27 04:13:53 -06:00
vhost-vdpa: introduce vhost-vdpa backend
Currently we have 2 types of vhost backends in QEMU: vhost kernel and vhost-user. The above patch provides a generic device for vDPA purpose, this vDPA device exposes to user space a non-vendor-specific configuration interface for setting up a vhost HW accelerator, this patch set introduces a third vhost backend called vhost-vdpa based on the vDPA interface. Vhost-vdpa usage: qemu-system-x86_64 -cpu host -enable-kvm \ ...... -netdev type=vhost-vdpa,vhostdev=/dev/vhost-vdpa-id,id=vhost-vdpa0 \ -device virtio-net-pci,netdev=vhost-vdpa0,page-per-vq=on \ Signed-off-by: Lingshan zhu <lingshan.zhu@intel.com> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com> Signed-off-by: Cindy Lu <lulu@redhat.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Message-Id: <20200701145538.22333-14-lulu@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Jason Wang <jasowang@redhat.com>
This commit is contained in:
parent
38140cc4d9
commit
108a64818e
12 changed files with 600 additions and 7 deletions
|
@ -43,6 +43,7 @@
|
|||
#include "monitor/qdev.h"
|
||||
#include "hw/pci/pci.h"
|
||||
#include "net_rx_pkt.h"
|
||||
#include "hw/virtio/vhost.h"
|
||||
|
||||
#define VIRTIO_NET_VM_VERSION 11
|
||||
|
||||
|
@ -125,6 +126,8 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
|
|||
VirtIONet *n = VIRTIO_NET(vdev);
|
||||
struct virtio_net_config netcfg;
|
||||
|
||||
int ret = 0;
|
||||
memset(&netcfg, 0 , sizeof(struct virtio_net_config));
|
||||
virtio_stw_p(vdev, &netcfg.status, n->status);
|
||||
virtio_stw_p(vdev, &netcfg.max_virtqueue_pairs, n->max_queues);
|
||||
virtio_stw_p(vdev, &netcfg.mtu, n->net_conf.mtu);
|
||||
|
@ -138,6 +141,15 @@ static void virtio_net_get_config(VirtIODevice *vdev, uint8_t *config)
|
|||
virtio_stl_p(vdev, &netcfg.supported_hash_types,
|
||||
VIRTIO_NET_RSS_SUPPORTED_HASHES);
|
||||
memcpy(config, &netcfg, n->config_size);
|
||||
|
||||
NetClientState *nc = qemu_get_queue(n->nic);
|
||||
if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
|
||||
ret = vhost_net_get_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
|
||||
n->config_size);
|
||||
if (ret != -1) {
|
||||
memcpy(config, &netcfg, n->config_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
|
||||
|
@ -153,6 +165,13 @@ static void virtio_net_set_config(VirtIODevice *vdev, const uint8_t *config)
|
|||
memcpy(n->mac, netcfg.mac, ETH_ALEN);
|
||||
qemu_format_nic_info_str(qemu_get_queue(n->nic), n->mac);
|
||||
}
|
||||
|
||||
NetClientState *nc = qemu_get_queue(n->nic);
|
||||
if (nc->peer->info->type == NET_CLIENT_DRIVER_VHOST_VDPA) {
|
||||
vhost_net_set_config(get_vhost_net(nc->peer), (uint8_t *)&netcfg,
|
||||
0, n->config_size,
|
||||
VHOST_SET_CONFIG_TYPE_MASTER);
|
||||
}
|
||||
}
|
||||
|
||||
static bool virtio_net_started(VirtIONet *n, uint8_t status)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue