@@ -32,6 +32,7 @@
#define TUNSETVNETLE _IOW('T', 220, int)
#define TUNSETVNETBE _IOW('T', 222, int)
#define TUNSETSTEERINGEBPF _IOR('T', 224, int)
+#define TUNGETVNETHASHCAP _IOR('T', 228, NetVnetHash)
#define TUNSETVNETHASH _IOW('T', 229, NetVnetHash)
#endif
@@ -36,6 +36,7 @@ ssize_t tap_read_packet(int tapfd, uint8_t *buf, int maxlen);
void tap_set_sndbuf(int fd, const NetdevTapOptions *tap, Error **errp);
int tap_probe_vnet_hdr(int fd, Error **errp);
+bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types);
int tap_probe_has_ufo(int fd);
int tap_probe_has_uso(int fd);
void tap_fd_set_offload(int fd, int csum, int tso4, int tso6, int ecn, int ufo,
@@ -217,6 +217,11 @@ int tap_probe_has_uso(int fd)
return 0;
}
+bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types)
+{
+ return false;
+}
+
void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}
@@ -185,6 +185,19 @@ int tap_probe_has_uso(int fd)
return 1;
}
+bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types)
+{
+ NetVnetHash hash;
+
+ if (ioctl(fd, TUNGETVNETHASHCAP, &hash)) {
+ return false;
+ }
+
+ *types = hash.types;
+
+ return true;
+}
+
void tap_fd_set_vnet_hdr_len(int fd, int len)
{
if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) {
@@ -221,6 +221,11 @@ int tap_probe_has_uso(int fd)
return 0;
}
+bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types)
+{
+ return false;
+}
+
void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}
@@ -52,6 +52,11 @@ int tap_probe_has_uso(int fd)
return 0;
}
+bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types)
+{
+ return false;
+}
+
void tap_fd_set_vnet_hdr_len(int fd, int len)
{
}
@@ -248,6 +248,13 @@ static void tap_set_vnet_hdr_len(NetClientState *nc, int len)
s->using_vnet_hdr = true;
}
+static bool tap_get_vnet_hash_supported_types(NetClientState *nc,
+ uint32_t *types)
+{
+ TAPState *s = DO_UPCAST(TAPState, nc, nc);
+ return tap_probe_vnet_hash_supported_types(s->fd, types);
+}
+
static void tap_set_vnet_hash(NetClientState *nc, const NetVnetHash *hash)
{
TAPState *s = DO_UPCAST(TAPState, nc, nc);
@@ -350,6 +357,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,
+ .get_vnet_hash_supported_types = tap_get_vnet_hash_supported_types,
.set_vnet_hash = tap_set_vnet_hash,
.set_vnet_le = tap_set_vnet_le,
.set_vnet_be = tap_set_vnet_be,
This allows offloading virtio-net hashing to tap on Linux. Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> --- net/tap-linux.h | 1 + net/tap_int.h | 1 + net/tap-bsd.c | 5 +++++ net/tap-linux.c | 13 +++++++++++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 8 ++++++++ 7 files changed, 38 insertions(+)