From 37a768187e9fa477becaf06f975f4fab0f3f0515 Mon Sep 17 00:00:00 2001 From: roy Date: Tue, 20 Oct 2020 18:17:58 +0000 Subject: [PATCH] le(4): add link status change reporting to drivers which support it Reviewed by thorpej@ Tested by martin@ --- sys/arch/mac68k/dev/if_mc.c | 9 +++++++-- sys/arch/macppc/dev/am79c950.c | 9 +++++++-- sys/dev/ic/am7990.c | 9 +++++++-- sys/dev/ic/am79900.c | 9 +++++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/sys/arch/mac68k/dev/if_mc.c b/sys/arch/mac68k/dev/if_mc.c index e6d19038239b..e773b65bdbd9 100644 --- a/sys/arch/mac68k/dev/if_mc.c +++ b/sys/arch/mac68k/dev/if_mc.c @@ -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 @@ -35,7 +35,7 @@ */ #include -__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 diff --git a/sys/arch/macppc/dev/am79c950.c b/sys/arch/macppc/dev/am79c950.c index 3481511e9a04..79cfcb68460e 100644 --- a/sys/arch/macppc/dev/am79c950.c +++ b/sys/arch/macppc/dev/am79c950.c @@ -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 @@ -35,7 +35,7 @@ */ #include -__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; } diff --git a/sys/dev/ic/am7990.c b/sys/dev/ic/am7990.c index 461c626572c6..fe9bbbe571ca 100644 --- a/sys/dev/ic/am7990.c +++ b/sys/dev/ic/am7990.c @@ -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 -__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 #include @@ -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); diff --git a/sys/dev/ic/am79900.c b/sys/dev/ic/am79900.c index dec43090f448..e56d4c6bb577 100644 --- a/sys/dev/ic/am79900.c +++ b/sys/dev/ic/am79900.c @@ -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 -__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 #include @@ -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);