le(4): add link status change reporting to drivers which support it

Reviewed by thorpej@
Tested by martin@
This commit is contained in:
roy 2020-10-20 18:17:58 +00:00
parent ee6f901c72
commit 37a768187e
4 changed files with 28 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: if_mc.c,v 1.55 2020/01/30 06:30:52 martin Exp $ */
/* $NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $ */
/*-
* Copyright (c) 1997 David Huang <khym@azeotrope.org>
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.55 2020/01/30 06:30:52 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.56 2020/10/20 18:17:58 roy Exp $");
#include "opt_ddb.h"
#include "opt_inet.h"
@ -455,6 +455,7 @@ struct mc_softc *sc = arg;
* Pretend we have carrier; if we don't this will be cleared
* shortly.
*/
const int ocarrier = sc->sc_havecarrier;
sc->sc_havecarrier = 1;
if (ir & XMTINT)
@ -462,6 +463,10 @@ struct mc_softc *sc = arg;
if (ir & RCVINT)
mc_rint(sc);
if (sc->sc_havecarrier != ocarrier)
if_link_state_change(&sc->sc_if,
sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
}
integrate void

View File

@ -1,4 +1,4 @@
/* $NetBSD: am79c950.c,v 1.49 2020/02/04 13:47:34 martin Exp $ */
/* $NetBSD: am79c950.c,v 1.50 2020/10/20 18:17:58 roy Exp $ */
/*-
* Copyright (c) 1997 David Huang <khym@bga.com>
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.49 2020/02/04 13:47:34 martin Exp $");
__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.50 2020/10/20 18:17:58 roy Exp $");
#include "opt_inet.h"
@ -458,6 +458,7 @@ mcintr(void *arg)
* Pretend we have carrier; if we don't this will be cleared
* shortly.
*/
const int ocarrier = sc->sc_havecarrier;
sc->sc_havecarrier = 1;
if (ir & XMTINT)
@ -466,6 +467,10 @@ mcintr(void *arg)
if (ir & RCVINT)
mc_rint(sc);
if (sc->sc_havecarrier != ocarrier)
if_link_state_change(&sc->sc_if,
sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
return 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: am7990.c,v 1.82 2020/03/19 02:31:28 thorpej Exp $ */
/* $NetBSD: am7990.c,v 1.83 2020/10/20 18:17:58 roy Exp $ */
/*-
* Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@ -65,7 +65,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.82 2020/03/19 02:31:28 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: am7990.c,v 1.83 2020/10/20 18:17:58 roy Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -435,6 +435,7 @@ am7990_intr(void *arg)
* Pretend we have carrier; if we don't this will be cleared
* shortly.
*/
const int ocarrier = sc->sc_havecarrier;
sc->sc_havecarrier = 1;
if (isr & LE_C0_RINT)
@ -442,6 +443,10 @@ am7990_intr(void *arg)
if (isr & LE_C0_TINT)
am7990_tint(sc);
if (sc->sc_havecarrier != ocarrier)
if_link_state_change(ifp,
sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
rnd_add_uint32(&sc->rnd_source, isr);
return (1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: am79900.c,v 1.30 2020/03/19 02:31:28 thorpej Exp $ */
/* $NetBSD: am79900.c,v 1.31 2020/10/20 18:17:58 roy Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -103,7 +103,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: am79900.c,v 1.30 2020/03/19 02:31:28 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: am79900.c,v 1.31 2020/10/20 18:17:58 roy Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -456,6 +456,7 @@ am79900_intr(void *arg)
* Pretend we have carrier; if we don't this will be cleared
* shortly.
*/
const int ocarrier = sc->sc_havecarrier;
sc->sc_havecarrier = 1;
if (isr & LE_C0_RINT)
@ -463,6 +464,10 @@ am79900_intr(void *arg)
if (isr & LE_C0_TINT)
am79900_tint(sc);
if (sc->sc_havecarrier != ocarrier)
if_link_state_change(ifp,
sc->sc_havecarrier ? LINK_STATE_UP : LINK_STATE_DOWN);
rnd_add_uint32(&sc->rnd_source, isr);
return (1);