[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Xen-devel] [patch] ne2000.patch


  • To: "Han, Zhu" <zhu.han@xxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxx>
  • From: "Han, Zhu" <zhu.han@xxxxxxxxx>
  • Date: Wed, 31 May 2006 10:36:29 +0800
  • Delivery-date: Tue, 30 May 2006 19:36:57 -0700
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>
  • Thread-index: AcaDsEpR6tT0w9WqQFiqiRlU1A0QqgAqlxKw
  • Thread-topic: [Xen-devel] [patch] ne2000.patch

Hi, Ian and Keir,
I'm convinced the ne2000 card cannot work under LINUX HVM without this patch 
even sync to the latest changeset. So, this patch makes the ne2000 card work 
and also makes it work stable in my test case.
BTW: Anyone could help me test it against openBSD VMX? I don't own such 
environment.

Best Regards, 
hanzhu

-----Original Message-----
From: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx 
[mailto:xen-devel-bounces@xxxxxxxxxxxxxxxxxxx] On Behalf Of Han, Zhu
Sent: 2006年5月30日 14:14
To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [patch] ne2000.patch

This small could make ne2000 net card on HVM work stable.
I have submitted the patch to qemu mail list. Actually, they only check
the second part of it!

Several note:
1) Because ne2000.c in device model don't implement all the features
required by ne2000 hardware specs, I add some simple workaround to it!
When the buffer is full, resend the IRQ singal to the receiver! The
hardware asks us to send overflow IRQ to receiver, However, we needn't
do that since the software implementation will not overflow but just
miss the irq signal and halt itself!
2) According to the hardware spec, I have changed the condition when the
buffer is full.

Signed-off-by: hanzhu <zhu.han@xxxxxxxxx>
diff -r 6d476981e3a5 tools/ioemu/hw/ne2000.c
--- a/tools/ioemu/hw/ne2000.c   Sun May 28 15:49:17 2006 +0100
+++ b/tools/ioemu/hw/ne2000.c   Mon May 29 16:28:11 2006 +0800
@@ -147,9 +147,37 @@ 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);
+
+    if(avail < (MAX_ETH_FRAME_SIZE + 4))
+        return 1;
+    
+    return 0;
+}
+
 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",
@@ -172,14 +200,10 @@ static int ne2000_can_receive(void *opaq
     
     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))
+
+    if(ne2000_buffer_full(s)){
         return 0;
+    }
     return MAX_ETH_FRAME_SIZE;
 }

Best Regards, 
hanzhu

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.