Some wifi drivers don't call ieee80211_newstate() during some state
authorstsp <stsp@openbsd.org>
Wed, 31 Jan 2018 12:36:13 +0000 (12:36 +0000)
committerstsp <stsp@openbsd.org>
Wed, 31 Jan 2018 12:36:13 +0000 (12:36 +0000)
transitions, which means those state transition won't be shown in dmesg
in interface debug mode. Make drivers print these transitions themselves.
ok patrick@

sys/dev/ic/bwfm.c
sys/dev/pci/if_iwm.c
sys/dev/pci/if_iwn.c
sys/dev/pci/if_wpi.c
sys/dev/usb/if_atu.c
sys/dev/usb/if_rsu.c

index 3ba2ee2..0a92d69 100644 (file)
@@ -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 <patrick@blueri.se>
@@ -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);
index b2fd03d..8685fc5 100644 (file)
@@ -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 <info@genua.de>
@@ -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);
index edff5e4..fdb270e 100644 (file)
@@ -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 <damien.bergamini@free.fr>
@@ -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;
 
index 29e468e..214f194 100644 (file)
@@ -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;
 
index b4f3906..ede6990 100644 (file)
@@ -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 <Danovitsch@Vitsch.net>.  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);
 
index aa23626..fb70699 100644 (file)
@@ -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 <damien.bergamini@free.fr>
@@ -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;