Fix a bug that non-GMII devices don't send a routing message when the link

status is changed. Call if_link_state_change(). Tested with 82572EI(TBI) and
I350(SERDES).

XXX pullup-[67].
This commit is contained in:
msaitoh 2017-04-05 10:44:35 +00:00
parent e8a4523663
commit c930008140

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_wm.c,v 1.505 2017/03/24 10:39:10 knakahara Exp $ */
/* $NetBSD: if_wm.c,v 1.506 2017/04/05 10:44:35 msaitoh Exp $ */
/*
* Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@ -84,7 +84,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.505 2017/03/24 10:39:10 knakahara Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.506 2017/04/05 10:44:35 msaitoh Exp $");
#ifdef _KERNEL_OPT
#include "opt_net_mpsafe.h"
@ -8283,6 +8283,7 @@ wm_linkintr_gmii(struct wm_softc *sc, uint32_t icr)
static void
wm_linkintr_tbi(struct wm_softc *sc, uint32_t icr)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
uint32_t status;
DPRINTF(WM_DEBUG_LINK, ("%s: %s:\n", device_xname(sc->sc_dev),
@ -8315,10 +8316,12 @@ wm_linkintr_tbi(struct wm_softc *sc, uint32_t icr)
WMREG_OLD_FCRTL : WMREG_FCRTL,
sc->sc_fcrtl);
sc->sc_tbi_linkup = 1;
if_link_state_change(ifp, LINK_STATE_UP);
} else {
DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n",
device_xname(sc->sc_dev)));
sc->sc_tbi_linkup = 0;
if_link_state_change(ifp, LINK_STATE_DOWN);
}
/* Update LED */
wm_tbi_serdes_set_linkled(sc);
@ -8337,6 +8340,7 @@ wm_linkintr_tbi(struct wm_softc *sc, uint32_t icr)
static void
wm_linkintr_serdes(struct wm_softc *sc, uint32_t icr)
{
struct ifnet *ifp = &sc->sc_ethercom.ec_if;
struct mii_data *mii = &sc->sc_mii;
struct ifmedia_entry *ife = sc->sc_mii.mii_media.ifm_cur;
uint32_t pcs_adv, pcs_lpab, reg;
@ -8348,11 +8352,17 @@ wm_linkintr_serdes(struct wm_softc *sc, uint32_t icr)
/* Check PCS */
reg = CSR_READ(sc, WMREG_PCS_LSTS);
if ((reg & PCS_LSTS_LINKOK) != 0) {
DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> up\n",
device_xname(sc->sc_dev)));
mii->mii_media_status |= IFM_ACTIVE;
sc->sc_tbi_linkup = 1;
if_link_state_change(ifp, LINK_STATE_UP);
} else {
DPRINTF(WM_DEBUG_LINK, ("%s: LINK: LSC -> down\n",
device_xname(sc->sc_dev)));
mii->mii_media_status |= IFM_NONE;
sc->sc_tbi_linkup = 0;
if_link_state_change(ifp, LINK_STATE_DOWN);
wm_tbi_serdes_set_linkled(sc);
return;
}