qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: sfeldma@gmail.com
To: qemu-devel@nongnu.org
Cc: stefanha@gmail.com, jiri@resnulli.us, dsahern@gmail.com
Subject: [Qemu-devel] [PATCH v3 3/4] rocker: bring link up/down on PHY enable/disable
Date: Fri, 29 May 2015 07:01:48 -0700	[thread overview]
Message-ID: <1432908109-31559-4-git-send-email-sfeldma@gmail.com> (raw)
In-Reply-To: <1432908109-31559-1-git-send-email-sfeldma@gmail.com>

From: Scott Feldman <sfeldma@gmail.com>

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 <sfeldma@gmail.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 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

  parent reply	other threads:[~2015-05-29 14:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-29 14:01 [Qemu-devel] [PATCH v3 0/4] rocker device updates sfeldma
2015-05-29 14:01 ` [Qemu-devel] [PATCH v3 1/4] rocker: Add support for phys name sfeldma
2015-06-02 16:27   ` Eric Blake
2015-05-29 14:01 ` [Qemu-devel] [PATCH v3 2/4] rocker: update tests using hw-derived interface names sfeldma
2015-05-29 14:01 ` sfeldma [this message]
2015-05-29 14:01 ` [Qemu-devel] [PATCH v3 4/4] qmp/hmp: add rocker device support sfeldma
2015-06-02 15:07   ` Stefan Hajnoczi
2015-06-02 16:32   ` Eric Blake
2015-06-02 15:09 ` [Qemu-devel] [PATCH v3 0/4] rocker device updates Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432908109-31559-4-git-send-email-sfeldma@gmail.com \
    --to=sfeldma@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).