@@ -35,6 +35,20 @@ typedef struct NICConf {
int32_t bootindex;
} NICConf;
+#define NET_VNET_HASH_REPORT 1
+#define NET_VNET_HASH_RSS 2
+
+typedef struct NetVnetHash {
+ uint16_t flags;
+ uint8_t pad[2];
+ uint32_t types;
+} NetVnetHash;
+
+typedef struct NetVnetHashRss {
+ uint16_t indirection_table_mask;
+ uint16_t unclassified_queue;
+} NetVnetHashRss;
+
#define DEFINE_NIC_PROPERTIES(_state, _conf) \
DEFINE_PROP_MACADDR("mac", _state, _conf.macaddr), \
DEFINE_PROP_NETDEV("netdev", _state, _conf.peers)
@@ -61,6 +75,7 @@ typedef void (SetOffload)(NetClientState *, int, int, int, int, int, int, int);
typedef int (GetVnetHdrLen)(NetClientState *);
typedef void (SetVnetHdrLen)(NetClientState *, int);
typedef bool (GetVnetHashSupportedTypes)(NetClientState *, uint32_t *);
+typedef void (SetVnetHash)(NetClientState *, const NetVnetHash *);
typedef int (SetVnetLE)(NetClientState *, bool);
typedef int (SetVnetBE)(NetClientState *, bool);
typedef struct SocketReadState SocketReadState;
@@ -91,6 +106,7 @@ typedef struct NetClientInfo {
SetVnetLE *set_vnet_le;
SetVnetBE *set_vnet_be;
GetVnetHashSupportedTypes *get_vnet_hash_supported_types;
+ SetVnetHash *set_vnet_hash;
NetAnnounce *announce;
SetSteeringEBPF *set_steering_ebpf;
NetCheckPeerType *check_peer_type;
@@ -195,6 +211,7 @@ void qemu_set_offload(NetClientState *nc, int csum, int tso4, int tso6,
int qemu_get_vnet_hdr_len(NetClientState *nc);
void qemu_set_vnet_hdr_len(NetClientState *nc, int len);
bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *types);
+void qemu_set_vnet_hash(NetClientState *nc, const NetVnetHash *hash);
int qemu_set_vnet_le(NetClientState *nc, bool is_le);
int qemu_set_vnet_be(NetClientState *nc, bool is_be);
void qemu_macaddr_default_if_unset(MACAddr *macaddr);
@@ -32,6 +32,7 @@
#define TUNSETVNETLE _IOW('T', 220, int)
#define TUNSETVNETBE _IOW('T', 222, int)
#define TUNSETSTEERINGEBPF _IOR('T', 224, int)
+#define TUNSETVNETHASH _IOW('T', 229, NetVnetHash)
#endif
@@ -27,6 +27,7 @@
#define NET_TAP_INT_H
#include "qapi/qapi-types-net.h"
+#include "net/net.h"
int tap_open(char *ifname, int ifname_size, int *vnet_hdr,
int vnet_hdr_required, int mq_required, Error **errp);
@@ -40,6 +41,7 @@ int tap_probe_has_uso(int fd);
void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo,
int uso4, int uso6);
void tap_fd_set_vnet_hdr_len(int fd, int len);
+void tap_fd_set_vnet_hash(int fd, const NetVnetHash *hash);
int tap_fd_set_vnet_le(int fd, int vnet_is_le);
int tap_fd_set_vnet_be(int fd, int vnet_is_be);
int tap_fd_enable(int fd);
@@ -568,6 +568,11 @@ bool qemu_get_vnet_hash_supported_types(NetClientState *nc, uint32_t *types)
return nc->info->get_vnet_hash_supported_types(nc, types);
}
+void qemu_set_vnet_hash(NetClientState *nc, const NetVnetHash *hash)
+{
+ nc->info->set_vnet_hash(nc, hash);
+}
+
int qemu_set_vnet_le(NetClientState *nc, bool is_le)
{
#if HOST_BIG_ENDIAN
@@ -221,6 +221,11 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}
+void tap_fd_set_vnet_hash(int fd, const NetVnetHash *hash)
+{
+ g_assert_not_reached();
+}
+
int tap_fd_set_vnet_le(int fd, int is_le)
{
return -EINVAL;
@@ -194,6 +194,11 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
}
}
+void tap_fd_set_vnet_hash(int fd, const NetVnetHash *hash)
+{
+ assert(!ioctl(fd, TUNSETVNETHASH, hash));
+}
+
int tap_fd_set_vnet_le(int fd, int is_le)
{
int arg = is_le ? 1 : 0;
@@ -225,6 +225,11 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}
+void tap_fd_set_vnet_hash(int fd, const NetVnetHash *hash)
+{
+ g_assert_not_reached();
+}
+
int tap_fd_set_vnet_le(int fd, int is_le)
{
return -EINVAL;
@@ -56,6 +56,11 @@ void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}
+void tap_fd_set_vnet_hash(int fd, const NetVnetHash *hash)
+{
+ g_assert_not_reached();
+}
+
int tap_fd_set_vnet_le(int fd, int is_le)
{
return -EINVAL;
@@ -248,6 +248,12 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, int len)
s->using_vnet_hdr = true;
}
+static void tap_set_vnet_hash(NetClientState *nc, const NetVnetHash *hash)
+{
+ TAPState *s = DO_UPCAST(TAPState, nc, nc);
+ return tap_fd_set_vnet_hash(s->fd, hash);
+}
+
static int tap_set_vnet_le(NetClientState *nc, bool is_le)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
@@ -344,6 +350,7 @@ static NetClientInfo net_tap_info = {
.has_vnet_hdr_len = tap_has_vnet_hdr_len,
.set_offload = tap_set_offload,
.set_vnet_hdr_len = tap_set_vnet_hdr_len,
+ .set_vnet_hash = tap_set_vnet_hash,
.set_vnet_le = tap_set_vnet_le,
.set_vnet_be = tap_set_vnet_be,
.set_steering_ebpf = tap_set_steering_ebpf,
@@ -278,6 +278,11 @@ static bool vhost_vdpa_get_vnet_hash_supported_types(NetClientState *nc,
return true;
}
+static void vhost_vdpa_set_vnet_hash(NetClientState *nc,
+ const NetVnetHash *hash)
+{
+}
+
static bool vhost_vdpa_has_ufo(NetClientState *nc)
{
assert(nc->info->type == NET_CLIENT_DRIVER_VHOST_VDPA);
@@ -457,6 +462,7 @@ static NetClientInfo net_vhost_vdpa_info = {
.cleanup = vhost_vdpa_cleanup,
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
.get_vnet_hash_supported_types = vhost_vdpa_get_vnet_hash_supported_types,
+ .set_vnet_hash = vhost_vdpa_set_vnet_hash,
.has_ufo = vhost_vdpa_has_ufo,
.check_peer_type = vhost_vdpa_check_peer_type,
};
@@ -1324,6 +1330,7 @@ static NetClientInfo net_vhost_vdpa_cvq_info = {
.cleanup = vhost_vdpa_cleanup,
.has_vnet_hdr = vhost_vdpa_has_vnet_hdr,
.get_vnet_hash_supported_types = vhost_vdpa_get_vnet_hash_supported_types,
+ .set_vnet_hash = vhost_vdpa_set_vnet_hash,
.has_ufo = vhost_vdpa_has_ufo,
.check_peer_type = vhost_vdpa_check_peer_type,
};
This adds set_vnet_hash() to configure virtio hashing and implements it for Linux's tap. vDPA will have an empty function as configuring virtio hashing is done with the load(). Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> --- include/net/net.h | 17 +++++++++++++++++ net/tap-linux.h | 1 + net/tap_int.h | 2 ++ net/net.c | 5 +++++ net/tap-bsd.c | 5 +++++ net/tap-linux.c | 5 +++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 7 +++++++ net/vhost-vdpa.c | 7 +++++++ 10 files changed, 59 insertions(+)