The PCI revision numbers are unique to a PCI vendor/product

ID pair.  Misuse of the revision numbers was causing some of the chip
features to be disabled on some integrated Intel chips.  So, move the
determination of the features into the bus frontend, where the
vendor/product ID is known.  (Note: sc_rev should be removed.  The
microcode patch stuff is also busted and needs to be fixed.)  Also,
poll the actual flow control status in inphy, rather than making
assumptions.

contributed anonymously.
This commit is contained in:
mrg 2009-01-18 10:37:03 +00:00
parent 7e0b2295e7
commit 71e27a6efb
5 changed files with 37 additions and 76 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fxp_cardbus.c,v 1.34 2008/07/09 17:07:28 joerg Exp $ */
/* $NetBSD: if_fxp_cardbus.c,v 1.35 2009/01/18 10:37:03 mrg Exp $ */
/*
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_fxp_cardbus.c,v 1.34 2008/07/09 17:07:28 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_fxp_cardbus.c,v 1.35 2009/01/18 10:37:03 mrg Exp $");
#include "opt_inet.h"
#include "bpfilter.h"
@ -164,6 +164,12 @@ fxp_cardbus_attach(struct device *parent, struct device *self,
else
printf("\n");
sc->sc_rev = CARDBUS_REVISION(ca->ca_class);
if (sc->sc_rev >= FXP_REV_82558_A4)
sc->sc_flags |= FXPF_FC|FXPF_EXT_TXCB;
if (sc->sc_rev >= FXP_REV_82550)
sc->sc_flags |= FXPF_EXT_RFA|FXPF_IPCB;
sc->sc_dmat = ca->ca_dmat;
sc->sc_enable = fxp_cardbus_enable;
sc->sc_disable = fxp_cardbus_disable;

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82557.c,v 1.121 2008/12/05 11:17:38 tsutsui Exp $ */
/* $NetBSD: i82557.c,v 1.122 2009/01/18 10:37:04 mrg Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2001, 2002 The NetBSD Foundation, Inc.
@ -66,7 +66,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.121 2008/12/05 11:17:38 tsutsui Exp $");
__KERNEL_RCSID(0, "$NetBSD: i82557.c,v 1.122 2009/01/18 10:37:04 mrg Exp $");
#include "bpfilter.h"
#include "rnd.h"
@ -262,26 +262,16 @@ fxp_attach(struct fxp_softc *sc)
callout_init(&sc->sc_callout, 0);
/*
* Enable some good stuff on i82558 and later.
*/
if (sc->sc_rev >= FXP_REV_82558_A4) {
/* Enable the extended TxCB. */
sc->sc_flags |= FXPF_EXT_TXCB;
}
/*
* Enable use of extended RFDs and TCBs for 82550
* and later chips. Note: we need extended TXCB support
* too, but that's already enabled by the code above.
* Be careful to do this only on the right devices.
*/
if (sc->sc_rev == FXP_REV_82550 || sc->sc_rev == FXP_REV_82550_C) {
sc->sc_flags |= FXPF_EXT_RFA | FXPF_IPCB;
if (sc->sc_flags & FXPF_IPCB)
sc->sc_txcmd = htole16(FXP_CB_COMMAND_IPCBXMIT);
} else {
else
sc->sc_txcmd = htole16(FXP_CB_COMMAND_XMIT);
}
sc->sc_rfa_size =
(sc->sc_flags & FXPF_EXT_RFA) ? RFA_EXT_SIZE : RFA_SIZE;
@ -426,7 +416,7 @@ fxp_attach(struct fxp_softc *sc)
NULL, device_xname(sc->sc_dev), "txintr");
evcnt_attach_dynamic(&sc->sc_ev_rxintr, EVCNT_TYPE_INTR,
NULL, device_xname(sc->sc_dev), "rxintr");
if (sc->sc_rev >= FXP_REV_82558_A4) {
if (sc->sc_flags & FXPF_FC) {
evcnt_attach_dynamic(&sc->sc_ev_txpause, EVCNT_TYPE_MISC,
NULL, device_xname(sc->sc_dev), "txpause");
evcnt_attach_dynamic(&sc->sc_ev_rxpause, EVCNT_TYPE_MISC,
@ -483,8 +473,8 @@ fxp_mii_initmedia(struct fxp_softc *sc)
fxp_mii_mediastatus);
flags = MIIF_NOISOLATE;
if (sc->sc_rev >= FXP_REV_82558_A4)
flags |= MIIF_DOPAUSE;
if (sc->sc_flags & FXPF_FC)
flags |= MIIF_FORCEANEG|MIIF_DOPAUSE;
/*
* The i82557 wedges if all of its PHYs are isolated!
*/
@ -1438,7 +1428,7 @@ fxp_tick(void *arg)
tx_threshold += 64;
}
#ifdef FXP_EVENT_COUNTERS
if (sc->sc_rev >= FXP_REV_82558_A4) {
if (sc->sc_flags & FXPF_FC) {
sc->sc_ev_txpause.ev_count += sp->tx_pauseframes;
sc->sc_ev_rxpause.ev_count += sp->rx_pauseframes;
}
@ -1486,7 +1476,7 @@ fxp_tick(void *arg)
sp->rx_alignment_errors = 0;
sp->rx_rnr_errors = 0;
sp->rx_overrun_errors = 0;
if (sc->sc_rev >= FXP_REV_82558_A4) {
if (sc->sc_flags & FXPF_FC) {
sp->tx_pauseframes = 0;
sp->rx_pauseframes = 0;
}
@ -1761,7 +1751,7 @@ fxp_init(struct ifnet *ifp)
cbp->ext_rx_mode = (sc->sc_flags & FXPF_EXT_RFA) ? 1 : 0;
cbp->vlan_drop_en = vlan_drop;
if (sc->sc_rev < FXP_REV_82558_A4) {
if (!(sc->sc_flags & FXPF_FC)) {
/*
* The i82557 has no hardware flow control, the values
* here are the defaults for the chip.
@ -1972,14 +1962,6 @@ fxp_mii_mediastatus(struct ifnet *ifp, struct ifmediareq *ifmr)
}
ether_mediastatus(ifp, ifmr);
/*
* XXX Flow control is always turned on if the chip supports
* XXX it; we can't easily control it dynamically, since it
* XXX requires sending a setup packet.
*/
if (sc->sc_rev >= FXP_REV_82558_A4)
ifmr->ifm_active |= IFM_FLOW|IFM_ETH_TXPAUSE|IFM_ETH_RXPAUSE;
}
int

View File

@ -1,4 +1,4 @@
/* $NetBSD: i82557var.h,v 1.41 2008/12/03 15:34:38 tsutsui Exp $ */
/* $NetBSD: i82557var.h,v 1.42 2009/01/18 10:37:04 mrg Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2001 The NetBSD Foundation, Inc.
@ -224,6 +224,7 @@ struct fxp_softc {
#define FXPF_EXT_RFA 0x0200 /* enable extended RFD */
#define FXPF_IPCB 0x0400 /* use IPCB */
#define FXPF_RECV_WORKAROUND 0x0800 /* receiver lock-up workaround */
#define FXPF_FC 0x1000 /* has flow control */
int sc_int_delay; /* interrupt delay */
int sc_bundle_max; /* max packet bundle */

View File

@ -1,4 +1,4 @@
/* $NetBSD: inphy.c,v 1.49 2008/11/17 03:04:27 dyoung Exp $ */
/* $NetBSD: inphy.c,v 1.50 2009/01/18 10:37:04 mrg Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: inphy.c,v 1.49 2008/11/17 03:04:27 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: inphy.c,v 1.50 2009/01/18 10:37:04 mrg Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -249,6 +249,7 @@ inphy_status(struct mii_softc *sc)
mii->mii_media_active |= IFM_NONE;
return;
}
scr = PHY_READ(sc, MII_INPHY_SCR);
if ((bmsr & BMSR_100T4) && (scr & SCR_T4))
mii->mii_media_active |= IFM_100_T4;
@ -258,6 +259,9 @@ inphy_status(struct mii_softc *sc)
mii->mii_media_active |= IFM_10_T;
if (scr & SCR_FDX)
mii->mii_media_active |= IFM_FDX;
if (mii->mii_media_active & IFM_FDX)
mii->mii_media_active |= mii_phy_flowstatus(sc);
} else
mii->mii_media_active = ife->ifm_media;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_fxp_pci.c,v 1.60 2008/07/09 17:07:28 joerg Exp $ */
/* $NetBSD: if_fxp_pci.c,v 1.61 2009/01/18 10:37:04 mrg Exp $ */
/*-
* Copyright (c) 1997, 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.60 2008/07/09 17:07:28 joerg Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_fxp_pci.c,v 1.61 2009/01/18 10:37:04 mrg Exp $");
#include "rnd.h"
@ -110,9 +110,9 @@ static const struct fxp_pci_product {
{ PCI_PRODUCT_INTEL_82801BA_LAN,
"Intel i82562 Ethernet" },
{ PCI_PRODUCT_INTEL_82801E_LAN_1,
"Intel i82559 Ethernet" },
"Intel i82801E Ethernet" },
{ PCI_PRODUCT_INTEL_82801E_LAN_2,
"Intel i82559 Ethernet" },
"Intel i82801E Ethernet" },
{ PCI_PRODUCT_INTEL_PRO_100_VE_0,
"Intel PRO/100 VE Network Controller" },
{ PCI_PRODUCT_INTEL_PRO_100_VE_1,
@ -335,6 +335,7 @@ fxp_pci_attach(device_t parent, device_t self, void *aux)
if (sc->sc_rev >= FXP_REV_82558_A4) {
chipname = "i82558 Ethernet";
sc->sc_flags |= FXPF_FC|FXPF_EXT_TXCB;
/*
* Enable the MWI command for memory writes.
*/
@ -345,8 +346,10 @@ fxp_pci_attach(device_t parent, device_t self, void *aux)
chipname = "i82559 Ethernet";
if (sc->sc_rev >= FXP_REV_82559S_A)
chipname = "i82559S Ethernet";
if (sc->sc_rev >= FXP_REV_82550)
if (sc->sc_rev >= FXP_REV_82550) {
chipname = "i82550 Ethernet";
sc->sc_flags |= FXPF_EXT_RFA|FXPF_IPCB;
}
/*
* Mark all i82559 and i82550 revisions as having
@ -361,16 +364,6 @@ fxp_pci_attach(device_t parent, device_t self, void *aux)
}
case PCI_PRODUCT_INTEL_82801BA_LAN:
aprint_normal(": %s, rev %d\n", fpp->fpp_name, sc->sc_rev);
/*
* The 82801BA Ethernet has a bug which requires us to send a
* NOP before a CU_RESUME if we're in 10baseT mode.
*/
if (fpp->fpp_prodid == PCI_PRODUCT_INTEL_82801BA_LAN)
sc->sc_flags |= FXPF_HAS_RESUME_BUG;
break;
case PCI_PRODUCT_INTEL_PRO_100_VE_0:
case PCI_PRODUCT_INTEL_PRO_100_VE_1:
case PCI_PRODUCT_INTEL_PRO_100_VM_0:
@ -380,41 +373,16 @@ fxp_pci_attach(device_t parent, device_t self, void *aux)
case PCI_PRODUCT_INTEL_82562EH_HPNA_2:
case PCI_PRODUCT_INTEL_PRO_100_VM_2:
aprint_normal(": %s, rev %d\n", fpp->fpp_name, sc->sc_rev);
sc->sc_flags |= FXPF_FC|FXPF_EXT_TXCB;
/*
* ICH3 chips apparently have problems with the enhanced
* features, so just treat them as an i82557. It also
* has the resume bug that the ICH2 has.
* The ICH-2 and ICH-3 have the "resume bug".
*/
sc->sc_rev = 1;
sc->sc_flags |= FXPF_HAS_RESUME_BUG;
break;
case PCI_PRODUCT_INTEL_82801E_LAN_1:
case PCI_PRODUCT_INTEL_82801E_LAN_2:
aprint_normal(": %s, rev %d\n", fpp->fpp_name, sc->sc_rev);
/*
* XXX We have to read the C-ICH's developer's manual
* in detail
*/
break;
case PCI_PRODUCT_INTEL_PRO_100_VE_2:
case PCI_PRODUCT_INTEL_PRO_100_VE_3:
case PCI_PRODUCT_INTEL_PRO_100_VE_4:
case PCI_PRODUCT_INTEL_PRO_100_VE_5:
case PCI_PRODUCT_INTEL_PRO_100_VM_3:
case PCI_PRODUCT_INTEL_PRO_100_VM_4:
case PCI_PRODUCT_INTEL_PRO_100_VM_5:
case PCI_PRODUCT_INTEL_PRO_100_VM_6:
case PCI_PRODUCT_INTEL_82801EB_LAN:
case PCI_PRODUCT_INTEL_82801FB_LAN:
case PCI_PRODUCT_INTEL_82801G_LAN:
default:
aprint_normal(": %s, rev %d\n", fpp->fpp_name, sc->sc_rev);
/*
* No particular quirks.
*/
sc->sc_flags |= FXPF_FC|FXPF_EXT_TXCB|FXPF_EXT_RFA|FXPF_IPCB;
break;
}