Module Name: src Committed By: phx Date: Tue Mar 8 19:06:59 UTC 2011
Modified Files: src/sys/dev/pci: if_stge.c Log Message: On the ST1023 (and compatible, like IP1000A), the mac-address can also be passed via device properties, when the serial EEPROM is missing or empty. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/sys/dev/pci/if_stge.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/if_stge.c diff -u src/sys/dev/pci/if_stge.c:1.51 src/sys/dev/pci/if_stge.c:1.52 --- src/sys/dev/pci/if_stge.c:1.51 Sat Nov 13 13:52:07 2010 +++ src/sys/dev/pci/if_stge.c Tue Mar 8 19:06:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: if_stge.c,v 1.51 2010/11/13 13:52:07 uebayasi Exp $ */ +/* $NetBSD: if_stge.c,v 1.52 2011/03/08 19:06:58 phx Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.51 2010/11/13 13:52:07 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.52 2011/03/08 19:06:58 phx Exp $"); #include <sys/param.h> @@ -70,6 +70,8 @@ #include <dev/pci/if_stgereg.h> +#include <prop/proplib.h> + /* #define STGE_CU_BUG 1 */ #define STGE_VLAN_UNTAG 1 /* #define STGE_VLAN_CFI 1 */ @@ -379,6 +381,7 @@ bus_space_tag_t iot, memt; bus_space_handle_t ioh, memh; bus_dma_segment_t seg; + prop_data_t data; int ioh_valid, memh_valid; int i, rseg, error; const struct stge_product *sp; @@ -557,13 +560,27 @@ STGE_StationAddress2) >> 8; sc->sc_stge1023 = 0; } else { - uint16_t myaddr[ETHER_ADDR_LEN / 2]; - for (i = 0; i <ETHER_ADDR_LEN / 2; i++) { - stge_read_eeprom(sc, STGE_EEPROM_StationAddress0 + i, - &myaddr[i]); - myaddr[i] = le16toh(myaddr[i]); + data = prop_dictionary_get(device_properties(self), + "mac-address"); + if (data != NULL) { + /* + * Try to get the station address from device + * properties first, in case the EEPROM is missing. + */ + KASSERT(prop_object_type(data) == PROP_TYPE_DATA); + KASSERT(prop_data_size(data) == ETHER_ADDR_LEN); + (void)memcpy(enaddr, prop_data_data_nocopy(data), + ETHER_ADDR_LEN); + } else { + uint16_t myaddr[ETHER_ADDR_LEN / 2]; + for (i = 0; i <ETHER_ADDR_LEN / 2; i++) { + stge_read_eeprom(sc, + STGE_EEPROM_StationAddress0 + i, + &myaddr[i]); + myaddr[i] = le16toh(myaddr[i]); + } + (void)memcpy(enaddr, myaddr, sizeof(enaddr)); } - (void)memcpy(enaddr, myaddr, sizeof(enaddr)); sc->sc_stge1023 = 1; }