Force a reload of the EEPROM if the MAC address is all zeroes.

Fixes PR kern/34812.
This commit is contained in:
scw 2006-10-20 10:31:06 +00:00
parent a2fafc1061
commit d269f28650
1 changed files with 13 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_vr.c,v 1.77 2006/10/12 01:31:30 christos Exp $ */
/* $NetBSD: if_vr.c,v 1.78 2006/10/20 10:31:06 scw Exp $ */
/*-
* Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@ -104,7 +104,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.77 2006/10/12 01:31:30 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_vr.c,v 1.78 2006/10/20 10:31:06 scw Exp $");
#include "rnd.h"
@ -1455,7 +1455,7 @@ vr_attach(struct device *parent __unused, struct device *self, void *aux)
struct vr_type *vrt;
u_int32_t reg;
struct ifnet *ifp;
u_char eaddr[ETHER_ADDR_LEN];
u_char eaddr[ETHER_ADDR_LEN], mac;
int i, rseg, error;
#define PCI_CONF_WRITE(r, v) pci_conf_write(sc->vr_pc, sc->vr_tag, (r), (v))
@ -1582,14 +1582,20 @@ vr_attach(struct device *parent __unused, struct device *self, void *aux)
* (and the lack of anyone else noticing the problems this
* causes) I'm going to retain the old behaviour for the
* other parts.
* In some cases, the chip really does startup without having
* read the EEPROM (kern/34812). To handle this case, we force
* a reload if we see an all-zeroes MAC address.
*/
if (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6105 &&
PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6102) {
for (mac = 0, i = 0; i < ETHER_ADDR_LEN; i++)
mac |= (eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i));
if (mac == 0 || (PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6105 &&
PCI_PRODUCT(pa->pa_id) != PCI_PRODUCT_VIATECH_VT6102)) {
VR_SETBIT(sc, VR_EECSR, VR_EECSR_LOAD);
DELAY(200);
for (i = 0; i < ETHER_ADDR_LEN; i++)
eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i);
}
for (i = 0; i < ETHER_ADDR_LEN; i++)
eaddr[i] = CSR_READ_1(sc, VR_PAR0 + i);
/*
* A Rhine chip was detected. Inform the world.