WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

[XenPPC] [xenppc-unstable] [HVM] Fixes to buffer handling in ne2000 devi

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [HVM] Fixes to buffer handling in ne2000 device model.
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 02 Jun 2006 17:56:05 +0000
Delivery-date: Fri, 02 Jun 2006 10:57:44 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 9e207a5cf589ae6401a88f3391163ff6e9b9a180
# Parent  d291e3a930dd1c2e39414fe20824ef5d2d815922
[HVM] Fixes to buffer handling in ne2000 device model.
Signed-off-by: hanzhu <zhu.han@xxxxxxxxx>
---
 tools/ioemu/hw/ne2000.c |   36 ++++++++++++++++++++++++++----------
 1 files changed, 26 insertions(+), 10 deletions(-)

diff -r d291e3a930dd -r 9e207a5cf589 tools/ioemu/hw/ne2000.c
--- a/tools/ioemu/hw/ne2000.c   Wed May 31 07:48:54 2006 +0100
+++ b/tools/ioemu/hw/ne2000.c   Wed May 31 09:30:40 2006 +0100
@@ -147,9 +147,33 @@ static void ne2000_reset(NE2000State *s)
     }
 }
 
+static int ne2000_buffer_full(NE2000State *s)
+{
+    int avail, index, boundary;
+
+    index = s->curpag << 8;
+    boundary = s->boundary << 8;
+    if (index <= boundary)
+        /* when index == boundary, we should assume the
+         * buffer is full instead of empty!
+         */
+        avail = boundary - index;
+    else
+        avail = (s->stop - s->start) - (index - boundary);
+
+    return (avail < (MAX_ETH_FRAME_SIZE + 4));
+}
+
 static void ne2000_update_irq(NE2000State *s)
 {
     int isr;
+
+    if (ne2000_buffer_full(s)) {
+        /* The freeing space is not enough, tell the ne2k driver
+         * to fetch these packets!
+         */
+        s->isr |= ENISR_RX;
+    }
     isr = s->isr & s->imr;
 #if defined(DEBUG_NE2000)
     printf("NE2000: Set IRQ line %d to %d (%02x %02x)\n",
@@ -168,19 +192,11 @@ static int ne2000_can_receive(void *opaq
 static int ne2000_can_receive(void *opaque)
 {
     NE2000State *s = opaque;
-    int avail, index, boundary;
     
     if (s->cmd & E8390_STOP)
         return 0;
-    index = s->curpag << 8;
-    boundary = s->boundary << 8;
-    if (index < boundary)
-        avail = boundary - index;
-    else
-        avail = (s->stop - s->start) - (index - boundary);
-    if (avail < (MAX_ETH_FRAME_SIZE + 4))
-        return 0;
-    return MAX_ETH_FRAME_SIZE;
+
+    return (ne2000_buffer_full(s) ? 0 : MAX_ETH_FRAME_SIZE);
 }
 
 #define MIN_BUF_SIZE 60

_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [XenPPC] [xenppc-unstable] [HVM] Fixes to buffer handling in ne2000 device model., Xen patchbot-xenppc-unstable <=