Do not send (normal) packets before we reach the run state. Logic copied
authorkettenis <kettenis@openbsd.org>
Fri, 30 Dec 2022 16:49:34 +0000 (16:49 +0000)
committerkettenis <kettenis@openbsd.org>
Fri, 30 Dec 2022 16:49:34 +0000 (16:49 +0000)
from iwm(4), which also looks at the TX_MGMT_ONLY flag.  We don't expect
that flag to be ever set for bwfm(4), but it shouldn't hurt and it keeps
things consistent across drivers.

This fixes issues with suspend/resume (including firmware crashes seen on
the M2 Macbook Air).

ok patrick@, stsp@

sys/dev/ic/bwfm.c

index b4f8c70..56c8e23 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: bwfm.c,v 1.105 2022/06/30 19:57:40 stsp Exp $ */
+/* $OpenBSD: bwfm.c,v 1.106 2022/12/30 16:49:34 kettenis Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
  * Copyright (c) 2016,2017 Patrick Wildt <patrick@blueri.se>
@@ -391,6 +391,7 @@ void
 bwfm_start(struct ifnet *ifp)
 {
        struct bwfm_softc *sc = ifp->if_softc;
+       struct ieee80211com *ic = &sc->sc_ic;
        struct mbuf *m;
 
        if (!(ifp->if_flags & IFF_RUNNING))
@@ -408,6 +409,10 @@ bwfm_start(struct ifnet *ifp)
                        break;
                }
 
+               if (ic->ic_state != IEEE80211_S_RUN ||
+                   (ic->ic_xflags & IEEE80211_F_TX_MGMT_ONLY))
+                       break;
+
                m = ifq_dequeue(&ifp->if_snd);
                if (m == NULL)
                        break;