qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Gabriel L. Somlo" <gsomlo@gmail.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, jaceksburghardt@gmail.com, stefanha@gmail.com
Subject: [Qemu-devel] [PATCH v1] e1000: initial link negotiation on mac osx
Date: Thu, 7 Nov 2013 13:04:40 -0500	[thread overview]
Message-ID: <20131107180440.GC13775@HEDWIG.INI.CMU.EDU> (raw)
In-Reply-To: <20131031150651.GI9423@HEDWIG.INI.CMU.EDU>

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 <somlo@cmu.edu>
---

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;
-- 
1.8.1.4

  parent reply	other threads:[~2013-11-07 18:04 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-25 13:53 [Qemu-devel] e1000 patch for osx jacek burghardt
2013-10-25 14:21 ` Paolo Bonzini
2013-10-25 14:27   ` jacek burghardt
2013-10-30  9:41     ` Stefan Hajnoczi
2013-10-30 13:26       ` jacek burghardt
2013-10-30 13:35         ` Andreas Färber
2013-10-30 23:54     ` jacek burghardt
2013-10-31  0:00       ` Paolo Bonzini
2013-10-31  0:21         ` jacek burghardt
2013-10-31  0:24           ` jacek burghardt
2013-10-31  0:27           ` Paolo Bonzini
2013-10-31  0:31             ` jacek burghardt
2013-10-31  0:51               ` jacek burghardt
2013-10-31 15:06                 ` Gabriel L. Somlo
2013-10-31 21:38                   ` jacek burghardt
2013-11-07 18:04                   ` Gabriel L. Somlo [this message]
2013-11-07 19:28                     ` [Qemu-devel] [PATCH v1] e1000: initial link negotiation on mac osx Paolo Bonzini
2013-11-07 19:44                       ` jacek burghardt
2013-11-07 20:28                       ` [Qemu-devel] [PATCH v2] " Gabriel L. Somlo
2013-11-07 23:12                         ` Alexander Graf
2013-11-08 13:39                           ` Stefan Hajnoczi
2013-11-08 15:52                             ` Gabriel L. Somlo
2013-11-11  9:48                               ` Stefan Hajnoczi
2013-10-30 16:52 ` [Qemu-devel] e1000 patch for osx Paolo Bonzini
2013-10-30 17:29   ` Peter Maydell
2013-10-30 17:50     ` jacek burghardt
2013-10-30 18:00     ` Paolo Bonzini

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=20131107180440.GC13775@HEDWIG.INI.CMU.EDU \
    --to=gsomlo@gmail.com \
    --cc=jaceksburghardt@gmail.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.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).