Source-Changes-HG archive

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

[src/trunk]: src/sys IEEE80211_LOCK and WI_LOCK conceal enormous differences ...



details:   https://anonhg.NetBSD.org/src/rev/b41d79ad67a0
branches:  trunk
changeset: 547265:b41d79ad67a0
user:      dyoung <dyoung%NetBSD.org@localhost>
date:      Fri May 16 01:26:17 2003 +0000

description:
IEEE80211_LOCK and WI_LOCK conceal enormous differences in locking
semantics on FreeBSD and NetBSD, so I am backing them out until
the macro set is enriched.

diffstat:

 sys/dev/ic/wi.c            |  69 ++++++++++++++++-----------------------------
 sys/dev/ic/wivar.h         |   5 +--
 sys/net/if_ieee80211.h     |   8 +----
 sys/net/if_ieee80211subr.c |  27 +++++++++--------
 4 files changed, 41 insertions(+), 68 deletions(-)

diffs (truncated from 363 to 300 lines):

diff -r 5a4b022c0f40 -r b41d79ad67a0 sys/dev/ic/wi.c
--- a/sys/dev/ic/wi.c   Thu May 15 23:35:37 2003 +0000
+++ b/sys/dev/ic/wi.c   Fri May 16 01:26:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wi.c,v 1.124 2003/05/13 08:58:01 dyoung Exp $  */
+/*     $NetBSD: wi.c,v 1.125 2003/05/16 01:26:18 dyoung Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.124 2003/05/13 08:58:01 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wi.c,v 1.125 2003/05/16 01:26:18 dyoung Exp $");
 
 #define WI_HERMES_AUTOINC_WAR  /* Work around data write autoinc bug. */
 #define WI_HERMES_STATS_WAR    /* Work around stats counter bug. */
@@ -214,9 +214,9 @@
        static const u_int8_t empty_macaddr[IEEE80211_ADDR_LEN] = {
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00
        };
-       WI_LOCK_DECL();
+       int s;
 
-       WI_LOCK(sc);
+       s = splnet();
 
        /* Make sure interrupts are disabled. */
        CSR_WRITE_2(sc, WI_INT_EN, 0);
@@ -224,7 +224,7 @@
 
        /* Reset the NIC. */
        if (wi_reset(sc) != 0) {
-               WI_UNLOCK(s);
+               splx(s);
                return 1;
        }
 
@@ -232,7 +232,7 @@
        if (wi_read_rid(sc, WI_RID_MAC_NODE, ic->ic_myaddr, &buflen) != 0 ||
            IEEE80211_ADDR_EQ(ic->ic_myaddr, empty_macaddr)) {
                printf(" could not get mac address, attach failed\n");
-               WI_UNLOCK(sc);
+               splx(s);
                return 1;
        }
 
@@ -399,7 +399,7 @@
        /* Attach is successful. */
        sc->sc_attached = 1;
 
-       WI_UNLOCK(sc);
+       splx(s);
        return 0;
 }
 
@@ -407,12 +407,12 @@
 wi_detach(struct wi_softc *sc)
 {
        struct ifnet *ifp = &sc->sc_ic.ic_if;
-       WI_LOCK_DECL();
+       int s;
 
        if (!sc->sc_attached)
                return 0;
 
-       WI_LOCK(sc);
+       s = splnet();
 
        /* Delete all remaining media. */
        ifmedia_delete_instance(&sc->sc_media, IFM_INST_ANY);
@@ -424,7 +424,7 @@
                        (*sc->sc_disable)(sc);
                sc->sc_enabled = 0;
        }
-       WI_UNLOCK(sc);
+       splx(s);
        return 0;
 }
 
