summaryrefslogtreecommitdiffstats
path: root/hw/e1000.c
diff options
context:
space:
mode:
authorJason Wang <jasowang@redhat.com>2012-03-22 18:01:59 +0800
committerMichael S. Tsirkin <mst@redhat.com>2012-04-25 10:53:48 +0300
commit93e37d769074bebfd04c6704b7a7ae92736876e3 (patch)
tree740a9468943fc9fc559b59525ba3399ce5fa29f6 /hw/e1000.c
parent17fbbb0b3d0b09f07d288991248c81f441bf6941 (diff)
downloadhqemu-93e37d769074bebfd04c6704b7a7ae92736876e3.zip
hqemu-93e37d769074bebfd04c6704b7a7ae92736876e3.tar.gz
e1000: PHY loopback mode support
The missing of loopback mode prevent the running of self diagnosis program in guest. This patch adds this support. After this patch, loopback test of ethtool were passed in guest. Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/e1000.c')
-rw-r--r--hw/e1000.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/hw/e1000.c b/hw/e1000.c
index 4e787bc..4a09e39 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -392,6 +392,16 @@ fcs_len(E1000State *s)
}
static void
+e1000_send_packet(E1000State *s, const uint8_t *buf, int size)
+{
+ if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) {
+ s->nic->nc.info->receive(&s->nic->nc, buf, size);
+ } else {
+ qemu_send_packet(&s->nic->nc, buf, size);
+ }
+}
+
+static void
xmit_seg(E1000State *s)
{
uint16_t len, *sp;
@@ -440,9 +450,9 @@ xmit_seg(E1000State *s)
memmove(tp->vlan, tp->data, 4);
memmove(tp->data, tp->data + 4, 8);
memcpy(tp->data + 8, tp->vlan_header, 4);
- qemu_send_packet(&s->nic->nc, tp->vlan, tp->size + 4);
+ e1000_send_packet(s, tp->vlan, tp->size + 4);
} else
- qemu_send_packet(&s->nic->nc, tp->data, tp->size);
+ e1000_send_packet(s, tp->data, tp->size);
s->mac_reg[TPT]++;
s->mac_reg[GPTC]++;
n = s->mac_reg[TOTL];
OpenPOWER on IntegriCloud