From patchwork Thu Mar 22 10:01:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Wang X-Patchwork-Id: 148209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 234A3B6F98 for ; Thu, 22 Mar 2012 21:07:11 +1100 (EST) Received: from localhost ([::1]:49178 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAevA-0007Yx-TW for incoming@patchwork.ozlabs.org; Thu, 22 Mar 2012 06:07:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:48959) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAeut-0007AU-5k for qemu-devel@nongnu.org; Thu, 22 Mar 2012 06:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SAeum-00068y-Ue for qemu-devel@nongnu.org; Thu, 22 Mar 2012 06:06:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SAeum-00068g-Ni for qemu-devel@nongnu.org; Thu, 22 Mar 2012 06:06:40 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q2MA6bVU010569 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 22 Mar 2012 06:06:37 -0400 Received: from amd-6168-8-1.englab.nay.redhat.com (amd-6168-8-1.englab.nay.redhat.com [10.66.104.52]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q2MA6Zb9021702; Thu, 22 Mar 2012 06:06:36 -0400 To: qemu-devel@nongnu.org, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, mst@redhat.com From: Jason Wang Date: Thu, 22 Mar 2012 18:01:59 +0800 Message-ID: <20120322100159.44393.81006.stgit@amd-6168-8-1.englab.nay.redhat.com> In-Reply-To: <20120322100141.44393.14528.stgit@amd-6168-8-1.englab.nay.redhat.com> References: <20120322100141.44393.14528.stgit@amd-6168-8-1.englab.nay.redhat.com> User-Agent: StGit/0.16-1-g60c4 MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/7] e1000: PHY loopback mode support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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];