summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/wi/if_wi.c89
-rw-r--r--sys/dev/wi/if_wi_pccard.c22
-rw-r--r--sys/dev/wi/if_wi_pci.c2
-rw-r--r--sys/dev/wi/if_wivar.h29
-rw-r--r--sys/dev/wi/wi_hostap.c11
5 files changed, 115 insertions, 38 deletions
diff --git a/sys/dev/wi/if_wi.c b/sys/dev/wi/if_wi.c
index 0f7404e..07333fe 100644
--- a/sys/dev/wi/if_wi.c
+++ b/sys/dev/wi/if_wi.c
@@ -54,12 +54,9 @@
* programs the Hermes controller directly, using information gleaned
* from the HCF Light code and corresponding documentation.
*
- * This driver supports both the PCMCIA and ISA versions of the
- * WaveLAN/IEEE cards. Note however that the ISA card isn't really
- * anything of the sort: it's actually a PCMCIA bridge adapter
- * that fits into an ISA slot, into which a PCMCIA WaveLAN card is
- * inserted. Consequently, you need to use the pccard support for
- * both the ISA and PCMCIA adapters.
+ * This driver supports the ISA, PCMCIA and PCI versions of the Lucent
+ * WaveLan cards (based on the Hermes chipset), as well as the newer
+ * Prism 2 chipsets with firmware from Intersil and Symbol.
*/
#include <sys/param.h>
@@ -78,6 +75,7 @@
#include <machine/bus.h>
#include <machine/resource.h>
+#include <machine/clock.h>
#include <sys/rman.h>
#include <net/if.h>
@@ -180,14 +178,15 @@ wi_generic_detach(dev)
{
struct wi_softc *sc;
struct ifnet *ifp;
+ int s;
sc = device_get_softc(dev);
- WI_LOCK(sc);
+ WI_LOCK(sc, s);
ifp = &sc->arpcom.ac_if;
if (sc->wi_gone) {
device_printf(dev, "already unloaded\n");
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return(ENODEV);
}
@@ -201,8 +200,10 @@ wi_generic_detach(dev)
wi_free(dev);
sc->wi_gone = 1;
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
+#if __FreeBSD_version >= 500000
mtx_destroy(&sc->wi_mtx);
+#endif
return(0);
}
@@ -215,6 +216,7 @@ wi_generic_attach(device_t dev)
struct wi_ltv_gen gen;
struct ifnet *ifp;
int error;
+ int s;
/* XXX maybe we need the splimp stuff here XXX */
sc = device_get_softc(dev);
@@ -229,9 +231,11 @@ wi_generic_attach(device_t dev)
return (error);
}
+#if __FreeBSD_version >= 500000
mtx_init(&sc->wi_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
MTX_DEF | MTX_RECURSE);
- WI_LOCK(sc);
+#endif
+ WI_LOCK(sc, s);
/* Reset the NIC. */
wi_reset(sc);
@@ -370,7 +374,7 @@ wi_generic_attach(device_t dev)
*/
ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
callout_handle_init(&sc->wi_stat_ch);
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return(0);
}
@@ -749,7 +753,7 @@ wi_inquire(xsc)
{
struct wi_softc *sc;
struct ifnet *ifp;
- int s;
+ int s;
sc = xsc;
ifp = &sc->arpcom.ac_if;
@@ -760,9 +764,9 @@ wi_inquire(xsc)
if (ifp->if_flags & IFF_OACTIVE)
return;
- s = splimp();
+ WI_LOCK(sc, s);
wi_cmd(sc, WI_CMD_INQUIRE, WI_INFO_COUNTERS, 0, 0);
- splx(s);
+ WI_UNLOCK(sc, s);
return;
}
@@ -827,15 +831,16 @@ wi_intr(xsc)
struct wi_softc *sc = xsc;
struct ifnet *ifp;
u_int16_t status;
+ int s;
- WI_LOCK(sc);
+ WI_LOCK(sc, s);
ifp = &sc->arpcom.ac_if;
if (sc->wi_gone || !(ifp->if_flags & IFF_UP)) {
CSR_WRITE_2(sc, WI_EVENT_ACK, 0xFFFF);
CSR_WRITE_2(sc, WI_INT_EN, 0);
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -885,7 +890,7 @@ wi_intr(xsc)
wi_start(ifp);
}
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -899,6 +904,11 @@ wi_cmd(sc, cmd, val0, val1, val2)
int val2;
{
int i, s = 0;
+ static volatile int count = 0;
+
+ if (count > 1)
+ panic("Hey partner, hold on there!");
+ count++;
/* wait for the busy bit to clear */
for (i = 500; i > 0; i--) { /* 5s */
@@ -909,6 +919,7 @@ wi_cmd(sc, cmd, val0, val1, val2)
}
if (i == 0) {
device_printf(sc->dev, "wi_cmd: busy bit won't clear.\n" );
+ count--;
return(ETIMEDOUT);
}
@@ -931,19 +942,21 @@ wi_cmd(sc, cmd, val0, val1, val2)
if ((s & WI_CMD_CODE_MASK) != (cmd & WI_CMD_CODE_MASK))
return(EIO);
#endif
- if (s & WI_STAT_CMD_RESULT)
+ if (s & WI_STAT_CMD_RESULT) {
+ count--;
return(EIO);
+ }
break;
}
DELAY(WI_DELAY);
}
+ count--;
if (i == WI_TIMEOUT) {
device_printf(sc->dev,
"timeout in wi_cmd 0x%04x; event status 0x%04x\n", cmd, s);
return(ETIMEDOUT);
}
-
return(0);
}
@@ -1395,7 +1408,11 @@ wi_setmulti(sc)
return;
}
+#if __FreeBSD_version < 500000
+ LIST_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
+#else
TAILQ_FOREACH(ifma, &ifp->if_multiaddrs, ifma_link) {
+#endif
if (ifma->ifma_addr->sa_family != AF_LINK)
continue;
if (i < 16) {
@@ -1515,10 +1532,15 @@ wi_ioctl(ifp, command, data)
struct wi_req wreq;
struct ifreq *ifr;
struct ieee80211req *ireq;
+#if __FreeBSD_version >= 500000
struct thread *td = curthread;
+#else
+ struct proc *td = curproc; /* Little white lie */
+#endif
+ int s;
sc = ifp->if_softc;
- WI_LOCK(sc);
+ WI_LOCK(sc, s);
ifr = (struct ifreq *)data;
ireq = (struct ieee80211req *)data;
@@ -1881,7 +1903,7 @@ wi_ioctl(ifp, command, data)
break;
}
out:
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return(error);
}
@@ -1894,11 +1916,12 @@ wi_init(xsc)
struct ifnet *ifp = &sc->arpcom.ac_if;
struct wi_ltv_macaddr mac;
int id = 0;
+ int s;
- WI_LOCK(sc);
+ WI_LOCK(sc, s);
if (sc->wi_gone) {
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -2012,7 +2035,7 @@ wi_init(xsc)
ifp->if_flags &= ~IFF_OACTIVE;
sc->wi_stat_ch = timeout(wi_inquire, sc, hz * 60);
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -2161,24 +2184,25 @@ wi_start(ifp)
struct wi_frame tx_frame;
struct ether_header *eh;
int id;
+ int s;
sc = ifp->if_softc;
- WI_LOCK(sc);
+ WI_LOCK(sc, s);
if (sc->wi_gone) {
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
if (ifp->if_flags & IFF_OACTIVE) {
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
nextpkt:
IF_DEQUEUE(&ifp->if_snd, m0);
if (m0 == NULL) {
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -2292,7 +2316,7 @@ nextpkt:
*/
ifp->if_timer = 5;
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -2340,11 +2364,12 @@ wi_stop(sc)
struct wi_softc *sc;
{
struct ifnet *ifp;
+ int s;
- WI_LOCK(sc);
+ WI_LOCK(sc, s);
if (sc->wi_gone) {
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
@@ -2366,7 +2391,7 @@ wi_stop(sc)
ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
- WI_UNLOCK(sc);
+ WI_UNLOCK(sc, s);
return;
}
diff --git a/sys/dev/wi/if_wi_pccard.c b/sys/dev/wi/if_wi_pccard.c
index 3d1a317..ce35003 100644
--- a/sys/dev/wi/if_wi_pccard.c
+++ b/sys/dev/wi/if_wi_pccard.c
@@ -41,6 +41,7 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/socket.h>
+#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
@@ -57,7 +58,9 @@
#include <net/if_ieee80211.h>
#include <dev/pccard/pccardvar.h>
+#if __FreeBSD_version >= 500000
#include <dev/pccard/pccarddevs.h>
+#endif
#include <dev/wi/if_wavelan_ieee.h>
#include <dev/wi/wi_hostap.h>
@@ -71,10 +74,23 @@ static const char rcsid[] =
"$FreeBSD$";
#endif
-static int wi_pccard_match(device_t);
static int wi_pccard_probe(device_t);
static int wi_pccard_attach(device_t);
+#if __FreeBSD_version < 500000
+static device_method_t wi_pccard_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, wi_pccard_probe),
+ DEVMETHOD(device_attach, wi_pccard_attach),
+ DEVMETHOD(device_detach, wi_generic_detach),
+ DEVMETHOD(device_shutdown, wi_shutdown),
+
+ { 0, 0 }
+};
+
+#else
+static int wi_pccard_match(device_t);
+
static device_method_t wi_pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_compat_probe),
@@ -90,6 +106,8 @@ static device_method_t wi_pccard_methods[] = {
{ 0, 0 }
};
+#endif
+
static driver_t wi_pccard_driver = {
"wi",
wi_pccard_methods,
@@ -98,6 +116,7 @@ static driver_t wi_pccard_driver = {
DRIVER_MODULE(if_wi, pccard, wi_pccard_driver, wi_devclass, 0, 0);
+#if __FreeBSD_version >= 500000
static const struct pccard_product wi_pccard_products[] = {
PCMCIA_CARD(3COM, 3CRWE737A, 0),
PCMCIA_CARD(3COM, 3CRWE777A, 0),
@@ -150,6 +169,7 @@ wi_pccard_match(dev)
}
return ENXIO;
}
+#endif
static int
wi_pccard_probe(dev)
diff --git a/sys/dev/wi/if_wi_pci.c b/sys/dev/wi/if_wi_pci.c
index 4c91160..86af465 100644
--- a/sys/dev/wi/if_wi_pci.c
+++ b/sys/dev/wi/if_wi_pci.c
@@ -41,11 +41,13 @@
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/socket.h>
+#include <sys/systm.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <machine/bus.h>
#include <machine/resource.h>
+#include <machine/clock.h>
#include <sys/rman.h>
#include <pci/pcireg.h>
diff --git a/sys/dev/wi/if_wivar.h b/sys/dev/wi/if_wivar.h
index af1490f..470ba6d 100644
--- a/sys/dev/wi/if_wivar.h
+++ b/sys/dev/wi/if_wivar.h
@@ -160,7 +160,9 @@ struct wi_softc {
u_int32_t wi_icv;
int wi_icv_flag;
struct callout_handle wi_stat_ch;
+#if __FreeBSD_version >= 500000
struct mtx wi_mtx;
+#endif
int wi_nic_type;
int wi_bus_type; /* Bus attachment type */
struct {
@@ -188,8 +190,31 @@ struct wi_card_ident {
u_int8_t firm_type;
};
-#define WI_LOCK(_sc)
-#define WI_UNLOCK(_sc)
+#if __FreeBSD_version < 500000
+/*
+ * Various compat hacks/kludges
+ */
+#define le16toh(x) (x)
+#define htole16(x) (x)
+#define ifaddr_byindex(idx) ifnet_addrs[(idx) - 1];
+#define WI_LOCK(_sc, _s) s = splimp()
+#define WI_UNLOCK(_sc, _s) splx(s)
+#define IF_HANDOFF(q, m, ifp) \
+ if (IF_QFULL((q))) { \
+ IF_DROP((q)); \
+ m_freem((m)); \
+ } else { \
+ (ifp)->if_obytes += (m)->m_pkthdr.len; \
+ if ((m)->m_flags & M_MCAST) \
+ (ifp)->if_omcasts++; \
+ IF_ENQUEUE((q), (m)); \
+ if (((ifp)->if_flags & IFF_OACTIVE) == 0) \
+ (*(ifp)->if_start)((ifp)); \
+ }
+#else
+#define WI_LOCK(_sc, _s) _s = 1
+#define WI_UNLOCK(_sc, _s)
+#endif
int wi_generic_attach(device_t);
int wi_generic_detach(device_t);
diff --git a/sys/dev/wi/wi_hostap.c b/sys/dev/wi/wi_hostap.c
index 1cecb43..15dcafb 100644
--- a/sys/dev/wi/wi_hostap.c
+++ b/sys/dev/wi/wi_hostap.c
@@ -1120,13 +1120,18 @@ wihap_ioctl(struct wi_softc *sc, u_long command, caddr_t data)
struct hostap_sta reqsta;
struct hostap_sta stabuf;
int s, error = 0, n, flag;
+#if __FreeBSD_version >= 500000
+ struct thread *td = curthread;
+#else
+ struct proc *td = curproc; /* Little white lie */
+#endif
if (!(sc->arpcom.ac_if.if_flags & IFF_RUNNING))
return ENODEV;
switch (command) {
case SIOCHOSTAP_DEL:
- if ((error = suser(curthread)))
+ if ((error = suser(td)))
break;
if ((error = copyin(ifr->ifr_data, &reqsta, sizeof(reqsta))))
break;
@@ -1170,7 +1175,7 @@ wihap_ioctl(struct wi_softc *sc, u_long command, caddr_t data)
break;
case SIOCHOSTAP_ADD:
- if ((error = suser(curthread)))
+ if ((error = suser(td)))
break;
if ((error = copyin(ifr->ifr_data, &reqsta, sizeof(reqsta))))
break;
@@ -1194,7 +1199,7 @@ wihap_ioctl(struct wi_softc *sc, u_long command, caddr_t data)
break;
case SIOCHOSTAP_SFLAGS:
- if ((error = suser(curthread)))
+ if ((error = suser(td)))
break;
if ((error = copyin(ifr->ifr_data, &flag, sizeof(int))))
break;
OpenPOWER on IntegriCloud