From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuuQc-0006bq-Dc for qemu-devel@nongnu.org; Tue, 19 May 2015 23:12:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuuQb-00045o-Gq for qemu-devel@nongnu.org; Tue, 19 May 2015 23:12:18 -0400 Received: from mail-pd0-x232.google.com ([2607:f8b0:400e:c02::232]:33088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuuQb-00045c-91 for qemu-devel@nongnu.org; Tue, 19 May 2015 23:12:17 -0400 Received: by pdbqa5 with SMTP id qa5so51201788pdb.0 for ; Tue, 19 May 2015 20:12:16 -0700 (PDT) From: sfeldma@gmail.com Date: Tue, 19 May 2015 20:13:17 -0700 Message-Id: <1432091598-62403-4-git-send-email-sfeldma@gmail.com> In-Reply-To: <1432091598-62403-1-git-send-email-sfeldma@gmail.com> References: <1432091598-62403-1-git-send-email-sfeldma@gmail.com> Subject: [Qemu-devel] [PATCH v2 3/4] rocker: bring link up/down on PHY enable/disable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, jiri@resnulli.us, dsahern@gmail.com From: Scott Feldman When the OS driver enables/disables the port, go ahead and set the port's link status to up/down in response to the change. This more closely emulates real hardware when the PHY for the port is brought up/down and the PHY negotiates carrier (link status) with link partner. In the case of qemu, the virtual rocker device can't really do link negotiation with the link partner as that requires signally over a physical medium (the wire), so just pretend the negotiation was successful and bring the link up when the port is enabled. Signed-off-by: Scott Feldman Reviewed-by: Stefan Hajnoczi --- hw/net/rocker/rocker_fp.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/net/rocker/rocker_fp.c b/hw/net/rocker/rocker_fp.c index 393e9e7..29a2b68 100644 --- a/hw/net/rocker/rocker_fp.c +++ b/hw/net/rocker/rocker_fp.c @@ -178,8 +178,19 @@ bool fp_port_enabled(FpPort *port) return port->enabled; } +static void fp_port_set_link(FpPort *port, bool up) +{ + NetClientState *nc = qemu_get_queue(port->nic); + + if (up == nc->link_down) { + nc->link_down = !up; + nc->info->link_status_changed(nc); + } +} + void fp_port_enable(FpPort *port) { + fp_port_set_link(port, true); port->enabled = true; DPRINTF("port %d enabled\n", port->index); } @@ -187,6 +198,7 @@ void fp_port_enable(FpPort *port) void fp_port_disable(FpPort *port) { port->enabled = false; + fp_port_set_link(port, false); DPRINTF("port %d disabled\n", port->index); } -- 1.7.10.4