RTL8169 on real hardware not able to send packages

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
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

RTL8169 on real hardware not able to send packages

Post by SanderR »

Hello everyone,

I am trying to setup a RTL8169 driver.
So far I used the tutorial on osdev.org and added the interrupt function so the interrupts are working.
After this, I decided to look for incoming packets by sending "sudo dhclient" from my Linux computer to my computer with my OS on it.
The computer caused an interrupt and I can see what the system is sending to my computer.
So far so good.
Now I'm trying to send data to the network (the same package as I received earlier since I know this package is alright):
https://github.com/AdeRegt/SanderOSUSB/ ... 8169.c#L58
This function is not causing an interrupt and polling seems not to work (stays on 0x40 forever). Also, I cannot see it is sent with Wireshark.
Im testing this on real hardware.

I hope someone can help me.
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: RTL8169 on real hardware not able to send packages

Post by Jezze »

Hard to say what's wrong but one common mistake is that you forgot to set PCI Bus Mastering for the card.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
hidnplayr
Posts: 23
Joined: Sat Aug 09, 2008 5:07 pm

Re: RTL8169 on real hardware not able to send packages

Post by hidnplayr »

Please get rid of the magic numbers, it makes the code hard to read and maintain :)

It's not clear from the code if TX descriptors are properly aligned, they should be aligned on 256 byte boundary if I'm not mistaken.
You did not set the high address of the TX descriptor ring (bar1 + 0x24)
nlg
Member
Member
Posts: 40
Joined: Mon Mar 14, 2016 5:34 am

Re: RTL8169 on real hardware not able to send packages

Post by nlg »

I managed to make an RTL8139 driver for my OS but I had trouble getting it to start. the clock was missing and I had not found any indication of this clock in the official documentation. to start the clock there is a need to send the "R" byte to port 5Bh of the card registers

the source code of my driver: https://github.com/N-LG/service-etherne ... TL8139.asm (in assembler and commented in French, I know it's not easy but it can help a little bit)
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Re: RTL8169 on real hardware not able to send packages

Post by SanderR »

Thank you for your comments.
I managed to make it work on real hardware.

This is the sourcecode:
https://github.com/AdeRegt/SanderOSUSB/ ... /RTL8169.c
Post Reply