diff mbox

[v1] e1000: initial link negotiation on mac osx

Message ID 20131107180440.GC13775@HEDWIG.INI.CMU.EDU
State New
Headers show

Commit Message

Gabriel L. Somlo Nov. 7, 2013, 6:04 p.m. UTC
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(+)

Comments

Paolo Bonzini Nov. 7, 2013, 7:28 p.m. UTC | #1
Il 07/11/2013 19:04, Gabriel L. Somlo ha scritto:
> 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;
> 

Is there any way to work around this in the guest?  Such as using a UEFI
driver for e1000 or something like that.

Paolo
jacek burghardt Nov. 7, 2013, 7:44 p.m. UTC | #2
I know there are patches for seabios
diff mbox

Patch

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;