Page 1 of 1

Quick question r.e. RTL8139 chipsets

Posted: Wed Nov 07, 2007 3:21 am
by JamesM
I've got a seriously cheap (£2.50) network card in my testbed machine. It's got (I think) a RTL8139 -ish chip in it, but I can't get it to recieve DHCP ACKs in linux.

I assume the chances of me successfully writing a driver for my OS that makes it work is non-existent? Do people suggest I get a better NIC?

Posted: Wed Nov 07, 2007 6:17 am
by Dex
RTL8139 is one of the easiest and most documented network card around.

Posted: Wed Nov 07, 2007 8:15 am
by JamesM
Yes, but if the linux driver can't seem to run it, is it worth my even trying? Could the hardware be bust? I don't want to spend weeks writing a driver that will never work!

Posted: Wed Nov 07, 2007 8:29 am
by Brynet-Inc
It's a widely documented chipset, but many implementations are buggy/flaky..

Here is a quotation from OpenBSD's manual page for Realtek 8139C+/8169/816xS/811xS/8101E cards:
rl(4) wrote:Since outbound packets must be longword aligned, the transmit routine has to copy an unaligned packet into an mbuf cluster buffer before transmission. The driver abuses the fact that the cluster buffer pool is allocated at system startup time in a contiguous region starting at a page boundary. Since cluster buffers are 2048 bytes, they are longword aligned by definition. The driver probably should not be depending on this characteristic.

The Realtek data sheets are of especially poor quality: the grammar and spelling are awful and there is a lot of information missing, particularly concerning the receiver operation. One particularly important fact that the data sheets fail to mention relates to the way in which the chip fills in the receive buffer. When an interrupt is posted to signal that a frame has been received, it is possible that another frame might be in the process of being copied into the receive buffer while the driver is busy handling the first one. If the driver manages to finish processing the first frame before the chip is done DMAing the rest of the next frame, the driver may attempt to process the next frame in the buffer before the chip has had a chance to finish DMAing all of it.

The driver can check for an incomplete frame by inspecting the frame length in the header preceding the actual packet data: an incomplete frame will have the magic length of 0xFFF0. When the driver encounters this value, it knows that it has finished processing all currently available packets. Neither this magic value nor its significance are documented anywhere in the Realtek data sheets.
I'm lucky enough to own a few ASUS rebranded devices, they seem to work perfectly under OpenBSD.. but often manifest problems under FreeBSD.

Posted: Wed Nov 07, 2007 9:00 am
by jal
Brynet-Inc wrote:Here is a quotation from OpenBSD's manual page for Realtek 8139C+/8169/816xS/811xS/8101E cards:
Where can I find this on-line? (Yes, I'm lazy.)


JAL

Posted: Wed Nov 07, 2007 9:08 am
by Dex
@JamesM, you can try my OS and RTL8139 driver if you want, let me know and i will send you a link.

Posted: Wed Nov 07, 2007 9:09 am
by Brynet-Inc
Yes, Manual pages can be viewed online... 8)

rl(4) - Realtek 8129/8139 10/100 Ethernet devices

re(4) - RealTek 8139C+/8169/816xS/811xS/8101E 10/100/Gigabit Ethernet devices

The source code is also documented quite well...

Posted: Wed Nov 07, 2007 1:40 pm
by exkor
manuals, free, with some limit # per day to download
http://www.datasheetarchive.com/search. ... 0&sub.y=14

Posted: Wed Nov 07, 2007 1:54 pm
by 01000101
look through the wiki!!!
I wrote a nice little how-to for programming the RTL8139.

Posted: Wed Nov 07, 2007 2:14 pm
by jal
Brynet-Inc wrote:Yes, Manual pages can be viewed online... 8)
Thanks :)


JAL

Posted: Thu Nov 08, 2007 2:31 am
by JamesM
01000101 wrote:look through the wiki!!!
I wrote a nice little how-to for programming the RTL8139.
Yes, thanks for that, it's not as if I'd check the wiki first for a programming problem before posting... :S

My question was not 'how to' program for the RTL chip, it was 'should I bother with this particular card, as linux seems to have a problem with it - therefore my chances of getting it working are next to NULL'.

Posted: Thu Nov 08, 2007 1:35 pm
by Candy
01000101 wrote:look through the wiki!!!
I wrote a nice little how-to for programming the RTL8139.
I've tried it, as far as I can tell it doesn't work. The QEMU card acknowledges that it has a packet and does nothing, the real card (8139C+) says it's never received a packet. Neither has any incoming packets either.

Posted: Thu Nov 08, 2007 2:41 pm
by 01000101
well, ive tried it on BOCHS, VPC, and real PC's and it works just fine.

The code doesn't show you how to handle the packet . It just shows you how to copy it into memory, then it is up to you what to do with it. Also, you must support IRQ handling as well, either that or poll the recieve buffer at a set interval to keep getting packets.

and if you have a problem with the code, fix it... that's the point of the wiki.