All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Ne2000 bug?, buffer full/empty
@ 2007-03-26 18:05 Marcel Block
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Block @ 2007-03-26 18:05 UTC (permalink / raw)
  To: qemu-devel

Hi qemu-devers,

this is my first post here, so please be kind :-)

i believe i found a bug in qemu's ne2000 code. i'm currently working on 
a ne2000 driver for my little hobby-os and i'm having some troubles 
getting it to receive any packets when running on qemu. but it works 
fine on bochs and on _real_ ne2000-hardware (rtl8029-pci in my case).

i believe the case "current page register == boundary register" should 
be interpreted as 'buffer empty' instead of 'buffer full'. this was 
changed last year or so by dr. han zhu, i tried to send him a email but 
it looks like the email-address he used back then is no longer available.

the current code looks like this: (hw/ne2000.c):
static int ne2000_buffer_full(NE2000State *s)
{
    int avail, index, boundary;

    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 1;
    return 0;
}

that way qemu thinks the buffer is full if index==boundary. if i change 
the "if(index <= boundary)" back to "if(index < boundary)" my driver 
appears to work fine.

all the specs i read so far tend to initialize those two registers to 
the same value. so it appears logical that index==boundary should be 
interpreted as 'buffer empty'.

i'm waiting for your feedback :-)

best regards,
marcel block

^ permalink raw reply	[flat|nested] 3+ messages in thread
* [Qemu-devel] ne2000 bug? buffer full/empty
@ 2007-03-27  6:58 Marcel Block
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Block @ 2007-03-27  6:58 UTC (permalink / raw)
  To: qemu-devel

Hi qemu-devers,

this is my first post here, so please be kind :-)

i believe i found a bug in qemu's ne2000 code. i'm currently working on 
a ne2000 driver for my little hobby-os and i'm having some troubles 
getting it to receive any packets when running on qemu. but it works 
fine on bochs and on _real_ ne2000-hardware (rtl8029-pci in my case).

i believe the case "current page register == boundary register" should 
be interpreted as 'buffer empty' instead of 'buffer full'. this was 
changed last year or so by dr. han zhu, i tried to send him a email but 
it looks like the email-address he used back then is no longer available.

the current code looks like this: (hw/ne2000.c):
static int ne2000_buffer_full(NE2000State *s)
{
   int avail, index, boundary;

   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 1;
   return 0;
}

that way qemu thinks the buffer is full if index==boundary. if i change 
the "if(index <= boundary)" back to "if(index < boundary)" my driver 
appears to work fine.

all the specs i read so far tend to initialize those two registers to 
the same value. so it appears logical that index==boundary should be 
interpreted as 'buffer empty'.

i'm waiting for your feedback :-)

best regards,
marcel block

^ permalink raw reply	[flat|nested] 3+ messages in thread
* Re: [Qemu-devel] ne2000 bug? buffer full/empty
@ 2007-04-02  1:21 Marcel Block
  0 siblings, 0 replies; 3+ messages in thread
From: Marcel Block @ 2007-04-02  1:21 UTC (permalink / raw)
  To: qemu-devel

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

hi again,

here's a patch for the changes i described before.

best regards
marcel block

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: qemu_ne2000.patch --]
[-- Type: text/x-patch; name="qemu_ne2000.patch", Size: 398 bytes --]

--- qemu-0.9.0/hw/ne2000.c	2007-02-06 00:01:54.000000000 +0100
+++ ne2000.c	2007-04-02 03:02:32.000000000 +0200
@@ -206,7 +206,7 @@ static int ne2000_buffer_full(NE2000Stat
 
     index = s->curpag << 8;
     boundary = s->boundary << 8;
-    if (index <= boundary)
+    if (index < boundary)
         avail = boundary - index;
     else
         avail = (s->stop - s->start) - (index - boundary);

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

end of thread, other threads:[~2007-04-02  1:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-26 18:05 [Qemu-devel] Ne2000 bug?, buffer full/empty Marcel Block
2007-03-27  6:58 [Qemu-devel] ne2000 bug? " Marcel Block
2007-04-02  1:21 Marcel Block

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.