@@ -433,10 +433,9 @@
 wi_activate(struct device *self, enum devact act)
 {
        struct wi_softc *sc = (struct wi_softc *)self;
-       int rv = 0;
-       WI_LOCK_DECL();
+       int rv = 0, s;
 
-       WI_LOCK(sc);
+       s = splnet();
        switch (act) {
        case DVACT_ACTIVATE:
                rv = EOPNOTSUPP;
@@ -446,7 +445,7 @@
                if_deactivate(&sc->sc_ic.ic_if);
                break;
        }
-       WI_UNLOCK(sc);
+       splx(s);
        return rv;
 }
 
@@ -454,9 +453,9 @@
 wi_power(struct wi_softc *sc, int why)
 {
        struct ifnet *ifp = &sc->sc_ic.ic_if;
-       WI_LOCK_DECL();
+       int s;
 
-       WI_LOCK(sc);
+       s = splnet();
        switch (why) {
        case PWR_SUSPEND:
        case PWR_STANDBY:
@@ -473,7 +472,7 @@
        case PWR_SOFTRESUME:
                break;
        }
-       WI_UNLOCK(sc);
+       splx(s);
 }
 #endif /* __NetBSD__ */
 
@@ -550,9 +549,6 @@
        struct wi_joinreq join;
        int i;
        int error = 0, wasenabled;
-       WI_LOCK_DECL();
-
-       WI_LOCK(sc);
 
        DPRINTF(("wi_init: enabled %d\n", sc->sc_enabled));
        wasenabled = sc->sc_enabled;
@@ -711,7 +707,6 @@
                printf("%s: interface not running\n", sc->sc_dev.dv_xname);
                wi_stop(ifp, 0);
        }
-       WI_UNLOCK(sc);
        DPRINTF(("wi_init: return %d\n", error));
        return error;
 }
