From: Rusty Russell <rusty@rustcorp.com.au>
To: David Miller <davem@davemloft.net>
Cc: pktoss@gmail.com, dcbw@redhat.com, netdev@vger.kernel.org
Subject: Re: [PATCH] Make virtio_net support carrier detection
Date: Sat, 14 Mar 2009 10:49:42 +1030 [thread overview]
Message-ID: <200903141049.43202.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20090313.120100.266753164.davem@davemloft.net>
On Saturday 14 March 2009 05:31:00 David Miller wrote:
> You can set netif_carrier_on() until you are blue in the face,
> but until you hook up the ethtool link indication operation
> NetworkManager won't see it.
Um, dude, you already have that patch in your net-next tree. See below.
This one goes on top.
> I don't understand what all of this hob-knobbing is about,
> Pantelis's patch was perfect, appropriate, and should have
> gone straight in to net-2.6 and probably -stable too.
>
> Is this some kind of control issue Rusty? It's the only
> explanation I can come up with :-))
I don't think it was straightforward at all. Current virtio_net "cards"
don't support carrier detection. We reported that (correctly) to userspace,
like every other driver which doesn't support carrier detect.
So why is virtio_net different? Or should all devices which can't detect
carrier set it to on, so older NetworkManagers work?
This may be obvious to you. It's not to me.
Rusty.
commit 9f4d26d0f3016cf8813977d624751b94465fa317
Author: Mark McLoughlin <markmc@redhat.com>
Date: Mon Jan 19 17:09:49 2009 -0800
virtio_net: add link status handling
Allow the host to inform us that the link is down by adding
a VIRTIO_NET_F_STATUS which indicates that device status is
available in virtio_net config.
This is currently useful for simulating link down conditions
(e.g. using proposed qemu 'set_link' monitor command) but
would also be needed if we were to support device assignment
via virtio.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (added future masking)
Signed-off-by: David S. Miller <davem@davemloft.net>
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 30ae6d9..9b33d6e 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -42,6 +42,7 @@ struct virtnet_info
struct virtqueue *rvq, *svq;
struct net_device *dev;
struct napi_struct napi;
+ unsigned int status;
/* The skb we couldn't send because buffers were full. */
struct sk_buff *last_xmit_skb;
@@ -611,6 +612,7 @@ static struct ethtool_ops virtnet_ethtool_ops = {
.set_tx_csum = virtnet_set_tx_csum,
.set_sg = ethtool_op_set_sg,
.set_tso = ethtool_op_set_tso,
+ .get_link = ethtool_op_get_link,
};
#define MIN_MTU 68
@@ -636,6 +638,41 @@ static const struct net_device_ops virtnet_netdev = {
#endif
};
+static void virtnet_update_status(struct virtnet_info *vi)
+{
+ u16 v;
+
+ if (!virtio_has_feature(vi->vdev, VIRTIO_NET_F_STATUS))
+ return;
+
+ vi->vdev->config->get(vi->vdev,
+ offsetof(struct virtio_net_config, status),
+ &v, sizeof(v));
+
+ /* Ignore unknown (future) status bits */
+ v &= VIRTIO_NET_S_LINK_UP;
+
+ if (vi->status == v)
+ return;
+
+ vi->status = v;
+
+ if (vi->status & VIRTIO_NET_S_LINK_UP) {
+ netif_carrier_on(vi->dev);
+ netif_wake_queue(vi->dev);
+ } else {
+ netif_carrier_off(vi->dev);
+ netif_stop_queue(vi->dev);
+ }
+}
+
+static void virtnet_config_changed(struct virtio_device *vdev)
+{
+ struct virtnet_info *vi = vdev->priv;
+
+ virtnet_update_status(vi);
+}
+
static int virtnet_probe(struct virtio_device *vdev)
{
int err;
@@ -738,6 +775,9 @@ static int virtnet_probe(struct virtio_device *vdev)
goto unregister;
}
+ vi->status = VIRTIO_NET_S_LINK_UP;
+ virtnet_update_status(vi);
+
pr_debug("virtnet: registered device %s\n", dev->name);
return 0;
@@ -793,7 +833,7 @@ static unsigned int features[] = {
VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6,
VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6,
VIRTIO_NET_F_GUEST_ECN, /* We don't yet handle UFO input. */
- VIRTIO_NET_F_MRG_RXBUF,
+ VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS,
VIRTIO_F_NOTIFY_ON_EMPTY,
};
@@ -805,6 +845,7 @@ static struct virtio_driver virtio_net = {
.id_table = id_table,
.probe = virtnet_probe,
.remove = __devexit_p(virtnet_remove),
+ .config_changed = virtnet_config_changed,
};
static int __init init(void)
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index 5cdd0aa..f76bd4a 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -21,11 +21,16 @@
#define VIRTIO_NET_F_HOST_ECN 13 /* Host can handle TSO[6] w/ ECN in. */
#define VIRTIO_NET_F_HOST_UFO 14 /* Host can handle UFO in. */
#define VIRTIO_NET_F_MRG_RXBUF 15 /* Host can merge receive buffers. */
+#define VIRTIO_NET_F_STATUS 16 /* virtio_net_config.status available */
+
+#define VIRTIO_NET_S_LINK_UP 1 /* Link is up */
struct virtio_net_config
{
/* The config defining mac address (if VIRTIO_NET_F_MAC) */
__u8 mac[6];
+ /* See VIRTIO_NET_F_STATUS and VIRTIO_NET_S_* above */
+ __u16 status;
} __attribute__((packed));
/* This is the first element of the scatter-gather list. If you don't
next prev parent reply other threads:[~2009-03-14 0:19 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1236772642-12705-1-git-send-email-pktoss@gmail.com>
2009-03-12 7:29 ` [PATCH] Make virtio_net support carrier detection Rusty Russell
2009-03-12 7:44 ` Pantelis Koukousoulas
2009-03-12 9:16 ` Rusty Russell
2009-03-12 10:23 ` Pantelis Koukousoulas
2009-03-12 11:05 ` Pantelis Koukousoulas
2009-03-12 11:43 ` Dan Williams
2009-03-12 12:47 ` Pantelis Koukousoulas
2009-03-12 12:52 ` David Miller
2009-03-12 12:58 ` Pantelis Koukousoulas
2009-03-12 13:03 ` David Miller
2009-03-12 13:10 ` Pantelis Koukousoulas
2009-03-12 13:41 ` Dan Williams
2009-03-12 13:55 ` Dan Williams
2009-03-12 21:39 ` Rusty Russell
2009-03-12 23:47 ` Rusty Russell
2009-03-12 23:55 ` Stephen Hemminger
2009-03-13 5:04 ` Pantelis Koukousoulas
2009-03-13 19:01 ` David Miller
2009-03-14 0:19 ` Rusty Russell [this message]
2009-03-14 10:40 ` Pantelis Koukousoulas
2009-03-14 11:33 ` Pantelis Koukousoulas
2009-03-15 22:39 ` Rusty Russell
2009-03-16 2:05 ` Pantelis Koukousoulas
2009-03-16 2:58 ` David Miller
2009-03-16 3:13 ` Rusty Russell
2009-03-16 3:15 ` David Miller
2009-03-14 0:23 Rusty Russell
2009-03-19 1:40 ` David Miller
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=200903141049.43202.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=davem@davemloft.net \
--cc=dcbw@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pktoss@gmail.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.