From: Andrew<andrew@daynix.com>
When RSS is enabled the device tries to load the eBPF program
to select RX virtqueue in the TUN. If eBPF can be loaded
the RSS will function also with vhost (works with kernel 5.8 and later).
Software RSS is used as a fallback with vhost=off when eBPF can't be loaded
or when hash population requested by the guest.
Signed-off-by: Yuri Benditovich<yuri.benditovich@daynix.com>
Signed-off-by: Andrew Melnychenko<andrew@daynix.com>
---
hw/net/vhost_net.c | 2 +
hw/net/virtio-net.c | 125 +++++++++++++++++++++++++++++++--
include/hw/virtio/virtio-net.h | 4 ++
net/vhost-vdpa.c | 2 +
4 files changed, 129 insertions(+), 4 deletions(-)
diff --git a/hw/net/vhost_net.c b/hw/net/vhost_net.c
index 24d555e764..16124f99c3 100644
--- a/hw/net/vhost_net.c
+++ b/hw/net/vhost_net.c
@@ -71,6 +71,8 @@ static const int user_feature_bits[] = {
VIRTIO_NET_F_MTU,
VIRTIO_F_IOMMU_PLATFORM,
VIRTIO_F_RING_PACKED,
+ VIRTIO_NET_F_RSS,
+ VIRTIO_NET_F_HASH_REPORT,
/* This bit implies RARP isn't sent by QEMU out of band */
VIRTIO_NET_F_GUEST_ANNOUNCE,
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 09ceb02c9d..37016fc73a 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -691,6 +691,19 @@ static void virtio_net_set_queues(VirtIONet *n)
static void virtio_net_set_multiqueue(VirtIONet *n, int multiqueue);
+static uint64_t fix_ebpf_vhost_features(uint64_t features)
+{
+ /* If vhost=on & CONFIG_EBPF doesn't set - disable RSS feature */