@@ -720,9 +715,9 @@
 wi_stop(struct ifnet *ifp, int disable)
 {
        struct wi_softc *sc = ifp->if_softc;
-       WI_LOCK_DECL();
+       int s;
 
-       WI_LOCK(sc);
+       s = splnet();
 
        DPRINTF(("wi_stop: disable %d\n", disable));
        /* Writing registers of a detached wi provokes an
@@ -751,7 +746,7 @@
        ifp->if_flags &= ~(IFF_OACTIVE | IFF_RUNNING);
        ifp->if_timer = 0;
 
-       WI_UNLOCK(sc);
+       splx(s);
 }
 
 static void
@@ -759,27 +754,16 @@
 {
        struct wi_softc *sc = ifp->if_softc;
        struct ieee80211com *ic = &sc->sc_ic;
-       struct ieee80211_node *ni = NULL;
+       struct ieee80211_node *ni;
        struct ieee80211_frame *wh;
        struct mbuf *m0;
        struct wi_frame frmhdr;
        int cur, fid, off;
-       WI_LOCK_DECL();
 
-       WI_LOCK(sc);
-
-       if (!sc->sc_enabled) {
-               WI_UNLOCK(sc);
+       if (ifp->if_flags & IFF_OACTIVE)
                return;
-       }
-       if (ifp->if_flags & IFF_OACTIVE) {
-               WI_UNLOCK(sc);
+       if (sc->sc_flags & WI_FLAGS_OUTRANGE)
                return;
-       }
-       if (sc->sc_flags & WI_FLAGS_OUTRANGE) {
-               WI_UNLOCK(sc);
-               return;
-       }
 
        memset(&frmhdr, 0, sizeof(frmhdr));
        cur = sc->sc_txnext;
@@ -914,8 +898,6 @@
                }
                sc->sc_txnext = cur = (cur + 1) % WI_NTXBUF;
        }
-
-       WI_UNLOCK(sc);
 }
 
 
@@ -997,13 +979,12 @@
        struct wi_softc *sc = ifp->if_softc;
        struct ieee80211com *ic = &sc->sc_ic;
        struct ifreq *ifr = (struct ifreq *)data;
-       int error = 0;
-       WI_LOCK_DECL();
+       int s, error = 0;
 
        if ((sc->sc_dev.dv_flags & DVF_ACTIVE) == 0)
                return ENXIO;
 
-       WI_LOCK(sc);
+       s = splnet();
 
        switch (cmd) {
        case SIOCSIFFLAGS:
@@ -1072,7 +1053,7 @@
                }
                break;
        }
-       WI_UNLOCK(sc);
+       splx(s);
        return error;
 }
 
diff -r 5a4b022c0f40 -r b41d79ad67a0 sys/dev/ic/wivar.h
--- a/sys/dev/ic/wivar.h        Thu May 15 23:35:37 2003 +0000
+++ b/sys/dev/ic/wivar.h        Fri May 16 01:26:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: wivar.h,v 1.32 2003/05/13 08:35:58 dyoung Exp $        */
+/*     $NetBSD: wivar.h,v 1.33 2003/05/16 01:26:18 dyoung Exp $        */
 
 /*
  * Copyright (c) 1997, 1998, 1999
@@ -200,9 +200,6 @@
        bus_space_read_multi_stream_2(sc->sc_iot, sc->sc_ioh,   \
                        (sc->sc_pci? reg * 2: reg), buf, count)
 
-#define        WI_LOCK_DECL()          int s
-#define        WI_LOCK(_sc)            s = splnet()
-#define        WI_UNLOCK(_sc)          splx(s)
 
 int    wi_attach(struct wi_softc *);
 int    wi_detach(struct wi_softc *);
diff -r 5a4b022c0f40 -r b41d79ad67a0 sys/net/if_ieee80211.h
--- a/sys/net/if_ieee80211.h    Thu May 15 23:35:37 2003 +0000
+++ b/sys/net/if_ieee80211.h    Fri May 16 01:26:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee80211.h,v 1.31 2003/05/13 10:05:05 dyoung Exp $ */
+/*     $NetBSD: if_ieee80211.h,v 1.32 2003/05/16 01:26:17 dyoung Exp $ */
 
 /*-
  * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
@@ -547,15 +547,9 @@
 };
 #ifdef __NetBSD__
 #define        ic_if           ic_ec.ec_if
-#define        IEEE80211_LOCK_DECL()   int s
-#define        IEEE80211_LOCK(_ic)     do { s = splnet(); } while (0)
-#define        IEEE80211_UNLOCK(_ic)   splx(s)
 #endif
 #ifdef __FreeBSD__
 #define        ic_if           ic_ac.ac_if
-#define        IEEE80211_LOCK_DECL()
-#define        IEEE80211_LOCK(_ic)     mtx_lock(&(_ic)->ic_mtx)
-#define        IEEE80211_UNLOCK(_ic)   mtx_unlock(&(_ic)->ic_mtx)
 #endif
 #define        ic_softc        ic_if.if_softc
 
diff -r 5a4b022c0f40 -r b41d79ad67a0 sys/net/if_ieee80211subr.c
--- a/sys/net/if_ieee80211subr.c        Thu May 15 23:35:37 2003 +0000
+++ b/sys/net/if_ieee80211subr.c        Fri May 16 01:26:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ieee80211subr.c,v 1.31 2003/05/13 10:05:05 dyoung Exp $     */
+/*     $NetBSD: if_ieee80211subr.c,v 1.32 2003/05/16 01:26:17 dyoung Exp $     */
 /*     $FreeBSD: src/sys/net/if_ieee80211subr.c,v 1.4 2003/01/21 08:55:59 alfred Exp $ */
 
 /*-
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.31 2003/05/13 10:05:05 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ieee80211subr.c,v 1.32 2003/05/16 01:26:17 dyoung Exp $");
 
 #include "opt_inet.h"
 #include "bpfilter.h"
@@ -218,9 +218,9 @@
 ieee80211_ifdetach(struct ifnet *ifp)
 {
        struct ieee80211com *ic = (void *)ifp;
-       IEEE80211_LOCK_DECL();
+       int s;
 
-       IEEE80211_LOCK(ic);
+       s = splnet();
        IF_PURGE(&ic->ic_mgtq);



Home | Main Index | Thread Index | Old Index