Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci On the ST1023 (and compatible, like IP1000A), th...
details: https://anonhg.NetBSD.org/src/rev/aa1220e98640
branches: trunk
changeset: 763033:aa1220e98640
user: phx <phx%NetBSD.org@localhost>
date: Tue Mar 08 19:06:58 2011 +0000
description:
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.
diffstat:
sys/dev/pci/if_stge.c | 33 +++++++++++++++++++++++++--------
1 files changed, 25 insertions(+), 8 deletions(-)
diffs (69 lines):
diff -r edc6d6909a17 -r aa1220e98640 sys/dev/pci/if_stge.c
--- a/sys/dev/pci/if_stge.c Tue Mar 08 19:00:38 2011 +0000
+++ b/sys/dev/pci/if_stge.c Tue Mar 08 19:06:58 2011 +0000
@@ -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;
}
Home |
Main Index |
Thread Index |
Old Index