qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v4 16/16] hub: add the support for hub own flow control
@ 2012-05-25 10:52 zwu.kernel
  2012-05-25 11:05 ` Paolo Bonzini
  2012-05-25 12:13 ` Stefan Hajnoczi
  0 siblings, 2 replies; 6+ messages in thread
From: zwu.kernel @ 2012-05-25 10:52 UTC (permalink / raw)
  To: qemu-devel; +Cc: pbonzini, wuzhy, stefanha, kvm, jan.kiszka

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

Only when all other hub port's *peer* .can_receive() all return 1, the source hub port .can_receive() return 1.

Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
---
 net/hub.c |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/net/hub.c b/net/hub.c
index 357ca87..478cce1 100644
--- a/net/hub.c
+++ b/net/hub.c
@@ -15,6 +15,7 @@
 #include "monitor.h"
 #include "net.h"
 #include "hub.h"
+#include "iov.h"
 
 /*
  * A hub broadcasts incoming packets to all its ports except the source port.
@@ -59,16 +60,16 @@ static ssize_t net_hub_receive_iov(NetHub *hub, NetHubPort *source_port,
                                    const struct iovec *iov, int iovcnt)
 {
     NetHubPort *port;
-    ssize_t ret = 0;
+    ssize_t len = iov_size(iov, iovcnt);
 
     QLIST_FOREACH(port, &hub->ports, next) {
         if (port == source_port) {
             continue;
         }
 
-        ret = qemu_sendv_packet(&port->nc, iov, iovcnt);
+        qemu_sendv_packet(&port->nc, iov, iovcnt);
     }
-    return ret;
+    return len;
 }
 
 static NetHub *net_hub_new(unsigned int id)
@@ -85,6 +86,25 @@ static NetHub *net_hub_new(unsigned int id)
     return hub;
 }
 
+static int net_hub_port_can_receive(NetClientState *nc)
+{
+    NetHubPort *port;
+    NetHubPort *src_port = DO_UPCAST(NetHubPort, nc, nc);
+    NetHub *hub = src_port->hub;
+
+    QLIST_FOREACH(port, &hub->ports, next) {
+        if (port == src_port) {
+            continue;
+        }
+
+        if (!qemu_can_send_packet(&port->nc)) {
+            return 0;
+        }
+    }
+
+    return 1;
+}
+
 static ssize_t net_hub_port_receive(NetClientState *nc,
                                     const uint8_t *buf, size_t len)
 {
@@ -111,6 +131,7 @@ static void net_hub_port_cleanup(NetClientState *nc)
 static NetClientInfo net_hub_port_info = {
     .type = NET_CLIENT_TYPE_HUB,
     .size = sizeof(NetHubPort),
+    .can_receive = net_hub_port_can_receive,
     .receive = net_hub_port_receive,
     .receive_iov = net_hub_port_receive_iov,
     .cleanup = net_hub_port_cleanup,
-- 
1.7.6

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH v4 00/16] hub-based networking patches
@ 2012-06-04  5:29 zwu.kernel
  2012-06-04  5:29 ` [Qemu-devel] [PATCH v4 16/16] hub: add the support for hub own flow control zwu.kernel
  0 siblings, 1 reply; 6+ messages in thread
From: zwu.kernel @ 2012-06-04  5:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: aliguori, stefanha, jan.kiszka, Zhi Yong Wu, luowenj, pbonzini

From: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>

All comments from other guys were addressed.

The following changes since commit a854972f8cdec0148087789d62777d8f7176933d:

 Update version to open the 1.2 development branch (Fri Jun 1 16:56:16 2012 +0800)

are available in the git repository at:

 git@github.com:wuzhy/qemu.git for-anthony

Changelog from v3:
 1.) refactor hub own flow control [paolo]
 2.) refactor the output for monitor command "info network" [jan kiszka]

v3:
 1.) add the support for hub own flow control [paolo]
 2.) make the monitor output more reasonable hub info [jan kiszka]

v2:
 1.) cleanup some obsolete vlan info
 2.) cleanup deliver/deliver_iov func pointers [paolo]
 3.) support more flexible flow control [paolo]

Stefan Hajnoczi (12):
  net: Add a hub net client
  net: Use hubs for the vlan feature
  net: Look up 'vlan' net clients using hubs
  hub: Check that hubs are configured correctly
  net: Drop vlan argument to qemu_new_net_client()
  net: Remove vlan qdev property
  net: Remove vlan code from net.c
  net: Remove VLANState
  net: Rename non_vlan_clients to net_clients
  net: Rename VLANClientState to NetClientState
  net: Rename vc local variables to nc
  net: Rename qemu_del_vlan_client() to qemu_del_net_client()

Zhi Yong Wu (4):
  net: Make "info network" output more readable info
  net: cleanup deliver/deliver_iov func pointers
  net: determine if packets can be sent before net queue deliver
    packets
  hub: add the support for hub own flow control

 Makefile.objs           |    2 +-
 hw/cadence_gem.c        |    8 +-
 hw/dp8393x.c            |    6 +-
 hw/e1000.c              |   10 +-
 hw/eepro100.c           |    8 +-
 hw/etraxfs_eth.c        |    8 +-
 hw/lan9118.c            |    8 +-
 hw/lance.c              |    2 +-
 hw/mcf_fec.c            |    6 +-
 hw/milkymist-minimac2.c |    6 +-
 hw/mipsnet.c            |    6 +-
 hw/musicpal.c           |    6 +-
 hw/ne2000-isa.c         |    2 +-
 hw/ne2000.c             |    8 +-
 hw/ne2000.h             |    4 +-
 hw/opencores_eth.c      |    8 +-
 hw/pcnet-pci.c          |    4 +-
 hw/pcnet.c              |    6 +-
 hw/pcnet.h              |    6 +-
 hw/qdev-properties.c    |   78 +------
 hw/qdev.c               |    2 -
 hw/qdev.h               |    8 +-
 hw/rtl8139.c            |   10 +-
 hw/smc91c111.c          |    6 +-
 hw/spapr_llan.c         |    4 +-
 hw/stellaris_enet.c     |    6 +-
 hw/usb/dev-network.c    |    8 +-
 hw/vhost_net.c          |   24 +-
 hw/vhost_net.h          |    2 +-
 hw/virtio-net.c         |   12 +-
 hw/xen_nic.c            |    7 +-
 hw/xgmac.c              |    6 +-
 hw/xilinx_axienet.c     |    6 +-
 hw/xilinx_ethlite.c     |    6 +-
 net.c                   |  605 ++++++++++++++---------------------------------
 net.h                   |   86 ++++----
 net/dump.c              |   28 ++-
 net/dump.h              |    2 +-
 net/hub.c               |  310 ++++++++++++++++++++++++
 net/hub.h               |   28 +++
 net/queue.c             |   37 ++--
 net/queue.h             |   25 +--
 net/slirp.c             |   32 +--
 net/slirp.h             |    2 +-
 net/socket.c            |   66 +++---
 net/socket.h            |    2 +-
 net/tap-win32.c         |   27 +-
 net/tap.c               |   45 ++--
 net/tap.h               |   21 +-
 net/vde.c               |   17 +-
 net/vde.h               |    3 +-
 qemu-common.h           |    3 +-
 slirp/if.c              |    5 -
 slirp/libslirp.h        |    1 -
 54 files changed, 818 insertions(+), 826 deletions(-)
 create mode 100644 net/hub.c
 create mode 100644 net/hub.h

-- 
1.7.6

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-04  5:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-25 10:52 [Qemu-devel] [PATCH v4 16/16] hub: add the support for hub own flow control zwu.kernel
2012-05-25 11:05 ` Paolo Bonzini
2012-05-25 11:10   ` Zhi Yong Wu
2012-05-25 12:13 ` Stefan Hajnoczi
2012-05-26 12:32   ` Zhi Yong Wu
  -- strict thread matches above, loose matches on Subject: below --
2012-06-04  5:29 [Qemu-devel] [PATCH v4 00/16] hub-based networking patches zwu.kernel
2012-06-04  5:29 ` [Qemu-devel] [PATCH v4 16/16] hub: add the support for hub own flow control zwu.kernel

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).