Op zondag 14 juni 2026 22:57:26 (+02:00) schreef Adrian Chadd:

> The branch main has been updated by adrian:
> > URL: https://cgit.FreeBSD.org/src/commit/?id=142cba958b7a6dd11e4257740db03d335475ede8


> commit 142cba958b7a6dd11e4257740db03d335475ede8
> Author:     Abdelkader Boudih <[email protected]>
> AuthorDate: 2026-06-14 20:55:33 +0000
> Commit:     Adrian Chadd <[email protected]>
> CommitDate: 2026-06-14 20:56:59 +0000
> > bge: read MAC from loader hint for boards without NVRAM/EEPROM > > BCM57766 on Apple T2 Macs (Macmini8,1) has no dedicated EEPROM and the
>     chip firmware handshake fails (the T2 intercepts PCI config space),
> leaving the SRAM mailbox unpopulated. All four existing MAC retrieval > paths (SRAM mailbox, NVRAM, EEPROM, firmware stub) fail, causing bge to
>     abort attach with "failed to read station address".
> > Work around this with two changes: > > 1. Tolerate EEPROM read failure on BCM57766. The chip is copper-only
>          so hwcfg=0 is correct; skip the fatal error that aborts attach
>          before bge_get_eaddr() is ever called.
> > 2. Implement bge_get_eaddr_fw() to read a "hint.bge.N.mac" string
>          (e.g. "f0:18:98:f4:1e:2f") from loader(8) tunable / kenv.
> > This is a workaround until the T2 BCE API is understood well enough to > either poke the chip firmware into completing its handshake or read the
>     MAC from the T2 directly.
> > Reviewed by: adrian
>     Differential Revision:  https://reviews.freebsd.org/D57090
> ---
>  sys/dev/bge/if_bge.c | 42 ++++++++++++++++++++++++++++++++++++------
>  1 file changed, 36 insertions(+), 6 deletions(-)
> > diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c
> index 3551f10b2ae3..1fbf8bfb7e93 100644
> --- a/sys/dev/bge/if_bge.c
> +++ b/sys/dev/bge/if_bge.c
> @@ -3766,11 +3766,19 @@ bge_attach(device_t dev)
>        (sc->bge_asicrev != BGE_ASICREV_BCM5906)) {
>            if (bge_read_eeprom(sc, (caddr_t)&hwcfg, BGE_EE_HWCFG_OFFSET,
>                sizeof(hwcfg))) {
> -                  device_printf(sc->bge_dev, "failed to read EEPROM\n");
> -                  error = ENXIO;
> -                  goto fail;
> -          }
> -          hwcfg = ntohl(hwcfg);
> +                  /*
> +                   * BCM57766 on Apple T2 Macs has no dedicated EEPROM;
> +                   * the chip is copper-only so hwcfg=0 is correct.
> +                   */
> +                  if (sc->bge_asicrev != BGE_ASICREV_BCM57766) {
> +                          device_printf(sc->bge_dev,
> +                              "failed to read EEPROM\n");
> +                          error = ENXIO;
> +                          goto fail;
> +                  }
> +                  hwcfg = 0;
> +          } else
> +                  hwcfg = ntohl(hwcfg);
>    }
> > /* The SysKonnect SK-9D41 is a 1000baseSX card. */
> @@ -6677,7 +6685,29 @@ bge_sysctl_mem_read(SYSCTL_HANDLER_ARGS)
>  static int
>  bge_get_eaddr_fw(struct bge_softc *sc, uint8_t ether_addr[])
>  {
> -  return (1);
> +  const char *mac_str;
> +  unsigned int o[ETHER_ADDR_LEN];
> +  char trail;
> +  int i, n, unit;
> +
> +  unit = device_get_unit(sc->bge_dev);
> +  if (resource_string_value("bge", unit, "mac", &mac_str) != 0)
> +          return (1);
> +
> +  /* Parse and validate; trailing-char check rejects garbage. */
> +  n = sscanf(mac_str, "%x:%x:%x:%x:%x:%x%c",
> +      &o[0], &o[1], &o[2], &o[3], &o[4], &o[5], &trail);
> +  if (n != 6)
> +          return (1);
> +  for (i = 0; i < ETHER_ADDR_LEN; i++) {
> +          if (o[i] > 0xff)
> +                  return (1);
> +          ether_addr[i] = (uint8_t)o[i];
> +  }
> +  if (ETHER_IS_MULTICAST(ether_addr) ||
> +      ETHER_IS_ZERO(ether_addr))
> +          return (1);
> +  return (0);
>  }
> > static int > >

If no hint is set you can also fall back to ether_gen_addr(9). Or the undocumented ether_gen_addr_byname().

sys/net/if_ethersubr.c:ether_gen_addr_byname(const char *nameunit, struct ether_addr *hwaddr) sys/net/if_ethersubr.c:ether_gen_addr(struct ifnet *ifp, struct ether_addr *hwaddr)

Regards,
Ronald.

Reply via email to