diff options
author | Chris Kuethe <ckuethe@cvs.openbsd.org> | 2007-09-01 19:19:40 +0000 |
---|---|---|
committer | Chris Kuethe <ckuethe@cvs.openbsd.org> | 2007-09-01 19:19:40 +0000 |
commit | 8b2d7ba1f3b200ac03db469f8f4535c1103aeb03 (patch) | |
tree | afc2f085e96bb086c1e970f07211f80d157774e9 /sys/dev/pci | |
parent | ec24840b6666724b7c844cbdfcb46b1412511315 (diff) |
Correct the backwards ethernet address that some NVidia MACs have.
diff from brad. "commit this" jsg
Diffstat (limited to 'sys/dev/pci')
-rw-r--r-- | sys/dev/pci/if_nfe.c | 54 | ||||
-rw-r--r-- | sys/dev/pci/if_nfevar.h | 13 |
2 files changed, 45 insertions, 22 deletions
diff --git a/sys/dev/pci/if_nfe.c b/sys/dev/pci/if_nfe.c index 4dfb809241f..4e959ec392e 100644 --- a/sys/dev/pci/if_nfe.c +++ b/sys/dev/pci/if_nfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nfe.c,v 1.69 2007/03/02 00:16:59 jsg Exp $ */ +/* $OpenBSD: if_nfe.c,v 1.70 2007/09/01 19:19:39 ckuethe Exp $ */ /*- * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> @@ -150,7 +150,11 @@ const struct pci_matchid nfe_devices[] = { { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN1 }, { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN2 }, { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN3 }, - { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN4 } + { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP67_LAN4 }, + { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN1 }, + { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN2 }, + { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN3 }, + { PCI_VENDOR_NVIDIA, PCI_PRODUCT_NVIDIA_MCP73_LAN4 } }; int @@ -203,10 +207,6 @@ nfe_attach(struct device *parent, struct device *self, void *aux) printf(": %s", intrstr); sc->sc_dmat = pa->pa_dmat; - - nfe_get_macaddr(sc, sc->sc_arpcom.ac_enaddr); - printf(", address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr)); - sc->sc_flags = 0; switch (PCI_PRODUCT(pa->pa_id)) { @@ -218,6 +218,8 @@ nfe_attach(struct device *parent, struct device *self, void *aux) break; case PCI_PRODUCT_NVIDIA_MCP51_LAN1: case PCI_PRODUCT_NVIDIA_MCP51_LAN2: + sc->sc_flags |= NFE_40BIT_ADDR; + break; case PCI_PRODUCT_NVIDIA_MCP61_LAN1: case PCI_PRODUCT_NVIDIA_MCP61_LAN2: case PCI_PRODUCT_NVIDIA_MCP61_LAN3: @@ -226,7 +228,11 @@ nfe_attach(struct device *parent, struct device *self, void *aux) case PCI_PRODUCT_NVIDIA_MCP67_LAN2: case PCI_PRODUCT_NVIDIA_MCP67_LAN3: case PCI_PRODUCT_NVIDIA_MCP67_LAN4: - sc->sc_flags |= NFE_40BIT_ADDR; + case PCI_PRODUCT_NVIDIA_MCP73_LAN1: + case PCI_PRODUCT_NVIDIA_MCP73_LAN2: + case PCI_PRODUCT_NVIDIA_MCP73_LAN3: + case PCI_PRODUCT_NVIDIA_MCP73_LAN4: + sc->sc_flags |= NFE_40BIT_ADDR | NFE_CORRECT_MACADDR; break; case PCI_PRODUCT_NVIDIA_CK804_LAN1: case PCI_PRODUCT_NVIDIA_CK804_LAN2: @@ -238,7 +244,7 @@ nfe_attach(struct device *parent, struct device *self, void *aux) case PCI_PRODUCT_NVIDIA_MCP65_LAN2: case PCI_PRODUCT_NVIDIA_MCP65_LAN3: case PCI_PRODUCT_NVIDIA_MCP65_LAN4: - sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR; + sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_CORRECT_MACADDR; break; case PCI_PRODUCT_NVIDIA_MCP55_LAN1: case PCI_PRODUCT_NVIDIA_MCP55_LAN2: @@ -251,6 +257,9 @@ nfe_attach(struct device *parent, struct device *self, void *aux) if (sc->sc_flags & NFE_JUMBO_SUP) sc->sc_flags |= NFE_USE_JUMBO; + nfe_get_macaddr(sc, sc->sc_arpcom.ac_enaddr); + printf(", address %s\n", ether_sprintf(sc->sc_arpcom.ac_enaddr)); + /* * Allocate Tx and Rx rings. */ @@ -1725,15 +1734,28 @@ nfe_get_macaddr(struct nfe_softc *sc, uint8_t *addr) { uint32_t tmp; - tmp = NFE_READ(sc, NFE_MACADDR_LO); - addr[0] = (tmp >> 8) & 0xff; - addr[1] = (tmp & 0xff); + if (sc->sc_flags & NFE_CORRECT_MACADDR) { + tmp = NFE_READ(sc, NFE_MACADDR_HI); + addr[0] = (tmp & 0xff); + addr[1] = (tmp >> 8) & 0xff; + addr[2] = (tmp >> 16) & 0xff; + addr[3] = (tmp >> 24) & 0xff; + + tmp = NFE_READ(sc, NFE_MACADDR_LO); + addr[4] = (tmp & 0xff); + addr[5] = (tmp >> 8) & 0xff; - tmp = NFE_READ(sc, NFE_MACADDR_HI); - addr[2] = (tmp >> 24) & 0xff; - addr[3] = (tmp >> 16) & 0xff; - addr[4] = (tmp >> 8) & 0xff; - addr[5] = (tmp & 0xff); + } else { + tmp = NFE_READ(sc, NFE_MACADDR_LO); + addr[0] = (tmp >> 8) & 0xff; + addr[1] = (tmp & 0xff); + + tmp = NFE_READ(sc, NFE_MACADDR_HI); + addr[2] = (tmp >> 24) & 0xff; + addr[3] = (tmp >> 16) & 0xff; + addr[4] = (tmp >> 8) & 0xff; + addr[5] = (tmp & 0xff); + } } void diff --git a/sys/dev/pci/if_nfevar.h b/sys/dev/pci/if_nfevar.h index 2142b751783..d9d6c051f00 100644 --- a/sys/dev/pci/if_nfevar.h +++ b/sys/dev/pci/if_nfevar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_nfevar.h,v 1.11 2006/02/19 13:57:02 damien Exp $ */ +/* $OpenBSD: if_nfevar.h,v 1.12 2007/09/01 19:19:39 ckuethe Exp $ */ /*- * Copyright (c) 2005 Jonathan Gray <jsg@openbsd.org> @@ -77,11 +77,12 @@ struct nfe_softc { int sc_if_flags; u_int sc_flags; -#define NFE_JUMBO_SUP 0x01 -#define NFE_40BIT_ADDR 0x02 -#define NFE_HW_CSUM 0x04 -#define NFE_HW_VLAN 0x08 -#define NFE_USE_JUMBO 0x10 +#define NFE_JUMBO_SUP 0x01 +#define NFE_40BIT_ADDR 0x02 +#define NFE_HW_CSUM 0x04 +#define NFE_HW_VLAN 0x08 +#define NFE_USE_JUMBO 0x10 +#define NFE_CORRECT_MACADDR 0x20 uint32_t rxtxctl; uint8_t mii_phyaddr; |