From 2c0331f4f7d241995452b99afaf0aab00493334a Mon Sep 17 00:00:00 2001 From: Michael Contreras Date: Wed, 5 Dec 2012 13:31:30 -0500 Subject: e1000: Discard oversized packets based on SBP|LPE Discard packets longer than 16384 when !SBP to match the hardware behavior. Signed-off-by: Michael Contreras Signed-off-by: Stefan Hajnoczi --- hw/e1000.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'hw') diff --git a/hw/e1000.c b/hw/e1000.c index 92fb00a89f..8fd165456a 100644 --- a/hw/e1000.c +++ b/hw/e1000.c @@ -61,6 +61,8 @@ static int debugflags = DBGBIT(TXERR) | DBGBIT(GENERAL); /* this is the size past which hardware will drop packets when setting LPE=0 */ #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 +/* this is the size past which hardware will drop packets when setting LPE=1 */ +#define MAXIMUM_ETHERNET_LPE_SIZE 16384 /* * HW models: @@ -809,8 +811,9 @@ e1000_receive(NetClientState *nc, const uint8_t *buf, size_t size) } /* Discard oversized packets if !LPE and !SBP. */ - if (size > MAXIMUM_ETHERNET_VLAN_SIZE - && !(s->mac_reg[RCTL] & E1000_RCTL_LPE) + if ((size > MAXIMUM_ETHERNET_LPE_SIZE || + (size > MAXIMUM_ETHERNET_VLAN_SIZE + && !(s->mac_reg[RCTL] & E1000_RCTL_LPE))) && !(s->mac_reg[RCTL] & E1000_RCTL_SBP)) { return size; } -- cgit v1.2.3 From 84dd2120247a7d25ff1bb337de21c0e76816ad2d Mon Sep 17 00:00:00 2001 From: Amos Kong Date: Fri, 28 Dec 2012 17:29:10 +0800 Subject: e1000: no need auto-negotiation if link was down 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 Signed-off-by: Amos Kong Signed-off-by: Stefan Hajnoczi --- hw/e1000.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'hw') diff --git a/hw/e1000.c b/hw/e1000.c index 8fd165456a..0f177ff844 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; -- cgit v1.2.3 From 83f58e570f21c3e7227e7fbef1fc0e18b5ed7ea9 Mon Sep 17 00:00:00 2001 From: Amos Kong Date: Fri, 28 Dec 2012 17:29:11 +0800 Subject: rtl8139: preserve link state across device reset A device reset does not affect the link state, only set_link does. Signed-off-by: Amos Kong Signed-off-by: Stefan Hajnoczi --- hw/rtl8139.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'hw') diff --git a/hw/rtl8139.c b/hw/rtl8139.c index c59ec6b6df..3e080621f6 100644 --- a/hw/rtl8139.c +++ b/hw/rtl8139.c @@ -1258,7 +1258,8 @@ static void rtl8139_reset(DeviceState *d) s->BasicModeStatus = 0x7809; //s->BasicModeStatus |= 0x0040; /* UTP medium */ s->BasicModeStatus |= 0x0020; /* autonegotiation completed */ - s->BasicModeStatus |= 0x0004; /* link is up */ + /* preserve link state */ + s->BasicModeStatus |= s->nic->nc.link_down ? 0 : 0x04; s->NWayAdvert = 0x05e1; /* all modes, full duplex */ s->NWayLPAR = 0x05e1; /* all modes, full duplex */ -- cgit v1.2.3