Page MenuHomeFreeBSD

Correctly set the MAC address for ethernet interfaces on Starfive VisionFiv2 2, riscv64 SBC
ClosedPublic

Authored by bscott_bunyatech.com.au on Mon, May 4, 8:39 AM.
Tags
None
Referenced Files
F157383216: D56782.diff
Wed, May 20, 8:40 PM
Unknown Object (File)
Tue, May 19, 5:43 PM
Unknown Object (File)
Tue, May 19, 3:42 AM
Unknown Object (File)
Mon, May 18, 9:42 PM
Unknown Object (File)
Thu, May 14, 1:37 PM
Unknown Object (File)
Thu, May 14, 1:37 PM
Unknown Object (File)
Thu, May 14, 12:33 PM
Unknown Object (File)
Wed, May 13, 11:56 PM
Subscribers

Details

Summary

u-boot/opensbi determine the ethernet MAC address from ROM and pass it to the O/S in the device tree.
This change sets the correct MAC address. This prevents the eqos class driver from generating random MAC addresses at each boot.

Test Plan

On a visionfive2 system, verify that a correct static MAC address is assigned rather than a random MAC address (f2:xx:xx:xx:xx:xx)

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

mhorne requested changes to this revision.Wed, May 6, 6:33 PM
mhorne added a subscriber: mhorne.

Thanks for digging into this.

I think the code can be simplified. Something like this:

if (OF_getprop(node, "local-mac-address", eaddr, sizeof(eaddr)) == sizeof(eaddr)) {
        machi = eaddr[5] | (eaddr[4] << 8);
        WR4(sc, GMAC_MAC_ADDRESS0_HIGH, machi);
        maclo = eaddr[3] | (eaddr[2] << 8) | (eaddr[1] << 16) | (eaddr[0] << 24);
	WR4(sc, GMAC_MAC_ADDRESS0_LOW, maclo);
}

Please check for accuracy.

sys/dev/eqos/if_eqos_starfive.c
199–207

It seems we don't need this block at all.

216

Please drop the print messages. They are useful for debugging, but most ethernet drivers don't print this when setting the MAC address.

This revision now requires changes to proceed.Wed, May 6, 6:33 PM

Changes pretty much as suggested by mhorne. More concise code and no messages.

bscott_bunyatech.com.au marked 2 inline comments as done and an inline comment as not done.Thu, May 7, 8:40 AM
bscott_bunyatech.com.au added inline comments.
sys/dev/eqos/if_eqos_starfive.c
199–207

Currently the MAC address is set to ff:ff:ff:ff:ff:ff after the reset. The intention was to make some noise if this isn't always the case on some future variant.
However I can't see why we would ever get a hint through the device tree AND have a different baked in address in the actual device. You win. If we get a hint we should use it no matter what.

216

Agree. This was just debugging.

Thanks again. When I have the chance I will test this and merge the change (likely early next week).

This revision is now accepted and ready to land.Thu, May 7, 5:31 PM