From e12405280b8252bb43da20098baace431a22f309 Mon Sep 17 00:00:00 2001 From: Marius Strobl Date: Wed, 2 Mar 2005 00:49:37 +0000 Subject: [PATCH] - Fix braino introduced in rev. 1.17, unlike the X1032A (HME-ISP1040-combo) and the X1034A (quad HME; QFE) cards the X1033A (single HME) don't have a PCI-PCI-bridge so we can't rely on the PCI slot number being useable as index for the network address to read from the VPD on the latter. Use the end tag to determine whether it is a QFE VPD with 4 NAs and only use the slot number as index in this case. - Remove a useless check. Prodded by: joerg Additional testing by: joerg MFC after: 1 day --- sys/dev/hme/if_hme_pci.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/dev/hme/if_hme_pci.c b/sys/dev/hme/if_hme_pci.c index 63bfbb22e001..929c2868d7cc 100644 --- a/sys/dev/hme/if_hme_pci.c +++ b/sys/dev/hme/if_hme_pci.c @@ -310,9 +310,14 @@ hme_pci_attach(device_t dev) * all-zero "checksum" byte. Sun calls this a "Fresh Choice * Ethernet" VPD... */ - bus_space_read_region_1(romt, romh, - vpdoff + slot * (3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN), - buf, sizeof(buf)); + /* Look at the end tag to determine whether this is a VPD with 4 NAs. */ + if (bus_space_read_1(romt, romh, + vpdoff + 3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN) != 0x79 && + bus_space_read_1(romt, romh, + vpdoff + 4 * (3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN)) == 0x79) + /* Use the Nth NA for the Nth HME on this SUNW,qfe. */ + vpdoff += slot * (3 + sizeof(struct pci_vpd) + ETHER_ADDR_LEN); + bus_space_read_region_1(romt, romh, vpdoff, buf, sizeof(buf)); vpd = (void *)(buf + 3); if (PCI_VPDRES_ISLARGE(buf[0]) == 0 || PCI_VPDRES_LARGE_NAME(buf[0]) != PCI_VPDRES_TYPE_VPD || @@ -324,11 +329,6 @@ hme_pci_attach(device_t dev) error = ENXIO; goto fail_rres; } - if (buf + 3 + sizeof(struct pci_vpd) == NULL) { - device_printf(dev, "could not read network address\n"); - error = ENXIO; - goto fail_rres; - } bcopy(buf + 3 + sizeof(struct pci_vpd), sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN);