All of lore.kernel.org
 help / color / mirror / Atom feed
* RE: [patch] ne2000.patch
@ 2006-05-30 11:39 Ian Pratt
  2006-05-30 12:31 ` han
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Pratt @ 2006-05-30 11:39 UTC (permalink / raw)
  To: Keir Fraser, Han, Zhu; +Cc: xen-devel

> > 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!
> 
> Does this actually fix any reported bugs or measurably 
> improve performance? If not then it isn't worth us diverging 
> from qemu code: 
> it's up to qemu maintainers whether or not to accept the patch.

Does it solve the issue that OpenBSD had with the ne2k emulation under
high load?

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread
* RE: [patch] ne2000.patch
@ 2006-05-31  2:36 Han, Zhu
  0 siblings, 0 replies; 5+ messages in thread
From: Han, Zhu @ 2006-05-31  2:36 UTC (permalink / raw)
  To: Han, Zhu, xen-devel

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@lists.xensource.com [mailto:xen-devel-bounces@lists.xensource.com] On Behalf Of Han, Zhu
Sent: 2006年5月30日 14:14
To: xen-devel@lists.xensource.com
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@intel.com>
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

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [patch] ne2000.patch
@ 2006-05-30  6:14 Han, Zhu
  2006-05-30 11:33 ` Keir Fraser
  0 siblings, 1 reply; 5+ messages in thread
From: Han, Zhu @ 2006-05-30  6:14 UTC (permalink / raw)
  To: xen-devel

[-- Attachment #1: Type: text/plain, Size: 2328 bytes --]

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@intel.com>
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


[-- Attachment #2: ne2000.patch --]
[-- Type: application/octet-stream, Size: 1544 bytes --]

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;
 }
 

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-05-31  2:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-30 11:39 [patch] ne2000.patch Ian Pratt
2006-05-30 12:31 ` han
  -- strict thread matches above, loose matches on Subject: below --
2006-05-31  2:36 Han, Zhu
2006-05-30  6:14 Han, Zhu
2006-05-30 11:33 ` Keir Fraser

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.