Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic bwfm: Switch from pcq to pool_cache.



details:   https://anonhg.NetBSD.org/src/rev/cd4d17477f63
branches:  trunk
changeset: 974078:cd4d17477f63
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Wed Jul 22 17:23:52 2020 +0000

description:
bwfm: Switch from pcq to pool_cache.

pcq_get is required to be serialized, but it's far from clear that it
is serialized here.

diffstat:

 sys/dev/ic/bwfm.c    |  33 +++++++++++++++++----------------
 sys/dev/ic/bwfmvar.h |   7 +++----
 2 files changed, 20 insertions(+), 20 deletions(-)

diffs (166 lines):

diff -r c26dac445cf8 -r cd4d17477f63 sys/dev/ic/bwfm.c
--- a/sys/dev/ic/bwfm.c Wed Jul 22 17:23:12 2020 +0000
+++ b/sys/dev/ic/bwfm.c Wed Jul 22 17:23:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfm.c,v 1.28 2020/07/22 17:21:25 riastradh Exp $ */
+/* $NetBSD: bwfm.c,v 1.29 2020/07/22 17:23:52 riastradh Exp $ */
 /* $OpenBSD: bwfm.c,v 1.5 2017/10/16 22:27:16 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -24,7 +24,7 @@
 #include <sys/device.h>
 #include <sys/kernel.h>
 #include <sys/kmem.h>
-#include <sys/pcq.h>
+#include <sys/pool.h>
 #include <sys/queue.h>
 #include <sys/socket.h>
 #include <sys/systm.h>
@@ -319,7 +319,6 @@
 {
        struct ieee80211com *ic = &sc->sc_ic;
        struct ifnet *ifp = &sc->sc_if;
-       struct bwfm_task *t;
        char fw_version[BWFM_DCMD_SMLEN];
        uint32_t bandlist[3];
        uint32_t tmp;
@@ -331,12 +330,10 @@
                printf("%s: could not create workqueue\n", DEVNAME(sc));
                return;
        }
-       sc->sc_freetask = pcq_create(BWFM_TASK_COUNT, KM_SLEEP);
-       for (i = 0; i < BWFM_TASK_COUNT; i++) {
-               t = &sc->sc_task[i];
-               t->t_sc = sc;
-               pcq_put(sc->sc_freetask, t);
-       }
+       sc->sc_freetask = pool_cache_init(sizeof(struct bwfm_task), 0, 0, 0,
+           "bwfmtask", NULL, IPL_NET /* XXX IPL_SOFTNET? */,
+           NULL, NULL, NULL);
+       pool_cache_prime(sc->sc_freetask, BWFM_TASK_COUNT);
 
        /* Stop the device in case it was previously initialized */
        bwfm_fwvar_cmd_set_int(sc, BWFM_C_DOWN, 1);
@@ -429,7 +426,7 @@
        error = if_initialize(ifp);
        if (error != 0) {
                printf("%s: if_initialize failed(%d)\n", DEVNAME(sc), error);
-               pcq_destroy(sc->sc_freetask);
+               pool_cache_destroy(sc->sc_freetask);
                workqueue_destroy(sc->sc_taskq);
 
                return; /* Error */
@@ -469,7 +466,7 @@
        if (sc->sc_taskq)
                workqueue_destroy(sc->sc_taskq);
        if (sc->sc_freetask)
-               pcq_destroy(sc->sc_freetask);
+               pool_cache_destroy(sc->sc_freetask);
 
        return 0;
 }
@@ -780,12 +777,13 @@
        struct bwfm_softc *sc = ic->ic_ifp->if_softc;
        struct bwfm_task *t;
 
-       t = pcq_get(sc->sc_freetask);
+       t = pool_cache_get(sc->sc_freetask, PR_NOWAIT);
        if (t == NULL) {
                printf("%s: no free tasks\n", DEVNAME(sc));
                return 0;
        }
 
