Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTL8139/RTL8168 driver #504

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

RTL8139/RTL8168 driver #504

wants to merge 5 commits into from

Conversation

no92
Copy link
Member

@no92 no92 commented Dec 27, 2022

Depends on managarm/frigg#58.

Copy link
Member

@ArsenArsen ArsenArsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cursory look, between lectures; I don't know whether the driver itself is correct yet though.

drivers/nic/rtl8168/include/nic/rtl8168/queue.hpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/include/nic/rtl8168/tx.hpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/src/rtl8168.cpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/src/rtl8168.cpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/src/rtl8168.cpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/src/rx.cpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/src/tx.cpp Outdated Show resolved Hide resolved
servers/netserver/include/netserver/nic.hpp Outdated Show resolved Hide resolved
Copy link
Member

@Dennisbonke Dennisbonke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with my somewhat limited knowledge.

* This class serves to encapsulate the peculiarities of queue indices, especially their
* wrap-around modular arithmetic.
*/
struct QueueIndex {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something that is better suited to maybe put in frigg?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like it's part of a more general ring buffer style container

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it also seems like it's used this way in the code. Might be cleaner to just use a straight up ring-buffer container.

drivers/nic/rtl8168/include/nic/rtl8168/queue.hpp Outdated Show resolved Hide resolved
struct TxQueue {
TxQueue(size_t descriptors, RealtekNic &nic);

virtual ~TxQueue() = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the need for this virtual destructor?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gcc complains otherwise: warning: delete called on 'TxQueue' that is abstract but has non-virtual destructor

drivers/nic/rtl8168/include/nic/rtl8168/tx.hpp Outdated Show resolved Hide resolved
Copy link
Member

@ArsenArsen ArsenArsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll trust your judgement on the driver code itself since i have damn near zero experience with the RTLs this is a driver for.

seems good overall, a few comments left.

p.s. sorry about the delay.

drivers/nic/rtl8168/include/nic/rtl8168/queue.hpp Outdated Show resolved Hide resolved
struct RxQueue {
RxQueue(size_t descriptors, RealtekNic &nic);

uintptr_t getBase() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be const

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I make getBase constant, gcc complains about the operator[] method not being const.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make that const too then :)

(rather, there needs to be two overloads)

drivers/nic/rtl8168/include/nic/rtl8168/tx.hpp Outdated Show resolved Hide resolved
drivers/nic/rtl8168/src/tx.cpp Outdated Show resolved Hide resolved
@no92
Copy link
Member Author

no92 commented Jul 6, 2023

Addressed the comments above and rebased on master.

@no92 no92 marked this pull request as draft July 10, 2023 21:53
@ElectrodeYT
Copy link
Contributor

The driver is now capable of sending and receiving packets somewhat reliably on my revision of the RTL8168 card (MacVer46, rtl8168h).
Support for most other cards is not yet implemented, and the code is still extremely ugly and hacked together. I will try and improve the code a bit and also add support for a few other RTL network cards i can test with.

Copy link
Member

@Dennisbonke Dennisbonke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants