Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-6]: src/sys/dev Pull up the following, requested by msaitoh in #1...
details: https://anonhg.NetBSD.org/src/rev/7809b2e8fcd3
branches: netbsd-6
changeset: 776816:7809b2e8fcd3
user: martin <martin%NetBSD.org@localhost>
date: Sun Dec 07 16:39:55 2014 +0000
description:
Pull up the following, requested by msaitoh in #1207:
sys/dev/mii/brgphy.c 1.69, 1.71-1.76 via patch
sys/dev/mii/brgphyreg.h 1.6-1.7, 1.9
sys/dev/pci/if_bge.c 1.259,1.267-1.276 via patch
sys/dev/pci/if_bgereg.h 1.87-1.88
sys/dev/pci/if_bnx.c 1.48, 1.49, 1.52-1.57 via patch
sys/dev/pci/if_bnxreg.h 1.15-1.18
sys/dev/pci/if_bnxvar.h 1.4-1.6
Changes for bge(4), bnx(4) and brgphy(4):
- Add device IDs for Broadcom BCM57710, BCM57711(E), BCM57712(E) and
BCM5719 into pcidevs.
- Change BCM5720's device ID from 0x1658 to 0x165f. 0x1658 is only for
the pre-product and not released to public.
- Fix detection of BGEPHYF_FIBER_{MII|TBI}
- Fix typo in comment.
- KNF
- brgphy(4):
- Add BCM5708S support.
- Add 2500SX support.
- Fix bit definition of BRGPHY_MRBE_MSG_PG5_NP_T2 from FreeBSD.
- Remove extra delay in brgphy_mii_phy_auto. Same as {Free,Open}BSD.
- Fix media detect on some Fiber chips.
- Add BCM5706.
- bge(4):
- Print yet another hardware config word in SRAM(BGE_SRAM_DATA_CFG_5)
for BCM5717 and newer devices.
- Fix a trivial bug in #ifdef NOTYET.
- Add BGEPHYF_NO_WIRESPEED flag for fiber devices.
- Print APE firmware correctly.
- Don't use the PHY Auto Poll Mode on many chips. This fixes a bug
that MII Fiber NIC drop packets about 50%. Same as {Free,Open}BSD.
Tested on HP Moonshot.
- Add workaround for PR#48451. Some BCM5717-5720 based systems get
NMI on boot. This problem doesn't occur when we don't use
prefetchable memory in the APE area. I don't know the reason...
Tested with HP MicroServer Gen8.
- Fix a bug that bge can't be initialized correctly on some sparc64
systems (PR#49018).
- Change initializaton order as the same as the document, Linux tg3
and FreeBSD (part of r241436).
- In the BCM5703, the DMA read watermark should be set to less than
or equal to the maximum memory read byte count of the PCI-X command
register. Same as FreeBSD r204978 and Linux tg3 driver.
- bnx(4):
- Enclose #ifdef BNX_DEBUG correctly.
- Add 2500SX support.
- Print some information (ASCI revision, PCI status, etc).
From FreeBSD.
diffstat:
sys/dev/mii/brgphy.c | 486 ++++++++++++++++++++---------
sys/dev/mii/brgphyreg.h | 47 +--
sys/dev/pci/if_bge.c | 130 ++++++--
sys/dev/pci/if_bgereg.h | 5 +-
sys/dev/pci/if_bnx.c | 761 +++++++++++++++++++++++++++--------------------
sys/dev/pci/if_bnxreg.h | 456 ++++++++++++++--------------
sys/dev/pci/if_bnxvar.h | 293 +++++++++--------
7 files changed, 1254 insertions(+), 924 deletions(-)
diffs (truncated from 4406 to 300 lines):
diff -r b8560d2bdb55 -r 7809b2e8fcd3 sys/dev/mii/brgphy.c
--- a/sys/dev/mii/brgphy.c Sun Dec 07 16:37:38 2014 +0000
+++ b/sys/dev/mii/brgphy.c Sun Dec 07 16:39:55 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: brgphy.c,v 1.59.8.6 2014/11/09 12:13:15 martin Exp $ */
+/* $NetBSD: brgphy.c,v 1.59.8.7 2014/12/07 16:39:55 martin Exp $ */
/*-
* Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.59.8.6 2014/11/09 12:13:15 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: brgphy.c,v 1.59.8.7 2014/12/07 16:39:55 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -90,8 +90,10 @@
struct mii_softc sc_mii;
bool sc_isbge;
bool sc_isbnx;
- uint32_t sc_chipid; /* parent's chipid */
- uint32_t sc_phyflags; /* parent's phyflags */
+ uint32_t sc_chipid; /* parent's chipid */
+ uint32_t sc_phyflags; /* parent's phyflags */
+ uint32_t sc_shared_hwcfg; /* shared hw config */
+ uint32_t sc_port_hwcfg; /* port specific hw config */
};
CFATTACH_DECL3_NEW(brgphy, sizeof(struct brgphy_softc),
@@ -99,7 +101,10 @@
DVF_DETACH_SHUTDOWN);
static int brgphy_service(struct mii_softc *, struct mii_data *, int);
-static void brgphy_status(struct mii_softc *);
+static void brgphy_copper_status(struct mii_softc *);
+static void brgphy_fiber_status(struct mii_softc *);
+static void brgphy_5708s_status(struct mii_softc *);
+static void brgphy_5709s_status(struct mii_softc *);
static int brgphy_mii_phy_auto(struct mii_softc *);
static void brgphy_loop(struct mii_softc *);
static void brgphy_reset(struct mii_softc *);
@@ -116,8 +121,20 @@
static void brgphy_eth_wirespeed(struct mii_softc *);
-static const struct mii_phy_funcs brgphy_funcs = {
- brgphy_service, brgphy_status, brgphy_reset,
+static const struct mii_phy_funcs brgphy_copper_funcs = {
+ brgphy_service, brgphy_copper_status, brgphy_reset,
+};
+
+static const struct mii_phy_funcs brgphy_fiber_funcs = {
+ brgphy_service, brgphy_fiber_status, brgphy_reset,
+};
+
+static const struct mii_phy_funcs brgphy_5708s_funcs = {
+ brgphy_service, brgphy_5708s_status, brgphy_reset,
+};
+
+static const struct mii_phy_funcs brgphy_5709s_funcs = {
+ brgphy_service, brgphy_5709s_status, brgphy_reset,
};
static const struct mii_phydesc brgphys[] = {
@@ -157,6 +174,9 @@
{ MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5705,
MII_STR_BROADCOM_BCM5705 },
+ { MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5706,
+ MII_STR_BROADCOM_BCM5706 },
+
{ MII_OUI_BROADCOM, MII_MODEL_BROADCOM_BCM5714,
MII_STR_BROADCOM_BCM5714 },
@@ -178,6 +198,9 @@
{ MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5482,
MII_STR_BROADCOM2_BCM5482 },
+ { MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5708S,
+ MII_STR_BROADCOM2_BCM5708S },
+
{ MII_OUI_BROADCOM2, MII_MODEL_BROADCOM2_BCM5709C,
MII_STR_BROADCOM2_BCM5709C },
@@ -264,15 +287,14 @@
sc->mii_pdata = mii;
sc->mii_flags = ma->mii_flags;
sc->mii_anegticks = MII_ANEGTICKS;
- sc->mii_funcs = &brgphy_funcs;
if (device_is_a(parent, "bge"))
bsc->sc_isbge = true;
else if (device_is_a(parent, "bnx"))
bsc->sc_isbnx = true;
+ dict = device_properties(parent);
if (bsc->sc_isbge || bsc->sc_isbnx) {
- dict = device_properties(parent);
if (!prop_dictionary_get_uint32(dict, "phyflags",
&bsc->sc_phyflags))
aprint_error_dev(self, "failed to get phyflags\n");
@@ -281,48 +303,73 @@
aprint_error_dev(self, "failed to get chipid\n");
}
+ if (bsc->sc_isbnx) {
+ /* Currently, only bnx use sc_shared_hwcfg and sc_port_hwcfg */
+ if (!prop_dictionary_get_uint32(dict, "shared_hwcfg",
+ &bsc->sc_shared_hwcfg))
+ aprint_error_dev(self, "failed to get shared_hwcfg\n");
+ if (!prop_dictionary_get_uint32(dict, "port_hwcfg",
+ &bsc->sc_port_hwcfg))
+ aprint_error_dev(self, "failed to get port_hwcfg\n");
+ }
+
+ if (sc->mii_flags & MIIF_HAVEFIBER) {
+ if ((sc->mii_mpd_oui == MII_OUI_BROADCOM2)
+ && sc->mii_mpd_model == MII_MODEL_BROADCOM2_BCM5708S)
+ sc->mii_funcs = &brgphy_5708s_funcs;
+ else if ((sc->mii_mpd_oui == MII_OUI_BROADCOM2)
+ && (sc->mii_mpd_model == MII_MODEL_BROADCOM2_BCM5709S)) {
+ if (bsc->sc_isbnx)
+ sc->mii_funcs = &brgphy_5709s_funcs;
+ else {
+ /*
+ * XXX
+ * 5720S and 5709S shares the same PHY id.
+ * Assume 5720S PHY if parent device is bge(4).
+ */
+ sc->mii_funcs = &brgphy_5708s_funcs;
+ }
+ } else
+ sc->mii_funcs = &brgphy_fiber_funcs;
+ } else
+ sc->mii_funcs = &brgphy_copper_funcs;
+
PHY_RESET(sc);
- sc->mii_capabilities =
- PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
+ sc->mii_capabilities = PHY_READ(sc, MII_BMSR) & ma->mii_capmask;
if (sc->mii_capabilities & BMSR_EXTSTAT)
sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR);
aprint_normal_dev(self, "");
- if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
- (sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
- aprint_error("no media present");
- else {
- if (sc->mii_flags & MIIF_HAVEFIBER) {
- sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
+ if (sc->mii_flags & MIIF_HAVEFIBER) {
+ sc->mii_flags |= MIIF_NOISOLATE | MIIF_NOLOOP;
+ /*
+ * Set the proper bits for capabilities so that the
+ * correct media get selected by mii_phy_add_media()
+ */
+ sc->mii_capabilities |= BMSR_ANEG;
+ sc->mii_capabilities &= ~BMSR_100T4;
+ sc->mii_extcapabilities |= EXTSR_1000XFDX;
+
+ if (bsc->sc_isbnx) {
/*
- * Set the proper bits for capabilities so that the
- * correct media get selected by mii_phy_add_media()
+ * 2.5Gb support is a software enabled feature
+ * on the BCM5708S and BCM5709S controllers.
*/
- sc->mii_capabilities |= BMSR_ANEG;
- sc->mii_capabilities &= ~BMSR_100T4;
- sc->mii_extcapabilities |= EXTSR_1000XFDX;
-
- if (bsc->sc_isbnx) {
- /*
- * 2.5Gb support is a software enabled feature
- * on the BCM5708S and BCM5709S controllers.
- */
#define ADD(m, c) ifmedia_add(&mii->mii_media, (m), (c), NULL)
- if (bsc->sc_phyflags
- & BNX_PHY_2_5G_CAPABLE_FLAG) {
- ADD(IFM_MAKEWORD(IFM_ETHER, IFM_2500_SX,
- IFM_FDX, sc->mii_inst), 0);
- aprint_normal("2500baseSX-FDX, ");
+ if (bsc->sc_phyflags
+ & BNX_PHY_2_5G_CAPABLE_FLAG) {
+ ADD(IFM_MAKEWORD(IFM_ETHER, IFM_2500_SX,
+ IFM_FDX, sc->mii_inst), 0);
+ aprint_normal("2500baseSX-FDX, ");
#undef ADD
- }
}
}
- mii_phy_add_media(sc);
}
+ mii_phy_add_media(sc);
+
aprint_normal("\n");
-
}
static int
@@ -333,9 +380,7 @@
switch (cmd) {
case MII_POLLSTAT:
- /*
- * If we're not polling our PHY instance, just return.
- */
+ /* If we're not polling our PHY instance, just return. */
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
return (0);
break;
@@ -351,9 +396,7 @@
return (0);
}
- /*
- * If the interface is not up, don't do anything.
- */
+ /* If the interface is not up, don't do anything. */
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
break;
@@ -363,6 +406,10 @@
case IFM_AUTO:
(void) brgphy_mii_phy_auto(sc);
break;
+ case IFM_2500_SX:
+ speed = BRGPHY_5708S_BMCR_2500;
+ goto setit;
+ case IFM_1000_SX:
case IFM_1000_T:
speed = BMCR_S1000;
goto setit;
@@ -376,15 +423,16 @@
if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) {
speed |= BMCR_FDX;
gig = GTCR_ADV_1000TFDX;
- } else {
+ } else
gig = GTCR_ADV_1000THDX;
- }
PHY_WRITE(sc, MII_100T2CR, 0);
PHY_WRITE(sc, MII_ANAR, ANAR_CSMA);
PHY_WRITE(sc, MII_BMCR, speed);
- if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)
+ if ((IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) &&
+ (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_SX) &&
+ (IFM_SUBTYPE(ife->ifm_media) != IFM_2500_SX))
break;
PHY_WRITE(sc, MII_100T2CR, gig);
@@ -405,21 +453,15 @@
break;
case MII_TICK:
- /*
- * If we're not currently selected, just return.
- */
+ /* If we're not currently selected, just return. */
if (IFM_INST(ife->ifm_media) != sc->mii_inst)
return (0);
- /*
- * Is the interface even up?
- */
+ /* Is the interface even up? */
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
return 0;
- /*
- * Only used for autonegotiation.
- */
+ /* Only used for autonegotiation. */
if ((IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) &&
(IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T)) {
sc->mii_ticks = 0;
@@ -444,9 +486,7 @@
if (sc->mii_ticks++ == 0)
break;
- /*
- * Only retry autonegotiation every mii_anegticks seconds.
- */
+ /* Only retry autonegotiation every mii_anegticks seconds. */
KASSERT(sc->mii_anegticks != 0);
if (sc->mii_ticks <= sc->mii_anegticks)
break;
@@ -493,7 +533,7 @@
}
static void
-brgphy_status(struct mii_softc *sc)
+brgphy_copper_status(struct mii_softc *sc)
{
Home |
Main Index |
Thread Index |
Old Index