+       t->t_sc = sc;
        t->t_cmd = BWFM_TASK_KEY_SET;
        t->t_key.key = wk;
        memcpy(t->t_key.mac, mac, sizeof(t->t_key.mac));
@@ -871,12 +869,13 @@
        struct bwfm_softc *sc = ic->ic_ifp->if_softc;
        struct bwfm_task *t;
 
-       t = pcq_get(sc->sc_freetask);
+       t = pool_cache_get(sc->sc_freetask, PR_NOWAIT);
        if (t == NULL) {
                printf("%s: no free tasks\n", DEVNAME(sc));
                return 0;
        }
 
+       t->t_sc = sc;
        t->t_cmd = BWFM_TASK_KEY_DELETE;
        t->t_key.key = wk;
        memset(t->t_key.mac, 0, sizeof(t->t_key.mac));
@@ -905,12 +904,13 @@
        struct bwfm_softc *sc = ic->ic_ifp->if_softc;
        struct bwfm_task *t;
 
-       t = pcq_get(sc->sc_freetask);
+       t = pool_cache_get(sc->sc_freetask, PR_NOWAIT);
        if (t == NULL) {
                printf("%s: no free tasks\n", DEVNAME(sc));
                return EIO;
        }
 
+       t->t_sc = sc;
        t->t_cmd = BWFM_TASK_NEWSTATE;
        t->t_newstate.state = nstate;
        t->t_newstate.arg = arg;
@@ -988,7 +988,7 @@
                panic("bwfm: unknown task command %d", t->t_cmd);
        }
 
-       pcq_put(sc->sc_freetask, t);
+       pool_cache_put(sc->sc_freetask, t);
 }
 
 int
@@ -2086,13 +2086,14 @@
 {
        struct bwfm_task *t;
 
-       t = pcq_get(sc->sc_freetask);
+       t = pool_cache_get(sc->sc_freetask, PR_NOWAIT);
        if (t == NULL) {
                m_freem(m);
                printf("%s: no free tasks\n", DEVNAME(sc));
                return;
        }
 
+       t->t_sc = sc;
        t->t_cmd = BWFM_TASK_RX_EVENT;
        t->t_mbuf = m;
        workqueue_enqueue(sc->sc_taskq, (struct work*)t, NULL);
diff -r c26dac445cf8 -r cd4d17477f63 sys/dev/ic/bwfmvar.h
--- a/sys/dev/ic/bwfmvar.h      Wed Jul 22 17:23:12 2020 +0000
+++ b/sys/dev/ic/bwfmvar.h      Wed Jul 22 17:23:52 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bwfmvar.h,v 1.11 2020/07/22 17:21:25 riastradh Exp $ */
+/* $NetBSD: bwfmvar.h,v 1.12 2020/07/22 17:23:52 riastradh Exp $ */
 /* $OpenBSD: bwfmvar.h,v 1.1 2017/10/11 17:19:50 patrick Exp $ */
 /*
  * Copyright (c) 2010-2016 Broadcom Corporation
@@ -24,7 +24,6 @@
 
 #include <sys/cdefs.h>
 #include <sys/device_if.h>
-#include <sys/pcq.h>
 #include <sys/queue.h>
 #include <sys/workqueue.h>
 
@@ -36,6 +35,7 @@
 
 struct ieee80211_key;
 struct mbuf;
+struct pool_cache;
 
 /* Chipcommon Core Chip IDs */
 #define BRCM_CC_43143_CHIP_ID          43143
@@ -223,8 +223,7 @@
        int                      sc_tx_timer;
 
        bool                     sc_if_attached;
-       struct bwfm_task         sc_task[BWFM_TASK_COUNT];
-       pcq_t                   *sc_freetask;
+       struct pool_cache       *sc_freetask;
        struct workqueue        *sc_taskq;
 
        int                     (*sc_newstate)(struct ieee80211com *,



Home | Main Index | Thread Index | Old Index