Patchwork [3/4] e1000: no need auto-negotiation if link was down

login
register
mail settings
Submitter Stefan Hajnoczi
Date Jan. 8, 2013, 10:45 a.m.
Message ID <1357641939-20030-4-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/210333/
State New
Headers show

Comments

Stefan Hajnoczi - Jan. 8, 2013, 10:45 a.m.
From: Amos Kong <akong@redhat.com>

Commit b9d03e352cb6b31a66545763f6a1e20c9abf0c2c added link
auto-negotiation emulation, it would always set link up by
callback function. Problem exists if original link status
was down, link status should not be changed in auto-negotiation.

Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Amos Kong <akong@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/e1000.c | 5 +++++
 1 file changed, 5 insertions(+)

Patch

diff --git a/hw/e1000.c b/hw/e1000.c
index 8fd1654..0f177ff 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -166,6 +166,11 @@  static void
 set_phy_ctrl(E1000State *s, int index, uint16_t val)
 {
     if ((val & MII_CR_AUTO_NEG_EN) && (val & MII_CR_RESTART_AUTO_NEG)) {
+        /* no need auto-negotiation if link was down */
+        if (s->nic->nc.link_down) {
+            s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
+            return;
+        }
         s->nic->nc.link_down = true;
         e1000_link_down(s);
         s->phy_reg[PHY_STATUS] &= ~MII_SR_AUTONEG_COMPLETE;