diff options
author | raj <raj@FreeBSD.org> | 2008-03-12 16:32:08 +0000 |
---|---|---|
committer | raj <raj@FreeBSD.org> | 2008-03-12 16:32:08 +0000 |
commit | 8e81cff1fea20b1d0d53988daff826286c50640c (patch) | |
tree | bee3dfa13f4fb01fa9d5de6630099aac13d777f4 /sys/dev/tsec/if_tsec.c | |
parent | 054d727b12bc095749d9c28ef9354f5aab773391 (diff) | |
download | FreeBSD-src-8e81cff1fea20b1d0d53988daff826286c50640c.zip FreeBSD-src-8e81cff1fea20b1d0d53988daff826286c50640c.tar.gz |
Obtain TSEC h/w address from the parent bus (OCP) and not rely blindly on what
might be currently programmed into the registers.
Underlying firmware (U-Boot) would typically program MAC address into the
first unit only, and others are left uninitialized. It is now possible to
retrieve and program MAC address for all units properly, provided they were
passed on in the bootinfo metadata.
Reviewed by: imp, marcel
Approved by: cognet (mentor)
Diffstat (limited to 'sys/dev/tsec/if_tsec.c')
-rw-r--r-- | sys/dev/tsec/if_tsec.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/sys/dev/tsec/if_tsec.c b/sys/dev/tsec/if_tsec.c index 8ea171a..ccee8f7 100644 --- a/sys/dev/tsec/if_tsec.c +++ b/sys/dev/tsec/if_tsec.c @@ -170,22 +170,26 @@ tsec_get_hwaddr(struct tsec_softc *sc, uint8_t *addr) uint8_t addr[6]; } curmac; uint32_t a[6]; - int count, i; - char *cp; + device_t parent; + uintptr_t macaddr; + int i; + + parent = device_get_parent(sc->dev); + if (BUS_READ_IVAR(parent, sc->dev, OCPBUS_IVAR_MACADDR, + &macaddr) == 0) { + bcopy((uint8_t *)macaddr, addr, 6); + return; + } - /* Use the currently programmed MAC address by default. */ + /* + * Fall back -- use the currently programmed address in the hope that + * it was set be firmware... + */ curmac.reg[0] = TSEC_READ(sc, TSEC_REG_MACSTNADDR1); curmac.reg[1] = TSEC_READ(sc, TSEC_REG_MACSTNADDR2); for (i = 0; i < 6; i++) a[5-i] = curmac.addr[i]; - cp = getenv("ethaddr"); - if (cp != NULL) { - count = sscanf(cp, "%x:%x:%x:%x:%x:%x", &a[0], &a[1], &a[2], - &a[3], &a[4], &a[5]); - freeenv(cp); - } - addr[0] = a[0]; addr[1] = a[1]; addr[2] = a[2]; |