PERFORCE change 115327 for review
Paolo Pisati
piso at FreeBSD.org
Mon Mar 5 11:19:17 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=115327
Change 115327 by piso at piso_longino on 2007/03/05 11:18:40
Toss the overcomplicated implementation of iwi filtered handler.
Affected files ...
.. //depot/projects/soc2006/intr_filter/dev/iwi/if_iwi.c#12 edit
.. //depot/projects/soc2006/intr_filter/dev/iwi/if_iwivar.h#6 edit
Differences ...
==== //depot/projects/soc2006/intr_filter/dev/iwi/if_iwi.c#12 (text+ko) ====
@@ -143,13 +143,9 @@
static void iwi_frame_intr(struct iwi_softc *, struct iwi_rx_data *, int,
struct iwi_frame *);
static void iwi_notification_intr(struct iwi_softc *, struct iwi_notif *);
-static void iwi_rx_intr(void *);
+static void iwi_rx_intr(struct iwi_softc *);
static void iwi_tx_intr(struct iwi_softc *, struct iwi_tx_ring *);
-static void iwi_tx_intr1(void *c, int p __unused);
-static void iwi_tx_intr2(void *c, int p __unused);
-static void iwi_tx_intr3(void *c, int p __unused);
-static void iwi_tx_intr4(void *c, int p __unused);
-static int iwi_filter(void *);
+static void iwi_intr(void *);
static int iwi_cmd(struct iwi_softc *, uint8_t, void *, uint8_t);
static void iwi_write_ibssnode(struct iwi_softc *, const u_int8_t [], int);
static int iwi_tx_start(struct ifnet *, struct mbuf *,
@@ -269,7 +265,7 @@
mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF);
-
+
sc->sc_unr = new_unrhdr(1, IWI_MAX_IBSSNODE-1, &sc->sc_mtx);
#if __FreeBSD_version >= 700000
@@ -292,10 +288,6 @@
TASK_INIT(&sc->sc_setwmetask, 0, iwi_wme_setparams, sc);
TASK_INIT(&sc->sc_downtask, 0, iwi_down, sc);
TASK_INIT(&sc->sc_restarttask, 0, iwi_restart, sc);
- TASK_INIT(&sc->sc_tx1_done, 0, iwi_tx_intr1, sc);
- TASK_INIT(&sc->sc_tx2_done, 0, iwi_tx_intr2, sc);
- TASK_INIT(&sc->sc_tx3_done, 0, iwi_tx_intr3, sc);
- TASK_INIT(&sc->sc_tx4_done, 0, iwi_tx_intr4, sc);
if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
device_printf(dev, "chip is in D%d power mode "
@@ -1561,15 +1553,12 @@
}
static void
-iwi_rx_intr(void *arg)
+iwi_rx_intr(struct iwi_softc *sc)
{
- struct iwi_softc *sc = arg;
struct iwi_rx_data *data;
struct iwi_hdr *hdr;
uint32_t hw;
- IWI_LOCK_DECL;
- IWI_LOCK(sc);
hw = CSR_READ_4(sc, IWI_CSR_RX_RIDX);
for (; sc->rxq.cur != hw;) {
@@ -1604,8 +1593,6 @@
/* tell the firmware what we have processed */
hw = (hw == 0) ? IWI_RX_RING_COUNT - 1 : hw - 1;
CSR_WRITE_4(sc, IWI_CSR_RX_WIDX, hw);
- CSR_WRITE_4(sc, IWI_CSR_INTR_MASK, IWI_INTR_MASK);
- IWI_UNLOCK(sc);
}
static void
@@ -1615,9 +1602,7 @@
struct ifnet *ifp = ic->ic_ifp;
struct iwi_tx_data *data;
uint32_t hw;
- IWI_LOCK_DECL;
- IWI_LOCK(sc);
hw = CSR_READ_4(sc, txq->csr_ridx);
for (; txq->next != hw;) {
@@ -1646,94 +1631,64 @@
iwi_led_event(sc, IWI_LED_TX);
iwi_start(ifp);
- IWI_UNLOCK(sc);
}
static void
-iwi_tx_intr1(void *arg, int p __unused) {
+iwi_intr(void *arg)
+{
struct iwi_softc *sc = arg;
-
- iwi_tx_intr(sc, &sc->txq[0]);
-}
-
-static void
-iwi_tx_intr2(void *arg, int p __unused) {
- struct iwi_softc *sc = arg;
-
- iwi_tx_intr(sc, &sc->txq[1]);
-}
-
-static void
-iwi_tx_intr3(void *arg, int p __unused) {
- struct iwi_softc *sc = arg;
-
- iwi_tx_intr(sc, &sc->txq[2]);
-}
-
-static void
-iwi_tx_intr4(void *arg, int p __unused) {
- struct iwi_softc *sc = arg;
+ uint32_t r;
IWI_LOCK_DECL;
- IWI_LOCK(sc);
- iwi_tx_intr(sc, &sc->txq[3]);
- IWI_UNLOCK(sc);
-}
+ IWI_LOCK(sc);
-static int
-iwi_filter(void *arg)
-{
- struct iwi_softc *sc = arg;
- uint32_t r;
- int ret = FILTER_HANDLED;
-
- if ((r = CSR_READ_4(sc, IWI_CSR_INTR)) == 0 || r == 0xffffffff)
- return (FILTER_STRAY);
+ if ((r = CSR_READ_4(sc, IWI_CSR_INTR)) == 0 || r == 0xffffffff) {
+ IWI_UNLOCK(sc);
+ return;
+ }
/* acknowledge interrupts */
CSR_WRITE_4(sc, IWI_CSR_INTR, r);
+ if (r & IWI_INTR_FATAL_ERROR) {
+ device_printf(sc->sc_dev, "firmware error\n");
+ taskqueue_enqueue(sc->sc_tq, &sc->sc_restarttask);
+ }
+
if (r & IWI_INTR_FW_INITED) {
if (!(r & (IWI_INTR_FATAL_ERROR | IWI_INTR_PARITY_ERROR)))
wakeup(sc);
}
-
+
+ if (r & IWI_INTR_RADIO_OFF)
+ taskqueue_enqueue(sc->sc_tq, &sc->sc_radiofftask);
+
if (r & IWI_INTR_CMD_DONE) {
sc->flags &= ~IWI_FLAG_BUSY;
wakeup(sc);
}
- if (r & IWI_INTR_PARITY_ERROR) {
- /* XXX rate-limit */
- device_printf(sc->sc_dev, "parity error\n");
- }
-
- if (r & IWI_INTR_FATAL_ERROR) {
- device_printf(sc->sc_dev, "firmware error\n");
- taskqueue_enqueue(sc->sc_tq, &sc->sc_restarttask);
- }
-
- if (r & IWI_INTR_RADIO_OFF)
- taskqueue_enqueue(sc->sc_tq, &sc->sc_radiofftask);
-
if (r & IWI_INTR_TX1_DONE)
- taskqueue_enqueue(sc->sc_tq, &sc->sc_tx1_done);
+ iwi_tx_intr(sc, &sc->txq[0]);
if (r & IWI_INTR_TX2_DONE)
- taskqueue_enqueue(sc->sc_tq, &sc->sc_tx2_done);
+ iwi_tx_intr(sc, &sc->txq[1]);
if (r & IWI_INTR_TX3_DONE)
- taskqueue_enqueue(sc->sc_tq, &sc->sc_tx3_done);
+ iwi_tx_intr(sc, &sc->txq[2]);
if (r & IWI_INTR_TX4_DONE)
- taskqueue_enqueue(sc->sc_tq, &sc->sc_tx4_done);
-
- if (r & IWI_INTR_RX_DONE) {
- /* disable interrupts */
- CSR_WRITE_4(sc, IWI_CSR_INTR_MASK, 0);
- ret |= FILTER_SCHEDULE_THREAD;
+ iwi_tx_intr(sc, &sc->txq[3]);
+
+ if (r & IWI_INTR_RX_DONE)
+ iwi_rx_intr(sc);
+
+ if (r & IWI_INTR_PARITY_ERROR) {
+ /* XXX rate-limit */
+ device_printf(sc->sc_dev, "parity error\n");
}
- return (ret);
+
+ IWI_UNLOCK(sc);
}
static int
@@ -2166,7 +2121,6 @@
CSR_WRITE_4(sc, IWI_CSR_RST, tmp | IWI_RST_PRINCETON_RESET);
sc->flags &= ~IWI_FLAG_FW_INITED;
-
}
static int
@@ -3323,7 +3277,6 @@
IWI_LOCK_CHECK(sc); /* XXX: pretty sure this triggers */
if (sc->sc_softled) {
- IWI_ASSERT_OWNED(sc);
callout_stop(&sc->sc_ledtimer);
sc->sc_blinking = 0;
}
@@ -3385,14 +3338,11 @@
iwi_radio_off(void *arg, int pending)
{
struct iwi_softc *sc = arg;
- IWI_LOCK_DECL;
- IWI_LOCK(sc);
device_printf(sc->sc_dev, "radio turned off\n");
iwi_stop(sc);
sc->sc_rfkill_timer = 2;
sc->sc_ifp->if_timer = 1;
- IWI_UNLOCK(sc);
}
static int
==== //depot/projects/soc2006/intr_filter/dev/iwi/if_iwivar.h#6 (text+ko) ====
@@ -190,10 +190,6 @@
struct task sc_setwmetask; /* set wme params processing */
struct task sc_downtask; /* disassociate processing */
struct task sc_restarttask; /* restart adapter processing */
- struct task sc_tx1_done;
- struct task sc_tx2_done;
- struct task sc_tx3_done;
- struct task sc_tx4_done;
unsigned int sc_softled : 1, /* enable LED gpio status */
sc_ledstate: 1, /* LED on/off state */
@@ -247,7 +243,3 @@
if (!__waslocked) \
mtx_unlock(&(sc)->sc_mtx); \
} while (0)
-
-#define IWI_ASSERT_OWNED(sc) do { \
- mtx_assert(&(sc)->sc_mtx, MA_OWNED); \
-} while (0)
More information about the p4-projects
mailing list