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

rtl8169: fail to read MAC address on FreeBSD-originated drivers #118

Closed
X547 opened this issue Dec 30, 2023 · 6 comments
Closed

rtl8169: fail to read MAC address on FreeBSD-originated drivers #118

X547 opened this issue Dec 30, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@X547
Copy link
Contributor

X547 commented Dec 30, 2023

Following patch is needed to make it working on Haiku:

diff --git a/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c b/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c
index cf327932cd7..5bd4ee548a7 100644
--- a/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c
+++ b/src/add-ons/kernel/drivers/network/ether/rtl81xx/dev/re/if_re.c
@@ -1564,7 +1564,7 @@ re_attach(device_t dev)
 	CSR_WRITE_1(sc, sc->rl_cfg5, cfg);
 	CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
 
-	if ((sc->rl_flags & RL_FLAG_PAR) != 0) {
+	if (true || (sc->rl_flags & RL_FLAG_PAR) != 0) {
 		/*
 		 * XXX Should have a better way to extract station
 		 * address from EEPROM.

RVVM probably incorrectly declare network card model that don't match implemented MAC address access method.

@X547 X547 added the bug Something isn't working label Dec 30, 2023
@LekKit
Copy link
Owner

LekKit commented Jan 2, 2024

Interesting, I remember there being some PHY command related to MAC address which is not properly documented in the spec I used for reference. There are MAC registers directly mapped into the NIC BAR however (And are implemented properly), so idk what is the PHY thing for.
As for emulated device it's an RTL8169C, one of the easiest models to emulate and the one I actually have documentation for - will try to get more info soon

@LekKit
Copy link
Owner

LekKit commented Jan 3, 2024

So I figured - for some reason FreeBSD driver wants to get MAC address from EEPROM (Which is present on rtl8169 and provides default values for most chip configuration on reset), whereas Linux directly accesses MAC address in IDR0-5 registers which are straightforward to implement and contain same MAC as in EEPROM upon reset.
Seems I'll have to emulate EEPROM presence soon

The weird part is, actual FreeBSD 14 worked perfectly for me (altho it believes that MAC is 00:00:...)

@LekKit LekKit self-assigned this Jan 3, 2024
@clee clee mentioned this issue Jan 23, 2024
10 tasks
@LekKit
Copy link
Owner

LekKit commented Feb 25, 2024

Implemented AT93C56 EEPROM emulation in 60c5dae. Both FreeBSD and Haiku guests seem to recognize MAC address properly.

image

image

If you confirm that everything works we can close this.

@LekKit
Copy link
Owner

LekKit commented Feb 25, 2024

It seems ssh into guest (ssh root@localhost -p 2022) doesn't work tho. Don't have an idea why, "Received" stat increments so it seems incoming SYN segments reach the guest, but "Sent" doesn't change so apparently guest doesn't reply with SYN ACK to incoming connection

FreeBSD networking works perfectly.

Perhaps my Haiku image doesn't have sshd package.

@LekKit
Copy link
Owner

LekKit commented Mar 4, 2024

Any update?

@X547
Copy link
Contributor Author

X547 commented Mar 4, 2024

MAC address reading is working in Haiku after fix.

@X547 X547 closed this as completed Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants