From patchwork Thu Nov 7 18:04:40 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gabriel L. Somlo" X-Patchwork-Id: 289454 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DBF732C008E for ; Fri, 8 Nov 2013 05:05:13 +1100 (EST) Received: from localhost ([::1]:41523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeTx9-0002GK-Ad for incoming@patchwork.ozlabs.org; Thu, 07 Nov 2013 13:05:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeTwo-0002FE-Kw for qemu-devel@nongnu.org; Thu, 07 Nov 2013 13:04:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VeTwj-0003QX-2n for qemu-devel@nongnu.org; Thu, 07 Nov 2013 13:04:50 -0500 Received: from mail-qc0-x22f.google.com ([2607:f8b0:400d:c01::22f]:51877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VeTwi-0003QK-UD for qemu-devel@nongnu.org; Thu, 07 Nov 2013 13:04:45 -0500 Received: by mail-qc0-f175.google.com with SMTP id e16so729025qcx.6 for ; Thu, 07 Nov 2013 10:04:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:in-reply-to:user-agent; bh=4euzk7/U3bA4CmQ42h6nSMYIrXr7Sqjph5BImTBXFrA=; b=MigeZe9FD/I7JQUV0vlX2yqj7g9mTM3zbp1KcCee3M+uiVeP4xrERe5ZQEB3NHqqFT qa7DqHme4rlMiToEbdSn2lRnRSg3PxUuh/onRufDoNoYb988L3fhbKc8Yh+KzsoaVQri TWTlw3l+reIPhNQxHYnULWbaVDTwQRL4OrNBVdbnojfG35381m8dQ2K2KAQRsCxBBktT OUPQ98LtMokafL/NU9XAe7V+3hLcUiXg8s1oeDc359hVaXEpuCsahgJwurdtETKqy6lF b9eMNDSsHDV9/rupIXNo/abhgSOA9Rml21Mv06ACjWsTupUkY3+EQActkY5i3dN3Pjap odRw== X-Received: by 10.49.72.3 with SMTP id z3mr15298958qeu.23.1383847483673; Thu, 07 Nov 2013 10:04:43 -0800 (PST) Received: from HEDWIG.INI.CMU.EDU (HEDWIG.INI.CMU.EDU. [128.2.16.5]) by mx.google.com with ESMTPSA id a5sm12413290qae.2.2013.11.07.10.04.42 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 Nov 2013 10:04:43 -0800 (PST) Date: Thu, 7 Nov 2013 13:04:40 -0500 From: "Gabriel L. Somlo" To: qemu-devel@nongnu.org Message-ID: <20131107180440.GC13775@HEDWIG.INI.CMU.EDU> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20131031150651.GI9423@HEDWIG.INI.CMU.EDU> User-Agent: Mutt/1.5.21 (2010-09-15) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c01::22f Cc: pbonzini@redhat.com, jaceksburghardt@gmail.com, stefanha@gmail.com Subject: [Qemu-devel] [PATCH v1] e1000: initial link negotiation on mac osx 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 Some guest operating systems' drivers (particularly Mac OS X) expect the link state to be pre-initialized by an earlier component such as a proprietary BIOS. This patch injects an additional LSC event upon PHY reset, allowing the OS X driver to successfully complete initial link negotiation. This is a follow-up to commit 372254c6e5c078fb13b236bb648d2b9b2b0c70f1, which works around the OS X driver's failure to properly set up the MAC address. Signed-off-by: Gabriel Somlo --- I studied the Intel 8254xxx manual and the various earlier suggestions, and came up with the following, which both works (at least for me, using SnowLeopard) and also appears to make sense from a "code flow" point of view. Please let me know what you all think. Thanks, Gabriel hw/net/e1000.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index ec8ecd7..2f2fc3a 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -186,6 +186,9 @@ e1000_link_up(E1000State *s) s->phy_reg[PHY_STATUS] |= MII_SR_LINK_STATUS; } +/* Forward decl. for use in set_phy_ctrl() (OS X link nego. workaround) */ +static void set_ics(E1000State *s, int index, uint32_t val); + static void set_phy_ctrl(E1000State *s, int index, uint16_t val) { @@ -197,6 +200,15 @@ set_phy_ctrl(E1000State *s, int index, uint16_t val) if (!(s->compat_flags & E1000_FLAG_AUTONEG)) { return; } + /* + * The Mac OS X driver expects a pre-initialized network card; injecting + * an extra LSC event here allows initial link negotiation to succeed in + * the absence of the Apple EFI BIOS. + */ + if ((val & MII_CR_RESET)) { + set_ics(s, 0, E1000_ICR_LSC); + return; + } if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) { e1000_link_down(s); s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;