From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:58887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StR5U-0002BR-U7 for qemu-devel@nongnu.org; Mon, 23 Jul 2012 18:26:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StR5T-0001TM-Kr for qemu-devel@nongnu.org; Mon, 23 Jul 2012 18:26:48 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StR5T-0001T0-Bd for qemu-devel@nongnu.org; Mon, 23 Jul 2012 18:26:47 -0400 Message-ID: <500DCFEA.1000603@redhat.com> Date: Tue, 24 Jul 2012 00:27:54 +0200 From: Laszlo Ersek MIME-Version: 1.0 References: <1342785709-3152-1-git-send-email-stefanha@linux.vnet.ibm.com> <1342785709-3152-17-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1342785709-3152-17-git-send-email-stefanha@linux.vnet.ibm.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 16/16] hub: add the support for hub own flow control List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Paolo Bonzini , Zhi Yong Wu , qemu-devel@nongnu.org, Zhi Yong Wu On 07/20/12 14:01, Stefan Hajnoczi wrote: > 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. > > Reviewed-off-by: Paolo Bonzini Probably a typo. > Signed-off-by: Zhi Yong Wu > Signed-off-by: Stefan Hajnoczi > --- > net/hub.c | 27 ++++++++++++++++++++++++--- > 1 file changed, 24 insertions(+), 3 deletions(-) > > diff --git a/net/hub.c b/net/hub.c > index f697a78..2d67df5 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; > } This seems to consolidate net_hub_receive_iov()'s retval with that of net_hub_receive(), but may I ask why it used to be calculated differently? > > 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; > +} > + (qemu_can_send_packet() handles a NULL sender->peer, OK.) No further comments for the series. Thanks! Laszlo