[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] virtio: enforce link up
|
From: |
Michael S. Tsirkin |
|
Subject: |
Re: [RFC] virtio: enforce link up |
|
Date: |
Sat, 14 Oct 2023 12:37:05 -0400 |
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