This allows offloading virtio-net hashing to tap on Linux. Signed-off-by: Akihiko Odaki <akihiko.od...@daynix.com> --- net/tap-linux.h | 1 + net/tap_int.h | 1 + net/tap-bsd.c | 5 +++++ net/tap-linux.c | 5 +++++ net/tap-solaris.c | 5 +++++ net/tap-stub.c | 5 +++++ net/tap.c | 8 ++++++++ 7 files changed, 30 insertions(+)
diff --git a/net/tap-linux.h b/net/tap-linux.h index 5bca6cab1867..fe30f4f27788 100644 --- a/net/tap-linux.h +++ b/net/tap-linux.h @@ -32,6 +32,7 @@ #define TUNSETVNETLE _IOW('T', 220, int) #define TUNSETVNETBE _IOW('T', 222, int) #define TUNSETSTEERINGEBPF _IOR('T', 224, int) +#define TUNGETVNETHASHTYPES _IOR('T', 228, __u32) #define TUNSETVNETREPORTINGAUTOMQ _IOR('T', 229, __u32) #define TUNSETVNETREPORTINGRSS _IOR('T', 230, NetVnetRss) #define TUNSETVNETRSS _IOR('T', 231, struct NetVnetRss) diff --git a/net/tap_int.h b/net/tap_int.h index 248d1efa51a0..5ff9ca721928 100644 --- a/net/tap_int.h +++ b/net/tap_int.h @@ -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, diff --git a/net/tap-bsd.c b/net/tap-bsd.c index 8ed384f02c5b..749732138502 100644 --- a/net/tap-bsd.c +++ b/net/tap-bsd.c @@ -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) { } diff --git a/net/tap-linux.c b/net/tap-linux.c index d0adb168e977..76fc88acaa18 100644 --- a/net/tap-linux.c +++ b/net/tap-linux.c @@ -196,6 +196,11 @@ int tap_probe_has_uso(int fd) return 1; } +bool tap_probe_vnet_hash_supported_types(int fd, uint32_t *types) +{ + return !ioctl(fd, TUNGETVNETHASHTYPES, types); +} + void tap_fd_set_vnet_hdr_len(int fd, int len) { if (ioctl(fd, TUNSETVNETHDRSZ, &len) == -1) { diff --git a/net/tap-solaris.c b/net/tap-solaris.c index bc76a030e7f9..65234c49a196 100644 --- a/net/tap-solaris.c +++ b/net/tap-solaris.c @@ -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) { } diff --git a/net/tap-stub.c b/net/tap-stub.c index 511ddfc707eb..281bae2615d2 100644 --- a/net/tap-stub.c +++ b/net/tap-stub.c @@ -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) { } diff --git a/net/tap.c b/net/tap.c index e93f5f951057..4a8adcf447eb 100644 --- a/net/tap.c +++ b/net/tap.c @@ -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_automq(NetClientState *nc, uint32_t hash_types) { TAPState *s = DO_UPCAST(TAPState, nc, nc); @@ -357,6 +364,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_automq = tap_set_vnet_automq, .set_vnet_rss = tap_set_vnet_rss, .set_vnet_le = tap_set_vnet_le, -- 2.49.0