summaryrefslogtreecommitdiff
path: root/sys/dev/ic
diff options
context:
space:
mode:
authormlelstv <mlelstv@NetBSD.org>2022-12-03 16:06:20 +0000
committermlelstv <mlelstv@NetBSD.org>2022-12-03 16:06:20 +0000
commitddfdbeb2b5e7948301d0c3a387b31a720d6ea518 (patch)
tree87fb75b85e80eb69b1d29909ef7cdae23c20f29f /sys/dev/ic
parenta3cd2359de50a832b0ae347dcc2ff1fc8a6e89a9 (diff)
Fix bug in protocol parser that often caused fatal 'checksum error'.
Defer power save setting to interface start. More verbose on errors. Allow build without FDT.
Diffstat (limited to 'sys/dev/ic')
-rw-r--r--sys/dev/ic/bwfm.c29
-rw-r--r--sys/dev/ic/bwfmvar.h5
2 files changed, 22 insertions, 12 deletions
diff --git a/sys/dev/ic/bwfm.c b/sys/dev/ic/bwfm.c
index 9de7d6b3d03..f84fdd62167 100644
--- a/sys/dev/ic/bwfm.c
+++ b/sys/dev/ic/bwfm.c
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.32 2022/03/14 06:40:12 mlelstv Exp $ */
+/* $NetBSD: bwfm.c,v 1.33 2022/12/03 16:06:20 mlelstv Exp $ */
/* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -508,6 +508,12 @@ bwfm_start(struct ifnet *ifp)
/* TODO: return if no link? */
+ if (sc->sc_setpm) {
+ sc->sc_setpm = false;
+ if (bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, sc->sc_pm))
+ printf("%s: could not set power\n", DEVNAME(sc));
+ }
+
for (;;) {
/* Discard management packets (fw handles this for us) */
IF_DEQUEUE(&ic->ic_mgtq, m);
@@ -548,7 +554,6 @@ bwfm_init(struct ifnet *ifp)
struct ieee80211com *ic = &sc->sc_ic;
uint8_t evmask[BWFM_EVENT_MASK_LEN];
struct bwfm_join_pref_params join_pref[2];
- int pm;
if (bwfm_fwvar_var_set_int(sc, "mpc", 1)) {
printf("%s: could not set mpc\n", DEVNAME(sc));
@@ -630,15 +635,12 @@ bwfm_init(struct ifnet *ifp)
* Use CAM (constantly awake) when we are running as AP
* otherwise use fast power saving.
*/
- pm = BWFM_PM_FAST_PS;
+ sc->sc_pm = BWFM_PM_FAST_PS;
#ifndef IEEE80211_STA_ONLY
if (ic->ic_opmode == IEEE80211_M_HOSTAP)
- pm = BWFM_PM_CAM;
+ sc->sc_pm = BWFM_PM_CAM;
#endif
- if (bwfm_fwvar_cmd_set_int(sc, BWFM_C_SET_PM, pm)) {
- printf("%s: could not set power\n", DEVNAME(sc));
- return EIO;
- }
+ sc->sc_setpm = true;
bwfm_fwvar_var_set_int(sc, "txbf", 1);
bwfm_fwvar_cmd_set_int(sc, BWFM_C_UP, 0);
@@ -702,6 +704,8 @@ bwfm_stop(struct ifnet *ifp, int disable)
if (sc->sc_bus_ops->bs_stop)
sc->sc_bus_ops->bs_stop(sc);
+
+ sc->sc_setpm = true;
}
void
@@ -728,22 +732,25 @@ bwfm_ioctl(struct ifnet *ifp, u_long cmd, void *data)
{
struct bwfm_softc *sc = ifp->if_softc;
struct ieee80211com *ic = &sc->sc_ic;
- int s, error = 0;
+ int s, error = 0, oflags;
s = splnet();
switch (cmd) {
case SIOCSIFFLAGS:
+ oflags = ifp->if_flags;
if ((error = ifioctl_common(ifp, cmd, data)) != 0)
break;
switch (ifp->if_flags & (IFF_UP | IFF_RUNNING)) {
case IFF_UP | IFF_RUNNING:
break;
case IFF_UP:
- bwfm_init(ifp);
+ if ((oflags & IFF_UP) == 0)
+ bwfm_init(ifp);
break;
case IFF_RUNNING:
- bwfm_stop(ifp, 1);
+ if ((oflags & IFF_UP) != 0)
+ bwfm_stop(ifp, 1);
break;
case 0:
break;
diff --git a/sys/dev/ic/bwfmvar.h b/sys/dev/ic/bwfmvar.h
index 63fecaa4d5d..8037c77e73b 100644
--- a/sys/dev/ic/bwfmvar.h
+++ b/sys/dev/ic/bwfmvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfmvar.h,v 1.13 2022/03/14 06:40:12 mlelstv Exp $ */
+/* $NetBSD: bwfmvar.h,v 1.14 2022/12/03 16:06:20 mlelstv Exp $ */
/* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
/*
* Copyright (c) 2010-2016 Broadcom Corporation
@@ -245,6 +245,9 @@ struct bwfm_softc {
size_t sc_txcapsize;
uint8_t *sc_cal;
size_t sc_calsize;
+
+ int sc_pm;
+ bool sc_setpm;
};
void bwfm_attach(struct bwfm_softc *);