From: Akihiko Odaki <akihiko.odaki@daynix.com>
To: qemu-devel@nongnu.org,
Yuri Benditovich <yuri.benditovich@daynix.com>,
Andrew Melnychenko <andrew@daynix.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Paolo Abeni <pabeni@redhat.com>,
devel@daynix.com
Cc: Akihiko Odaki <akihiko.odaki@daynix.com>
Subject: [PATCH RFC v5 4/5] tap: Report virtio-net hashing support on Linux
Date: Fri, 30 May 2025 13:39:12 +0900 [thread overview]
Message-ID: <20250530-hash-v5-4-343d7d7a8200@daynix.com> (raw)
In-Reply-To: <20250530-hash-v5-0-343d7d7a8200@daynix.com>
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 | 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
next prev parent reply other threads:[~2025-05-30 4:40 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-30 4:39 [PATCH RFC v5 0/5] virtio-net: Offload hashing without eBPF Akihiko Odaki
2025-05-30 4:39 ` [PATCH RFC v5 1/5] net: Allow configuring virtio hashing Akihiko Odaki
2025-05-30 4:39 ` [PATCH RFC v5 2/5] virtio-net: Offload hashing to peer Akihiko Odaki
2025-05-30 4:39 ` [PATCH RFC v5 3/5] virtio-net: Offload hashing without vhost Akihiko Odaki
2025-05-30 4:39 ` Akihiko Odaki [this message]
2025-05-30 4:39 ` [PATCH RFC v5 5/5] docs/devel/ebpf_rss.rst: Update for peer RSS Akihiko Odaki
2025-06-03 6:35 ` [PATCH RFC v5 0/5] virtio-net: Offload hashing without eBPF Lei Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250530-hash-v5-4-343d7d7a8200@daynix.com \
--to=akihiko.odaki@daynix.com \
--cc=andrew@daynix.com \
--cc=devel@daynix.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pabeni@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).