qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, aliguori@us.ibm.com,
	stefanha@linux.vnet.ibm.com, mst@redhat.com
Subject: [Qemu-devel] [PATCH 3/7] e1000: PHY loopback mode support
Date: Thu, 22 Mar 2012 18:01:59 +0800	[thread overview]
Message-ID: <20120322100159.44393.81006.stgit@amd-6168-8-1.englab.nay.redhat.com> (raw)
In-Reply-To: <20120322100141.44393.14528.stgit@amd-6168-8-1.englab.nay.redhat.com>

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>
---
 hw/e1000.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/hw/e1000.c b/hw/e1000.c
index dd6a97d..bc26a0c 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -352,6 +352,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;
@@ -400,9 +410,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];

  parent reply	other threads:[~2012-03-22 10:06 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22 10:01 [Qemu-devel] [PATCH 1/7] e1000: introduce bits of PHY control register Jason Wang
2012-03-22 10:01 ` [Qemu-devel] [PATCH 2/7] e1000: conditionally raise irq at the end of MDI cycle Jason Wang
2012-03-22 10:01 ` Jason Wang [this message]
2012-03-22 10:02 ` [Qemu-devel] [PATCH 4/7] e1000: introduce helpers to manipulate link status Jason Wang
2012-03-22 10:02 ` [Qemu-devel] [PATCH 5/7] e1000: introduce bit for debugging PHY emulation Jason Wang
2012-03-22 10:02 ` [Qemu-devel] [PATCH 6/7] e1000: link auto-negotiation emulation Jason Wang
2012-03-22 10:02 ` [Qemu-devel] [PATCH 7/7] e1000: set E1000_ICR_INT_ASSERTED only for 8257x Jason Wang

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=20120322100159.44393.81006.stgit@amd-6168-8-1.englab.nay.redhat.com \
    --to=jasowang@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@linux.vnet.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).