[solved]Qemu Problem with RTL8139 NIC emulation
[solved]Qemu Problem with RTL8139 NIC emulation
Hi,
I am currently writing a driver for RTL8139 NIC and I'm testing it under qemu. Sending packets seems to work well, but receiving is a bit more problematical. In order to test network under qemu, I have set up a tap device and given it an IPv4 address so as to be able to ping my guest machine from the host. I also use Wireshark to sniff the incoming (and outcoming) packets on the tap. When I ping my guest OS, my tap interface does receive ICMP (and also ARP) packets according to Wireshark. qemu also reacts : I get an interrupt with "Reception OK" flag in the Interrupt Status Register of the NIC. The problem is even though an interrupt has been raised to notify an incoming packet, the whole receive buffer is still filled with zeros (as it was initialized at the OS startup). It seems the receive buffer has not been filled with the incoming bytes.
I know there has been a similar issue on the forum (http://forum.osdev.org/viewtopic.php?f=1&t=26555). However, this has not been solved. There's also another point: I have not only tested my driver on qemu but also on real machine. And on real machine, it worked as expected: it dumped as many incoming packets as I wanted, and the dumped bytes were accurate (I could check it with Wireshark again). The NIC I use on my real PC is a RTL8139C. So maybe my driver is not compatible with all the variants of the RTL8139, and in particular not compatible with the version emulated by qemu... But this last assumption is hard to check and I hope there's a simpler explanation.
What do you think about it ?
Thanks in advance.
I am currently writing a driver for RTL8139 NIC and I'm testing it under qemu. Sending packets seems to work well, but receiving is a bit more problematical. In order to test network under qemu, I have set up a tap device and given it an IPv4 address so as to be able to ping my guest machine from the host. I also use Wireshark to sniff the incoming (and outcoming) packets on the tap. When I ping my guest OS, my tap interface does receive ICMP (and also ARP) packets according to Wireshark. qemu also reacts : I get an interrupt with "Reception OK" flag in the Interrupt Status Register of the NIC. The problem is even though an interrupt has been raised to notify an incoming packet, the whole receive buffer is still filled with zeros (as it was initialized at the OS startup). It seems the receive buffer has not been filled with the incoming bytes.
I know there has been a similar issue on the forum (http://forum.osdev.org/viewtopic.php?f=1&t=26555). However, this has not been solved. There's also another point: I have not only tested my driver on qemu but also on real machine. And on real machine, it worked as expected: it dumped as many incoming packets as I wanted, and the dumped bytes were accurate (I could check it with Wireshark again). The NIC I use on my real PC is a RTL8139C. So maybe my driver is not compatible with all the variants of the RTL8139, and in particular not compatible with the version emulated by qemu... But this last assumption is hard to check and I hope there's a simpler explanation.
What do you think about it ?
Thanks in advance.
Re: [qemu] Problem with RTL8139 NIC emulation
Good someone else had the same problem =) I was starting to think I was going crazy there for a moment...
I havent given it any more work since then so I'm still in the same situation as you. I think it is a bug with QEMU but I havent gotten around to actually seek the exact problem out. Will be following this thread closely though.
I havent given it any more work since then so I'm still in the same situation as you. I think it is a bug with QEMU but I havent gotten around to actually seek the exact problem out. Will be following this thread closely though.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
Re: [qemu] Problem with RTL8139 NIC emulation
I too am troubled with a driver that works on real RTL8139 (tested on at least versions B, C and D), but not fully in QEMU.
The problem I seem to have in QEMU is that interrupts are not fired for received packets.
http://websvn.kolibrios.org/filedetails ... TL8139.asm
The problem I seem to have in QEMU is that interrupts are not fired for received packets.
http://websvn.kolibrios.org/filedetails ... TL8139.asm
Re: [qemu] Problem with RTL8139 NIC emulation
Normally, an interrupt is fired when a packet is received. To get sure the packet is received, try to use a tap device and dump the incoming packets on your tap with tcpdump or Wireshark.hidnplayr wrote:I too am troubled with a driver that works on real RTL8139 (tested on at least versions B, C and D), but not fully in QEMU.
The problem I seem to have in QEMU is that interrupts are not fired for received packets.
I have modified the code of qemu a bit so that it displays the received packet to the console : appearently, qemu does receive the good packet. The question now is why it doesn't end up in the receive buffer.
Re: [qemu] Problem with RTL8139 NIC emulation
I remember a similar problem of mine… So I'm just asking: Did you enable bus mastering in the PCI command register? (I guess it could work on a real machine because the BIOS already did that – however, I remember that not being the case for qemu)
Re: [qemu] Problem with RTL8139 NIC emulation
Hmm that might be it... perhaps they added support for that in later versions of QEMU.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
Re: [qemu] Problem with RTL8139 NIC emulation
qemu checks the Bus Master bit since version 1.3. Says my commit message at least, I had to fix my code back then, too...
Re: [qemu] Problem with RTL8139 NIC emulation
I enabled bus mastering and it worked. Thanks !XanClic wrote:I remember a similar problem of mine… So I'm just asking: Did you enable bus mastering in the PCI command register? (I guess it could work on a real machine because the BIOS already did that – however, I remember that not being the case for qemu)
Re: [qemu] Problem with RTL8139 NIC emulation
Will anybody update wiki to add this fact?
Re: [qemu] Problem with RTL8139 NIC emulation
Can I just say: EXCELLENT!
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
Re: [qemu] Problem with RTL8139 NIC emulation
Ok, I have updated the Wiki.Nable wrote:Will anybody update wiki to add this fact?
Re: [qemu] Problem with RTL8139 NIC emulation
I can now also confirm this works =)
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
http://github.com/Jezze/fudge/
Re: [solved]Qemu Problem with RTL8139 NIC emulation
Just for reference:
My driver did not work on qemu because I wrote the receive configuration register as a word (instead of dword)
This works on real hardware but not in Qemu.
My driver did not work on qemu because I wrote the receive configuration register as a word (instead of dword)
This works on real hardware but not in Qemu.