From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50454) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXsKr-0002A9-87 for qemu-devel@nongnu.org; Fri, 25 May 2012 07:05:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXsKp-0003SW-Eg for qemu-devel@nongnu.org; Fri, 25 May 2012 07:05:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXsKp-0003SM-6d for qemu-devel@nongnu.org; Fri, 25 May 2012 07:05:31 -0400 Message-ID: <4FBF6773.2080306@redhat.com> Date: Fri, 25 May 2012 13:05:23 +0200 From: Paolo Bonzini MIME-Version: 1.0 References: <1337943134-1107-1-git-send-email-zwu.kernel@gmail.com> In-Reply-To: <1337943134-1107-1-git-send-email-zwu.kernel@gmail.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v4 16/16] hub: add the support for hub own flow control List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: zwu.kernel@gmail.com Cc: jan.kiszka@siemens.com, wuzhy@linux.vnet.ibm.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, stefanha@linux.vnet.ibm.com Il 25/05/2012 12:52, zwu.kernel@gmail.com ha scritto: > From: Zhi Yong Wu > > 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 > --- > 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); I think you still need to apply flow control, otherwise you're cheating. But perhaps this is acceptable, I'll leave it to more expert people. Paolo