[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 11/23] e1000: factor out checking for auto-negotiatio
From: |
Michael S. Tsirkin |
Subject: |
[Qemu-devel] [PULL 11/23] e1000: factor out checking for auto-negotiation availability |
Date: |
Mon, 23 Jun 2014 18:53:43 +0300 |
From: "Gabriel L. Somlo" <address@hidden>
Also fix minor indentation issues in the surrounding code.
Suggested-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Gabriel Somlo <address@hidden>
Reviewed-by: Michael S. Tsirkin <address@hidden>
Signed-off-by: Michael S. Tsirkin <address@hidden>
---
hw/net/e1000.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index 8ee5225..0fc29a0 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -848,6 +848,14 @@ receive_filter(E1000State *s, const uint8_t *buf, int size)
return 0;
}
+static bool
+have_autoneg(E1000State *s)
+{
+ return (s->compat_flags & E1000_FLAG_AUTONEG) &&
+ (s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN) &&
+ (s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG);
+}
+
static void
e1000_set_link_status(NetClientState *nc)
{
@@ -857,9 +865,7 @@ e1000_set_link_status(NetClientState *nc)
if (nc->link_down) {
e1000_link_down(s);
} else {
- if (s->compat_flags & E1000_FLAG_AUTONEG &&
- s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
- s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG &&
+ if (have_autoneg(s) &&
!(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) {
/* emulate auto-negotiation if supported */
timer_mod(s->autoneg_timer,
@@ -1297,11 +1303,8 @@ static void e1000_pre_save(void *opaque)
* complete auto-negotiation immediately. This allows us to look
* at MII_SR_AUTONEG_COMPLETE to infer link status on load.
*/
- if (nc->link_down &&
- s->compat_flags & E1000_FLAG_AUTONEG &&
- s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
- s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG) {
- s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
+ if (nc->link_down && have_autoneg(s)) {
+ s->phy_reg[PHY_STATUS] |= MII_SR_AUTONEG_COMPLETE;
}
}
@@ -1323,12 +1326,11 @@ static int e1000_post_load(void *opaque, int version_id)
* Alternatively, restart link negotiation if it was in progress. */
nc->link_down = (s->mac_reg[STATUS] & E1000_STATUS_LU) == 0;
- if (s->compat_flags & E1000_FLAG_AUTONEG &&
- s->phy_reg[PHY_CTRL] & MII_CR_AUTO_NEG_EN &&
- s->phy_reg[PHY_CTRL] & MII_CR_RESTART_AUTO_NEG &&
+ if (have_autoneg(s) &&
!(s->phy_reg[PHY_STATUS] & MII_SR_AUTONEG_COMPLETE)) {
nc->link_down = false;
- timer_mod(s->autoneg_timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
500);
+ timer_mod(s->autoneg_timer,
+ qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + 500);
}
return 0;
--
MST
- [Qemu-devel] [PULL 01/23] vhost: block migration if backend does not log memory, (continued)
- [Qemu-devel] [PULL 01/23] vhost: block migration if backend does not log memory, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 02/23] vhost: fix resource leak in error handling, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 03/23] qapi/hmp: use 'backend' instead of 'device' with memory backend, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 04/23] libqemustub: add more stubs for qemu-char, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 05/23] qtest: fix qtest for vhost-user, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 06/23] qtest: fix vhost-user-test unbalanced mutex locks, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 08/23] e1000: improve auto-negotiation reporting via mii-tool, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 07/23] e1000: emulate auto-negotiation during external link status change, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 09/23] e1000: signal guest on successful link auto-negotiation, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 10/23] e1000: move e1000_autoneg_timer() to after set_ics(), Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 11/23] e1000: factor out checking for auto-negotiation availability,
Michael S. Tsirkin <=
- [Qemu-devel] [PULL 13/23] qemu-char: fix qemu_chr_fe_get_msgfd(), Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 12/23] qapi/string-output-visitor: fix human output, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 14/23] qemu-char: avoid leaking unused fds in tcp_get_msgfds(), Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 15/23] virtio-pci: Report an error when msix vectors init fails, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 16/23] q35: Use PC_Q35_COMPAT_1_4 on pc-q35-1.4 compat_props, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 17/23] hw/pcie: correct debug message, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 18/23] hw/pcie: implement power controller functionality, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 19/23] hw/pcie: better hotplug/hotunplug support, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 20/23] pcie: coding style tweak, Michael S. Tsirkin, 2014/06/23
- [Qemu-devel] [PULL 22/23] pc & q35: Add new machine opt max-ram-below-4g, Michael S. Tsirkin, 2014/06/23