From: stsp Date: Wed, 31 Jan 2018 12:36:13 +0000 (+0000) Subject: Some wifi drivers don't call ieee80211_newstate() during some state X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5d1a01fe2fc5991b5aac9eed91379174b3b728e1;p=openbsd Some wifi drivers don't call ieee80211_newstate() during some state transitions, which means those state transition won't be shown in dmesg in interface debug mode. Make drivers print these transitions themselves. ok patrick@ --- diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c index 3ba2ee2c4fb..0a92d696577 100644 --- a/sys/dev/ic/bwfm.c +++ b/sys/dev/ic/bwfm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bwfm.c,v 1.32 2018/01/24 13:07:31 patrick Exp $ */ +/* $OpenBSD: bwfm.c,v 1.33 2018/01/31 12:36:13 stsp Exp $ */ /* * Copyright (c) 2010-2016 Broadcom Corporation * Copyright (c) 2016,2017 Patrick Wildt @@ -2152,26 +2152,30 @@ bwfm_newstate_cb(struct bwfm_softc *sc, void *arg) { struct bwfm_cmd_newstate *cmd = arg; struct ieee80211com *ic = &sc->sc_ic; - enum ieee80211_state ostate, nstate; + struct ifnet *ifp = &ic->ic_if; + enum ieee80211_state nstate = cmd->state; int s; s = splnet(); - ostate = ic->ic_state; - nstate = cmd->state; - DPRINTF(("newstate %s -> %s\n", - ieee80211_state_name[ostate], - ieee80211_state_name[nstate])); switch (nstate) { case IEEE80211_S_SCAN: bwfm_scan(sc); + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", DEVNAME(sc), + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[nstate]); ic->ic_state = nstate; splx(s); return; case IEEE80211_S_AUTH: ic->ic_bss->ni_rsn_supp_state = RSNA_SUPP_INITIALIZE; bwfm_connect(sc); - ic->ic_state = cmd->state; + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", DEVNAME(sc), + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[nstate]); + ic->ic_state = nstate; if (ic->ic_flags & IEEE80211_F_RSNON) ic->ic_bss->ni_rsn_supp_state = RSNA_SUPP_PTKSTART; splx(s); diff --git a/sys/dev/pci/if_iwm.c b/sys/dev/pci/if_iwm.c index b2fd03d9152..8685fc5db8f 100644 --- a/sys/dev/pci/if_iwm.c +++ b/sys/dev/pci/if_iwm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwm.c,v 1.223 2018/01/14 11:51:34 stsp Exp $ */ +/* $OpenBSD: if_iwm.c,v 1.224 2018/01/31 12:36:13 stsp Exp $ */ /* * Copyright (c) 2014, 2016 genua gmbh @@ -5475,6 +5475,7 @@ int iwm_scan(struct iwm_softc *sc) { struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = IC2IFP(ic); int err; if (sc->sc_flags & IWM_FLAG_BGSCAN) { @@ -5496,6 +5497,10 @@ iwm_scan(struct iwm_softc *sc) } sc->sc_flags |= IWM_FLAG_SCANNING; + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[IEEE80211_S_SCAN]); ic->ic_state = IEEE80211_S_SCAN; iwm_led_blink_start(sc); wakeup(&ic->ic_state); /* wake iwm_init() */ @@ -6077,10 +6082,6 @@ iwm_newstate_task(void *psc) int arg = sc->ns_arg; int err = 0, s = splnet(); - DPRINTF(("switching state %s->%s\n", - ieee80211_state_name[ostate], - ieee80211_state_name[nstate])); - if (sc->sc_flags & IWM_FLAG_SHUTDOWN) { /* iwm_stop() is waiting for us. */ refcnt_rele_wake(&sc->task_refs); diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c index edff5e47c5a..fdb270e8f1a 100644 --- a/sys/dev/pci/if_iwn.c +++ b/sys/dev/pci/if_iwn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_iwn.c,v 1.198 2018/01/09 10:00:12 mpi Exp $ */ +/* $OpenBSD: if_iwn.c,v 1.199 2018/01/31 12:36:13 stsp Exp $ */ /*- * Copyright (c) 2007-2010 Damien Bergamini @@ -1782,6 +1782,10 @@ iwn_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) sc->sc_dev.dv_xname); return error; } + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[nstate]); ic->ic_state = nstate; return 0; diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c index 29e468e9549..214f1944ca3 100644 --- a/sys/dev/pci/if_wpi.c +++ b/sys/dev/pci/if_wpi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_wpi.c,v 1.141 2017/10/26 15:00:28 mpi Exp $ */ +/* $OpenBSD: if_wpi.c,v 1.142 2018/01/31 12:36:13 stsp Exp $ */ /*- * Copyright (c) 2006-2008 @@ -1053,6 +1053,10 @@ wpi_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) sc->sc_dev.dv_xname); return error; } + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[nstate]); ic->ic_state = nstate; return 0; diff --git a/sys/dev/usb/if_atu.c b/sys/dev/usb/if_atu.c index b4f390632c2..ede699045be 100644 --- a/sys/dev/usb/if_atu.c +++ b/sys/dev/usb/if_atu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_atu.c,v 1.123 2017/07/21 15:55:04 stsp Exp $ */ +/* $OpenBSD: if_atu.c,v 1.124 2018/01/31 12:36:13 stsp Exp $ */ /* * Copyright (c) 2003, 2004 * Daan Vreeken . All rights reserved. @@ -1206,9 +1206,6 @@ atu_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) struct atu_softc *sc = ifp->if_softc; enum ieee80211_state ostate = ic->ic_state; - DPRINTFN(10, ("%s: atu_newstate: %s -> %s\n", sc->atu_dev.dv_xname, - ieee80211_state_name[ostate], ieee80211_state_name[nstate])); - switch (nstate) { case IEEE80211_S_SCAN: memcpy(ic->ic_chan_scan, ic->ic_chan_active, @@ -1220,6 +1217,10 @@ atu_newstate(struct ieee80211com *ic, enum ieee80211_state nstate, int arg) usb_add_task(sc->atu_udev, &sc->sc_task); /* handle this ourselves */ + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[nstate]); ic->ic_state = nstate; return (0); diff --git a/sys/dev/usb/if_rsu.c b/sys/dev/usb/if_rsu.c index aa23626b21f..fb70699874e 100644 --- a/sys/dev/usb/if_rsu.c +++ b/sys/dev/usb/if_rsu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rsu.c,v 1.41 2017/10/26 15:00:28 mpi Exp $ */ +/* $OpenBSD: if_rsu.c,v 1.42 2018/01/31 12:36:13 stsp Exp $ */ /*- * Copyright (c) 2010 Damien Bergamini @@ -814,14 +814,12 @@ rsu_newstate_cb(struct rsu_softc *sc, void *arg) { struct rsu_cmd_newstate *cmd = arg; struct ieee80211com *ic = &sc->sc_ic; + struct ifnet *ifp = &ic->ic_if; enum ieee80211_state ostate; int error, s; s = splnet(); ostate = ic->ic_state; - DPRINTF(("newstate %s -> %s\n", - ieee80211_state_name[ostate], - ieee80211_state_name[cmd->state])); if (ostate == IEEE80211_S_RUN) { /* Stop calibration. */ @@ -838,6 +836,10 @@ rsu_newstate_cb(struct rsu_softc *sc, void *arg) printf("%s: could not send site survey command\n", sc->sc_dev.dv_xname); } + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[cmd->state]); ic->ic_state = cmd->state; splx(s); return; @@ -851,6 +853,10 @@ rsu_newstate_cb(struct rsu_softc *sc, void *arg) splx(s); return; } + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[cmd->state]); ic->ic_state = cmd->state; if (ic->ic_flags & IEEE80211_F_RSNON) ic->ic_bss->ni_rsn_supp_state = RSNA_SUPP_PTKSTART; @@ -858,6 +864,10 @@ rsu_newstate_cb(struct rsu_softc *sc, void *arg) return; case IEEE80211_S_ASSOC: /* No-op for this driver. See rsu_event_join_bss(). */ + if (ifp->if_flags & IFF_DEBUG) + printf("%s: %s -> %s\n", ifp->if_xname, + ieee80211_state_name[ic->ic_state], + ieee80211_state_name[cmd->state]); ic->ic_state = cmd->state; splx(s); return;