From: "Michael S. Tsirkin" <mst@redhat.com>
To: Vincent Jardin <vincent.jardin@ekinops.com>
Cc: qemu-devel@nongnu.org, jasowang@redhat.com
Subject: Re: [RFC] virtio: enforce link up
Date: Sat, 14 Oct 2023 12:37:05 -0400 [thread overview]
Message-ID: <20231014123635-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20231014162234.153808-1-vincent.jardin@ekinops.com>
On Sat, Oct 14, 2023 at 06:22:34PM +0200, Vincent Jardin wrote:
> Using interface's settings, let's enforce an always on link up.
>
> Signed-off-by: Vincent Jardin <vincent.jardin@ekinops.com>
What is going on here? Just don't set it down.
> ---
> hw/net/virtio-net.c | 8 ++++++++
> include/hw/virtio/virtio-net.h | 2 ++
> 2 files changed, 10 insertions(+)
>
> diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
> index 29e33ea5ed..e731b4fdea 100644
> --- a/hw/net/virtio-net.c
> +++ b/hw/net/virtio-net.c
> @@ -78,6 +78,9 @@
> tso/gso/gro 'off'. */
> #define VIRTIO_NET_RSC_DEFAULT_INTERVAL 300000
>
> +/* force always link up */
> +#define VIRTIO_NET_LINK_UP false
> +
> #define VIRTIO_NET_RSS_SUPPORTED_HASHES (VIRTIO_NET_RSS_HASH_TYPE_IPv4 | \
> VIRTIO_NET_RSS_HASH_TYPE_TCPv4 | \
> VIRTIO_NET_RSS_HASH_TYPE_UDPv4 | \
> @@ -447,6 +450,9 @@ static void virtio_net_set_link_status(NetClientState *nc)
> else
> n->status |= VIRTIO_NET_S_LINK_UP;
>
> + if (n->net_conf.link_up)
> + n->status |= VIRTIO_NET_S_LINK_UP;
> +
> if (n->status != old_status)
> virtio_notify_config(vdev);
>
> @@ -3947,6 +3953,8 @@ static Property virtio_net_properties[] = {
> VIRTIO_NET_F_GUEST_USO6, true),
> DEFINE_PROP_BIT64("host_uso", VirtIONet, host_features,
> VIRTIO_NET_F_HOST_USO, true),
> + DEFINE_PROP_BOOL("link_up", VirtIONet, net_conf.link_up,
> + VIRTIO_NET_LINK_UP),
> DEFINE_PROP_END_OF_LIST(),
> };
>
> diff --git a/include/hw/virtio/virtio-net.h b/include/hw/virtio/virtio-net.h
> index 55977f01f0..385bebab34 100644
> --- a/include/hw/virtio/virtio-net.h
> +++ b/include/hw/virtio/virtio-net.h
> @@ -56,6 +56,7 @@ typedef struct virtio_net_conf
> char *duplex_str;
> uint8_t duplex;
> char *primary_id_str;
> + bool link_up; /* if set enforce link up, never down */
> } virtio_net_conf;
>
> /* Coalesced packets type & status */
> @@ -180,6 +181,7 @@ struct VirtIONet {
> size_t guest_hdr_len;
> uint64_t host_features;
> uint32_t rsc_timeout;
> + uint32_t link_up; /* if set enforce link up, never down */
> uint8_t rsc4_enabled;
> uint8_t rsc6_enabled;
> uint8_t has_ufo;
> --
> 2.34.1
next prev parent reply other threads:[~2023-10-14 16:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-14 16:22 [RFC] virtio: enforce link up Vincent Jardin
2023-10-14 16:37 ` Michael S. Tsirkin [this message]
2023-10-14 21:06 ` Vincent Jardin
2023-10-15 8:42 ` Michael S. Tsirkin
2023-10-15 15:53 ` Vincent Jardin
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=20231014123635-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vincent.jardin@ekinops.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.