OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:28 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Realtek 8169 NIC Chipset
PostPosted: Tue Jul 15, 2008 12:08 pm 
Offline
Member
Member
User avatar

Joined: Fri Jun 22, 2007 12:47 pm
Posts: 1598
Location: New Hampshire, USA
I started writing a programmers guide to the rtl8169 chipset. I recently wrote this driver for the Netgear GA311 and thought id share my experiences and tips. At the moment it is very half-baked and incomplete, but I'm editing it very soon and will add more to it.

http://wiki.osdev.org/RTL8169

_________________
Website: https://Joscor.com


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Tue Jul 15, 2008 4:09 pm 
Offline
Member
Member
User avatar

Joined: Thu May 12, 2005 11:00 pm
Posts: 129
Location: Kabaty, Warszawa
wow, respect on developping a driver just from the specs and guesswork, that must be very hard work... I usually don't remember anything I read from a technical specification after about 5 minutes :) if I understand it in the first place.


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Wed Jul 16, 2008 7:46 pm 
Offline
Member
Member
User avatar

Joined: Fri Jun 22, 2007 12:47 pm
Posts: 1598
Location: New Hampshire, USA
Thanks, I wrote a bunch more, and with a fully working reset example.. more to come.

_________________
Website: https://Joscor.com


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Thu Jul 17, 2008 4:45 am 
Offline
Member
Member
User avatar

Joined: Fri Aug 03, 2007 6:03 am
Posts: 536
Location: Cambridge, UK
looks like a nice start (it's slightly better than the RTL8139 article), i might have to purchase one and give writing my own driver a crack (the prospect of gigabit ethernet on my OS is very likeable)

=D>

_________________
~ Lukem95 [ Cake ]
Release: 0.08b
Image


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Mon Oct 03, 2011 8:56 am 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
Thanks to the spec link, I now almost have a functional RTL8169 driver to RDOS (I have some problem with sending packets that I will eventually figure out).

Anyway, I like this architecture a lot. The interface is simple and probably race-free, which should make for a stable driver. It's not cluttered with scatter-gather garbage either, and can offlload checksums for IP, TCP and UDP. I need to look closer at this as my NIC interface currently don't support offloading checksums.


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Mon Oct 03, 2011 9:21 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
Here is the BareMetal OS Assembly driver for the RTL816x/811x: http://code.google.com/p/baremetal/source/browse/trunk/os/drivers/net/rtl8169.asm

I'll be keeping an eye on this article for any potential improvements I can make.

Good to see you back on the forums, 01000101.

-Ian

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Mon Oct 03, 2011 1:56 pm 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
ReturnInfinity wrote:
Here is the BareMetal OS Assembly driver for the RTL816x/811x: http://code.google.com/p/baremetal/source/browse/trunk/os/drivers/net/rtl8169.asm


Interesting, but the layout of the Tx buffer is not part of the code. Currently, I know that the NIC transmits my packet (it clears the OWN + updates the fields), but I cannot see the packet from another computer (its a DHCP-packet addressed to the broadcast address). Does the buffer start with the 6 byte destination or something else?

ReturnInfinity wrote:
Good to see you back on the forums, 01000101.

-Ian


Note that I bumped a thread from 2008!


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Wed Oct 05, 2011 12:10 pm 
Offline
Member
Member
User avatar

Joined: Mon Jul 28, 2008 9:46 am
Posts: 325
Location: Ontario, Canada
os_net_rtl8169_transmit in my driver sets that up. All it needs is the address in memory where the packet is sitting and also the size of it. That information gets written into the RTL9168 transmit ring buffer. Do you see activity on the NIC or switch?

Ah, so you did. My mistake!

-Ian

_________________
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Wed Oct 05, 2011 2:33 pm 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
Some expected feature that wasn't spelled-out properly in the spec. Apparantely, when using more than one descriptor, there is a need to go through the descriptor ring sequentially for send-packets, as the controller won't check more than the current entry for "ready-to-send". I assumed setting the "queue" bit would imply it would search through the whole descriptor-ring, but it won't do that.

Now it generally works, but after a while the receiver stops working. I have no idea about this, but can conclude that all descriptors in the ring are free. I'll check the ISR bits tomorrow.

EDIT: Issue solved. I was corrupting the EOR flag in the last descriptor. The code link below is to a working implementation.

BTW, my driver is here: http://rdos.net/vc/viewvc.cgi/trunk/ker ... iew=markup


Top
 Profile  
 
 Post subject: Re: Realtek 8169 NIC Chipset
PostPosted: Wed Dec 14, 2011 3:25 pm 
Offline
Member
Member

Joined: Wed Oct 01, 2008 1:55 pm
Posts: 3191
There is an important part missing in the Wiki, as well as in other simple drivers. The spec for the NIC claims that PHY ANAR register is setup to autonegotiate all available modes, but this is not always true (not true on any of my test machines at least). Resetting the PHY won't work either. The only way to get the correct speed on some chips is to set all possible bits in the PHY ANAR register. After writing these bits during boot, and starting autonegotiation at boot and in the ISR when the link goes off, I now get the correct speed of the link. Without these, the NIC will use 10M regardless of switch/router capabilities.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group