The built-in 10G Ethernet on Apple arm64 hardware does not have a MAC
authorkettenis <kettenis@openbsd.org>
Mon, 1 May 2023 08:25:55 +0000 (08:25 +0000)
committerkettenis <kettenis@openbsd.org>
Mon, 1 May 2023 08:25:55 +0000 (08:25 +0000)
address programmed into the hardware.  Get it from the device tree instead.

ok dlg@, jmatthew@

sys/dev/pci/if_aq_pci.c

index b79099c..206e4b3 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_aq_pci.c,v 1.20 2023/04/24 09:18:55 jmatthew Exp $ */
+/* $OpenBSD: if_aq_pci.c,v 1.21 2023/05/01 08:25:55 kettenis Exp $ */
 /*     $NetBSD: if_aq.c,v 1.27 2021/06/16 00:21:18 riastradh Exp $     */
 
 /*
 #include <netinet/in.h>
 #include <netinet/if_ether.h>
 
+#ifdef __HAVE_FDT
+#include <dev/ofw/openfirm.h>
+#endif
+
 #include <dev/pci/pcireg.h>
 #include <dev/pci/pcivar.h>
 #include <dev/pci/pcidevs.h>
@@ -2260,6 +2264,14 @@ aq2_get_mac_addr(struct aq_softc *sc)
        AQ_READ_REGS(sc, AQ2_FW_INTERFACE_IN_MAC_ADDRESS_REG,
            mac_addr, nitems(mac_addr));
 
+#ifdef __HAVE_FDT
+       if (mac_addr[0] == 0 && mac_addr[1] == 0 &&
+           PCITAG_NODE(sc->sc_pcitag)) {
+               OF_getprop(PCITAG_NODE(sc->sc_pcitag), "local-mac-address",
+                   mac_addr, ETHER_ADDR_LEN);
+       }
+#endif
+
        if (mac_addr[0] == 0 && mac_addr[1] == 0) {
                printf(": mac address not found\n");
                return ENXIO;