From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Jason Wang <jasowang@redhat.com>,
Dmitry Fleytman <dmitry.fleytman@gmail.com>,
Sriram Yagnaraman <sriram.yagnaraman@ericsson.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Luigi Rizzo <rizzo@iet.unipi.it>,
Giuseppe Lettieri <g.lettieri@iet.unipi.it>,
Vincenzo Maffione <v.maffione@gmail.com>,
Andrew Melnychenko <andrew@daynix.com>,
Yuri Benditovich <yuri.benditovich@daynix.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Eduardo Habkost <eduardo@habkost.net>,
qemu-devel@nongnu.org
Subject: Re: [PATCH v2 4/4] virtio-net: Remove fallback from ebpf-rss-fds
Date: Wed, 10 Jul 2024 15:16:45 +0100 [thread overview]
Message-ID: <Zo6XzRyoXsp6FUWu@redhat.com> (raw)
In-Reply-To: <20240708-auto-v2-4-f4908b953f05@daynix.com>
On Mon, Jul 08, 2024 at 04:38:09PM +0900, Akihiko Odaki wrote:
> If ebpf-rss-fds is specified but we fail to use, we should not fall
> back to loading eBPF programs by ourselves as such makes the situation
> complicated.
>
> Suggested-by: Daniel P. Berrangé <berrange@redhat.com>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> hw/net/virtio-net.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index e779ba2df428..075c91f037d1 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -1396,15 +1396,9 @@ exit:
>
> static bool virtio_net_load_ebpf(VirtIONet *n)
> {
> - bool ret = false;
> -
> - if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
> - if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) {
> - ret = ebpf_rss_load(&n->ebpf_rss);
> - }
> - }
> -
> - return ret;
> + return virtio_net_attach_ebpf_to_backend(n->nic, -1) &&
> + (n->ebpf_rss_fds ? virtio_net_load_ebpf_fds(n) :
> + ebpf_rss_load(&n->ebpf_rss));
> }
>
> static void virtio_net_unload_ebpf(VirtIONet *n)
The eventual caller has an Error object that needs to be filled with
error details, not warn_report().
IMHO this patch needs to look like this:
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index 9c7e85caea..c7fd52bbe9 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -1314,21 +1314,21 @@ static void virtio_net_disable_rss(VirtIONet *n)
virtio_net_commit_rss_config(n);
}
-static bool virtio_net_load_ebpf_fds(VirtIONet *n)
+static bool virtio_net_load_ebpf_fds(VirtIONet *n, Error **errp)
{
int fds[EBPF_RSS_MAX_FDS] = { [0 ... EBPF_RSS_MAX_FDS - 1] = -1};
int ret = true;
int i = 0;
if (n->nr_ebpf_rss_fds != EBPF_RSS_MAX_FDS) {
- warn_report("Expected %d file descriptors but got %d",
- EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds);
- return false;
- }
+ error_setg(errp, "Expected %d file descriptors but got %d",
+ EBPF_RSS_MAX_FDS, n->nr_ebpf_rss_fds);
+ return false;
+ }
for (i = 0; i < n->nr_ebpf_rss_fds; i++) {
fds[i] = monitor_fd_param(monitor_cur(), n->ebpf_rss_fds[i],
- &error_warn);
+ errp);
if (fds[i] < 0) {
ret = false;
goto exit;
@@ -1347,14 +1347,15 @@ exit:
return ret;
}
-static bool virtio_net_load_ebpf(VirtIONet *n)
+static bool virtio_net_load_ebpf(VirtIONet *n, Error **errp)
{
bool ret = false;
if (virtio_net_attach_ebpf_to_backend(n->nic, -1)) {
- if (!(n->ebpf_rss_fds && virtio_net_load_ebpf_fds(n))) {
+ if (n->ebpf_rss_fds)
+ ret = virtio_net_load_ebpf_fds(n, errp);
+ else
ret = ebpf_rss_load(&n->ebpf_rss);
- }
}
return ret;
@@ -3750,7 +3751,7 @@ static void virtio_net_device_realize(DeviceState *dev, Error **errp)
net_rx_pkt_init(&n->rx_pkt);
if (virtio_has_feature(n->host_features, VIRTIO_NET_F_RSS)) {
- virtio_net_load_ebpf(n);
+ virtio_net_load_ebpf(n, errp);
}
}
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2024-07-10 14:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 7:38 [PATCH v2 0/4] virtio-net: Convert feature properties to OnOffAuto Akihiko Odaki
2024-07-08 7:38 ` [PATCH v2 1/4] qdev-properties: Add DEFINE_PROP_ON_OFF_AUTO_BIT64() Akihiko Odaki
2024-07-08 10:43 ` Michael S. Tsirkin
2024-07-10 14:06 ` Daniel P. Berrangé
2024-07-08 7:38 ` [PATCH v2 2/4] virtio-net: Convert feature properties to OnOffAuto Akihiko Odaki
2024-07-08 7:38 ` [PATCH v2 3/4] virtio-net: Report RSS warning at device realization Akihiko Odaki
2024-07-08 7:38 ` [PATCH v2 4/4] virtio-net: Remove fallback from ebpf-rss-fds Akihiko Odaki
2024-07-10 14:16 ` Daniel P. Berrangé [this message]
2024-07-09 2:52 ` [PATCH v2 0/4] virtio-net: Convert feature properties to OnOffAuto Jason Wang
2024-07-14 5:14 ` Akihiko Odaki
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=Zo6XzRyoXsp6FUWu@redhat.com \
--to=berrange@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=andrew@daynix.com \
--cc=dmitry.fleytman@gmail.com \
--cc=eduardo@habkost.net \
--cc=g.lettieri@iet.unipi.it \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rizzo@iet.unipi.it \
--cc=sriram.yagnaraman@ericsson.com \
--cc=v.maffione@gmail.com \
--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).