pcnet: Add link state support
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 7 Oct 2011 10:27:25 +0000 (12:27 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Tue, 1 Nov 2011 21:52:09 +0000 (16:52 -0500)
Update lnkst on link state changes so that guests can obtain this
information via reading back the LED output pin. Works for Linux but
not for guests that depend on the missing PHY.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/lance.c
hw/pcnet-pci.c
hw/pcnet.c
hw/pcnet.h

index d83e7f57a9161741165043491d43c2f4ef8cb8a3..93d5fda35b7231b41fec2e56ecfc41360430ca5a 100644 (file)
@@ -97,6 +97,7 @@ static NetClientInfo net_lance_info = {
     .size = sizeof(NICState),
     .can_receive = pcnet_can_receive,
     .receive = pcnet_receive,
+    .link_status_changed = pcnet_set_link_status,
     .cleanup = lance_cleanup,
 };
 
index ea5dfdef769a2dcd07e59b3239f76a142c0c1349..4e164da3ac74da6b43436def2d6b91f2ac8641d6 100644 (file)
@@ -288,6 +288,7 @@ static NetClientInfo net_pci_pcnet_info = {
     .size = sizeof(NICState),
     .can_receive = pcnet_can_receive,
     .receive = pcnet_receive,
+    .link_status_changed = pcnet_set_link_status,
     .cleanup = pci_pcnet_cleanup,
 };
 
index add3ec2559ce3b8a01686f4d119d369aee86f36e..cba253ba7b80e21057ceaaab42ac5a71779794d1 100644 (file)
@@ -1197,6 +1197,13 @@ ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_)
     return size_;
 }
 
+void pcnet_set_link_status(VLANClientState *nc)
+{
+    PCNetState *d = DO_UPCAST(NICState, nc, nc)->opaque;
+
+    d->lnkst = nc->link_down ? 0 : 0x40;
+}
+
 static void pcnet_transmit(PCNetState *s)
 {
     target_phys_addr_t xmit_cxda = 0;
index 52cc52e9401fc9dac3385b0839f9527aec07765c..edc81c90ac928c52fd40bebbfe8ec721d861728a 100644 (file)
@@ -58,6 +58,7 @@ uint32_t pcnet_ioport_readl(void *opaque, uint32_t addr);
 uint32_t pcnet_bcr_readw(PCNetState *s, uint32_t rap);
 int pcnet_can_receive(VLANClientState *nc);
 ssize_t pcnet_receive(VLANClientState *nc, const uint8_t *buf, size_t size_);
+void pcnet_set_link_status(VLANClientState *nc);
 void pcnet_common_cleanup(PCNetState *d);
 int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info);
 extern const VMStateDescription vmstate_pcnet;