Quick question r.e. RTL8139 chipsets

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Quick question r.e. RTL8139 chipsets

Post 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?
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

RTL8139 is one of the easiest and most documented network card around.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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!
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
User avatar
Dex
Member
Member
Posts: 1444
Joined: Fri Jan 27, 2006 12:00 am
Contact:

Post by Dex »

@JamesM, you can try my OS and RTL8139 driver if you want, let me know and i will send you a link.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post 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...
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
exkor
Member
Member
Posts: 111
Joined: Wed May 23, 2007 9:38 pm

Post by exkor »

manuals, free, with some limit # per day to download
http://www.datasheetarchive.com/search. ... 0&sub.y=14
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post by 01000101 »

look through the wiki!!!
I wrote a nice little how-to for programming the RTL8139.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post by jal »

Brynet-Inc wrote:Yes, Manual pages can be viewed online... 8)
Thanks :)


JAL
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Post 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'.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Post 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.
User avatar
01000101
Member
Member
Posts: 1599
Joined: Fri Jun 22, 2007 12:47 pm
Contact:

Post 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.
Post Reply