Port-sgimips archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: R10k O2
On Mon, Feb 25, 2008 at 09:32:52PM +0100, Martin Husemann wrote:
> Nope, it doesn't (or better: they don't persist). I'll borrow some code
> to create a random mac id from tap(4).
Hmm, the tap(4) strategy does not work very well (uptime too short and
deterministic) - I cam up with the evil hack below.
Martin
Index: if_mec.c
===================================================================
RCS file: /cvsroot/src/sys/arch/sgimips/mace/if_mec.c,v
retrieving revision 1.17
diff -c -u -r1.17 if_mec.c
--- if_mec.c 26 Jan 2008 14:28:49 -0000 1.17
+++ if_mec.c 25 Feb 2008 21:39:28 -0000
@@ -452,7 +452,41 @@
printf(": unable to get MAC address!\n");
goto fail_4;
}
- enaddr_aton(macaddr, sc->sc_enaddr);
+ /*
+ * On some machines the DS2502 chip storing the serial number/
+ * mac address is on the pci riser board - if this board is
+ * missing, ARCBIOS will not know a good ethernet address (but
+ * otherwise the machine will work fine).
+ */
+ if (strcmp(macaddr, "ff:ff:ff:ff:ff:ff") == 0) {
+ uint32_t ui = 0;
+ const char * netaddr =
+ ARCBIOS->GetEnvironmentVariable("netaddr");
+
+ /*
+ * Create a MAC address by abusing the "netaddr" env var
+ */
+ sc->sc_enaddr[0] = 0xf2;
+ sc->sc_enaddr[1] = 0x0b;
+ sc->sc_enaddr[2] = 0xa4;
+ if (netaddr) {
+ while (*netaddr) {
+ int v = 0;
+ while (*netaddr && *netaddr != '.') {
+ if (*netaddr >= '0' && *netaddr <= '9')
+ v = v*10 + (*netaddr - '0');
+ netaddr++;
+ }
+ ui <<= 8;
+ ui |= v;
+ if (*netaddr == '.')
+ netaddr++;
+ }
+ }
+ memcpy(sc->sc_enaddr+3, (u_int8_t *)&ui, 3);
+ } else {
+ enaddr_aton(macaddr, sc->sc_enaddr);
+ }
/* set the Ethernet address */
address = 0;
Home |
Main Index |
Thread Index |
Old Index