Received: from eggs.gnu.org ([140.186.70.92]:50976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REkcC-0007va-UK for qemu-devel@nongnu.org; Fri, 14 Oct 2011 12:28:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REkcB-0005hv-U0 for qemu-devel@nongnu.org; Fri, 14 Oct 2011 12:28:08 -0400 Received: from v220110690675601.yourvserver.net ([78.47.199.172]:43988) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REkcB-0005h4-Kl for qemu-devel@nongnu.org; Fri, 14 Oct 2011 12:28:07 -0400 Message-ID: <4E9862E1.4040206@weilnetz.de> Date: Fri, 14 Oct 2011 18:27:13 +0200 From: Stefan Weil MIME-Version: 1.0 References: <20111014104927.22252.96179.stgit@dhcp-8-146.nay.redhat.com> In-Reply-To: <20111014104927.22252.96179.stgit@dhcp-8-146.nay.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] rtl8139: check the buffer availiability List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: blauwirbel@gmail.com, aliguori@us.ibm.com, mst@redhat.com, qemu-devel@nongnu.org, stefanha@linux.vnet.ibm.com See my comments below. Am 14.10.2011 12:49, schrieb Jason Wang: > Reduce spurious packet drops on RX ring empty when in c+ mode by verifying that > we have at least 1 buffer ahead of the time. > > Signed-off-by: Jason Wang > --- > hw/rtl8139.c | 43 +++++++++++++++++++++++++++++-------------- > 1 files changed, 29 insertions(+), 14 deletions(-) > > diff --git a/hw/rtl8139.c b/hw/rtl8139.c > index 3753950..c654d5d 100644 > --- a/hw/rtl8139.c > +++ b/hw/rtl8139.c > @@ -84,6 +84,19 @@ > #define VLAN_TCI_LEN 2 > #define VLAN_HLEN (ETHER_TYPE_LEN + VLAN_TCI_LEN) > > +/* w0 ownership flag */ > +#define CP_RX_OWN (1<<31) > +/* w0 end of ring flag */ > +#define CP_RX_EOR (1<<30) > +/* w0 bits 0...12 : buffer size */ > +#define CP_RX_BUFFER_SIZE_MASK ((1<<13) - 1) > +/* w1 tag available flag */ > +#define CP_RX_TAVA (1<<16) > +/* w1 bits 0...15 : VLAN tag */ > +#define CP_RX_VLAN_TAG_MASK ((1<<16) - 1) > +/* w2 low 32bit of Rx buffer ptr */ > +/* w3 high 32bit of Rx buffer ptr */ > + > #if defined (DEBUG_RTL8139) > # define DPRINTF(fmt, ...) \ > do { fprintf(stderr, "RTL8139: " fmt, ## __VA_ARGS__); } while (0) > @@ -805,6 +818,21 @@ static inline target_phys_addr_t rtl8139_addr64(uint32_t low, uint32_t high) > #endif > } > > +/* Verify that we have at least one available rx buffer */ > +static int rtl8139_cp_has_rxbuf(RTL8139State *s) > +{ > + uint32_t val, rxdw0; > + target_phys_addr_t cplus_rx_ring_desc = rtl8139_addr64(s->RxRingAddrLO, > + s->RxRingAddrHI); > + cplus_rx_ring_desc += 16 * s->currCPlusRxDesc; > + cpu_physical_memory_read(cplus_rx_ring_desc, (uint8_t *)&val, 4); The type cast is not needed, please remove it. > + rxdw0 = le32_to_cpu(val); > + if (rxdw0& CP_RX_OWN) > + return 1; > + else > + return 0; The QEMU coding conventions require braces here. Check your patch with scripts/checkpatch.pl. Regards, Stefan W.