From abd116eff50831b8b237ca9b737e16087ed862aa Mon Sep 17 00:00:00 2001 From: itojun Date: Thu, 19 Jul 2001 15:38:17 +0000 Subject: [PATCH] - on IFF_UP change, inform sys/net/if_spppsubr.c of the change so that we can run LCP and subsequent PPP negotiation. - suppress too noisy printf() for about AIS event (if you remove the cable, it will bark forever). - sppp_dequeue() can return NULL even when sppp_isempty() is false, so check it and do not deref NULL pointer. - sppp_flush() on LMC interface shutdown. - prepare to change BPF type on the fly (bpf_change_type). --- sys/dev/pci/if_lmc.c | 26 +++++++++++++++++++++++--- sys/dev/pci/if_lmc_media.c | 14 +++++++++++++- sys/dev/pci/if_lmc_nbsd.c | 4 +++- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/sys/dev/pci/if_lmc.c b/sys/dev/pci/if_lmc.c index 74fd4081381e..3230bada80ba 100644 --- a/sys/dev/pci/if_lmc.c +++ b/sys/dev/pci/if_lmc.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lmc.c,v 1.12 2001/07/07 16:46:35 thorpej Exp $ */ +/* $NetBSD: if_lmc.c,v 1.13 2001/07/19 15:38:17 itojun Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -506,6 +506,10 @@ lmc_watchdog(int unit) static void lmc_ifup(lmc_softc_t * const sc) { +#if defined(__NetBSD__) || defined(__FreeBSD__) + struct sppp *sp = &sc->lmc_sppp; +#endif + sc->lmc_if.if_timer = 0; lmc_dec_reset(sc); @@ -544,6 +548,12 @@ lmc_ifup(lmc_softc_t * const sc) LMC_CSR_WRITE(sc, csr_command, sc->lmc_cmdmode); sc->lmc_if.if_timer = 1; + + +#if defined(__NetBSD__) || defined(__FreeBSD__) + /* connect LCP */ + (sp->pp_up)(sp); +#endif } /* @@ -553,6 +563,13 @@ lmc_ifup(lmc_softc_t * const sc) static void lmc_ifdown(lmc_softc_t * const sc) { +#if defined(__NetBSD__) || defined(__FreeBSD__) + struct sppp *sp = &sc->lmc_sppp; + + /* disconnect LCP */ + (sp->pp_down)(sp); +#endif + sc->lmc_if.if_timer = 0; sc->lmc_flags &= ~LMC_IFUP; @@ -1258,6 +1275,8 @@ lmc_ifstart(struct ifnet * const ifp) if (sc->lmc_flags & LMC_IFUP) { while (sppp_isempty(ifp) == 0) { m = sppp_dequeue(ifp); + if (!m) + break; if ((m = lmc_txput(sc, m)) != NULL) { IF_PREPEND(&((struct sppp *)ifp)->pp_fastq, m); break; @@ -1275,8 +1294,9 @@ lmc_ifstart_one(struct ifnet * const ifp) if ((sc->lmc_flags & LMC_IFUP) && (sppp_isempty(ifp) == 0)) { m = sppp_dequeue(ifp); - if ((m = lmc_txput(sc, m)) != NULL) { - IF_PREPEND(&((struct sppp *)ifp)->pp_fastq, m); + if (m) { + if ((m = lmc_txput(sc, m)) != NULL) + IF_PREPEND(&((struct sppp *)ifp)->pp_fastq, m); } LMC_CSR_WRITE(sc, csr_txpoll, 1); } diff --git a/sys/dev/pci/if_lmc_media.c b/sys/dev/pci/if_lmc_media.c index 4d3f68872bef..24d4dc348077 100644 --- a/sys/dev/pci/if_lmc_media.c +++ b/sys/dev/pci/if_lmc_media.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lmc_media.c,v 1.6 2001/06/12 15:17:25 wiz Exp $ */ +/* $NetBSD: if_lmc_media.c,v 1.7 2001/07/19 15:38:18 itojun Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -400,7 +400,9 @@ lmc_ds3_watchdog (lmc_softc_t * const sc) sc->lmc_miireg16 = lmc_mii_readreg (sc, 0, 16); if (sc->lmc_miireg16 & 0x0018) { +#if 0 printf("%s: AIS Received\n", sc->lmc_xname); +#endif lmc_led_on (sc, LMC_DS3_LED1 | LMC_DS3_LED2); } } @@ -1128,13 +1130,17 @@ lmc_t1_watchdog(lmc_softc_t * const sc) t1stat = lmc_t1_read (sc, 0x47); /* blue alarm -- RAIS */ if (t1stat & 0x08) { +#if 0 if (sc->lmc_blue != 1) printf ("%s: AIS Received\n", sc->lmc_xname); +#endif lmc_led_on (sc, LMC_DS3_LED1 | LMC_DS3_LED2); sc->lmc_blue = 1; } else { +#if 0 if (sc->lmc_blue == 1) printf ("%s: AIS ok\n", sc->lmc_xname); +#endif lmc_led_off (sc, LMC_DS3_LED1); lmc_led_on (sc, LMC_DS3_LED2); sc->lmc_blue = 0; @@ -1200,5 +1206,11 @@ lmc_set_protocol(lmc_softc_t * const sc, lmc_ctl_t *ctl) sc->lmc_sppp.pp_flags = PP_CISCO; } } + + /* just in case we are going to change encap type */ + if ((sc->lmc_sppp.pp_flags & PP_CISCO) != 0) + bpf_change_type(&sc->lmc_if, DLT_HDLC, PPP_HEADER_LEN); + else + bpf_change_type(&sc->lmc_if, DLT_PPP, PPP_HEADER_LEN); #endif } diff --git a/sys/dev/pci/if_lmc_nbsd.c b/sys/dev/pci/if_lmc_nbsd.c index fc42ec844644..bd6861024f24 100644 --- a/sys/dev/pci/if_lmc_nbsd.c +++ b/sys/dev/pci/if_lmc_nbsd.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_lmc_nbsd.c,v 1.10 2001/07/07 16:39:16 thorpej Exp $ */ +/* $NetBSD: if_lmc_nbsd.c,v 1.11 2001/07/19 15:38:18 itojun Exp $ */ /*- * Copyright (c) 1997-1999 LAN Media Corporation (LMC) @@ -378,4 +378,6 @@ lmc_shutdown(void *arg) sc->lmc_miireg16 = 0; /* deassert ready, and all others too */ lmc_led_on(sc, LMC_MII16_LED_ALL); + + sppp_flush(&sc->lmc_if); }