iwi driver for dragonfly

Andrew Atrens atrens at nortelnetworks.com
Wed Nov 17 12:41:59 PST 2004


Patch against -

MD5 (iwi-freebsd-1.1.tgz) = d66b432d730a23e7e92e0934db248d1b

Downloadable from http://damien.bergamini.free.fr/ipw/

My patch is based on Johannes Hofmann's port. Compiles cleanly
and loads, but is not yet tested ( my card should arrive in the
next two weeks, I plan to do some testing then ).


Andrew.diff -u -r iwi-freebsd-1.1/src/sys/dev/iwi/if_iwi.c iwi-dragonfly-1.1/src/sys/dev/iwi/if_iwi.c
--- iwi-freebsd-1.1/src/sys/dev/iwi/if_iwi.c	2004-10-17 14:51:34.000000000 -0400
+++ iwi-dragonfly-1.1/src/sys/dev/iwi/if_iwi.c	2004-11-17 15:21:12.000000000 -0500
@@ -28,7 +28,6 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$Id: if_iwi.c,v 1.4 2004/10/17 18:51:34 damien Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2915ABG driver
@@ -46,14 +45,16 @@
 #include <sys/module.h>
 #include <sys/bus.h>
 #include <sys/endian.h>
+#include <sys/proc.h>
+#include <sys/ucred.h>
 
 #include <machine/bus.h>
 #include <machine/resource.h>
 #include <machine/clock.h>
 #include <sys/rman.h>
 
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
+#include <bus/pci/pcireg.h>
+#include <bus/pci/pcivar.h>
 
 #include <net/bpf.h>
 #include <net/if.h>
@@ -69,8 +70,10 @@
 #include <netinet/ip.h>
 #include <netinet/if_ether.h>
 
-#include <net80211/ieee80211_var.h>
-#include <net80211/ieee80211_radiotap.h>
+#include <netproto/802_11/ieee80211_var.h>
+#include <netproto/802_11/ieee80211_ioctl.h>
+#include <netproto/802_11/ieee80211_radiotap.h>
+#include <netproto/802_11/if_wavelan_ieee.h>
 
 #include <../../dev/iwi/if_iwireg.h>
 #include <../../dev/iwi/if_iwivar.h>
@@ -125,7 +128,7 @@
 static void iwi_watchdog(struct ifnet *);
 static int iwi_get_table0(struct iwi_softc *, u_int32_t *);
 static int iwi_get_radio(struct iwi_softc *, int *);
-static int iwi_ioctl(struct ifnet *, u_long, caddr_t);
+static int iwi_ioctl(struct ifnet *, u_long, caddr_t, struct ucred *cr);
 static int iwi_init_buffers(struct iwi_softc *, int);
 static void iwi_free_buffers(struct iwi_softc *);
 static int iwi_init_tx_queue(struct iwi_softc *, int, int);
@@ -216,9 +219,6 @@
 
 	sc->sc_dev = dev;
 
-	mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
-	    MTX_DEF | MTX_RECURSE);
-
 	if (pci_get_powerstate(dev) != PCI_POWERSTATE_D0) {
 		device_printf(dev, "chip is in D%d power mode "
 		    "-- setting to D0\n", pci_get_powerstate(dev));
@@ -314,7 +314,6 @@
 	ifp->if_start = iwi_start;
 	ifp->if_watchdog = iwi_watchdog;
 	IFQ_SET_MAXLEN(&ifp->if_snd, IFQ_MAXLEN);
-	ifp->if_snd.ifq_drv_maxlen = IFQ_MAXLEN;
 	IFQ_SET_READY(&ifp->if_snd);
 
 	ieee80211_ifattach(ifp);
@@ -323,7 +322,7 @@
 	ic->ic_newstate = iwi_newstate;
 	ieee80211_media_init(ifp, iwi_media_change, iwi_media_status);
 
-#if NBPFILTER > 0
+#ifdef WI_RAWBPF
 	bpfattach2(ifp, DLT_IEEE802_11_RADIO,
 	    sizeof (struct ieee80211_frame) + 64, &sc->sc_drvbpf);
 
@@ -357,7 +356,7 @@
 
 	IWI_UNLOCK(sc);
 
-#if NBPFILTER > 0
+#if WI_RAWBPF
 	bpfdetach(ifp);
 #endif
 	ieee80211_ifdetach(ifp);
@@ -371,8 +370,6 @@
 		bus_release_resource(dev, SYS_RES_MEMORY, IWI_PCI_BAR0,
 		    sc->mem);
 
-	mtx_destroy(&sc->sc_mtx);
-
 	return 0;
 }
 
@@ -661,7 +658,7 @@
 		wh = mtod(m, struct ieee80211_frame *);
 	}
 
-#if NBPFILTER > 0
+#ifdef WI_RAWBPF
 	if (sc->sc_drvbpf != NULL) {
 		struct iwi_rx_radiotap_header *tap = &sc->sc_rxtap;
 
@@ -702,7 +699,7 @@
 	else
 		ieee80211_free_node(ic, ni);
 
-	m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+	m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
 	if (m == NULL) {
 		device_printf(sc->sc_dev, "could not allocate rx mbuf\n");
 		return;
@@ -992,7 +989,7 @@
 	if (flags & IWI_ASYNC_CMD)
 		return 0;
 
-	return msleep(sc, &sc->sc_mtx, 0, "iwicmd", hz);
+	return tsleep(sc, 0, "iwicmd", hz);
 }
 
 static int
@@ -1010,7 +1007,7 @@
 	struct mbuf *mnew;
 	int error, i;
 
-#if NBPFILTER > 0
+#ifdef WI_RAWBPF
 	if (sc->sc_drvbpf != NULL) {
 		struct iwi_tx_radiotap_header *tap = &sc->sc_txtap;
 
@@ -1038,7 +1035,7 @@
 		return error;
 	}
 	if (error != 0) {
-		mnew = m_defrag(m, M_DONTWAIT);
+		mnew = m_defrag(m, MB_DONTWAIT);
 		if (mnew == NULL) {
 			device_printf(sc->sc_dev,
 			    "could not defragment mbuf\n");
@@ -1118,7 +1115,7 @@
 	}
 
 	for (;;) {
-		IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
+		IFQ_DEQUEUE(&ifp->if_snd, m);
 		if (m == NULL)
 			break;
 
@@ -1128,7 +1125,7 @@
 			break;
 		}
 
-#if NBPFILTER > 0
+#ifdef WI_RAWBPF
 		BPF_MTAP(ifp, m);
 #endif
 
@@ -1136,7 +1133,7 @@
 		if (m == NULL)
 			continue;
 
-#if NBPFILTER > 0
+#ifdef WI_RAWBPF
 		if (ic->ic_rawbpf != NULL)
 			bpf_mtap(ic->ic_rawbpf, m);
 #endif
@@ -1198,7 +1195,7 @@
 }
 
 static int
-iwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
+iwi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr)
 {
 	struct iwi_softc *sc = ifp->if_softc;
 	struct ieee80211com *ic = &sc->sc_ic;
@@ -1260,7 +1257,7 @@
 			break;
 
 		default:
-			error = ieee80211_ioctl(ifp, cmd, data);
+			error = ieee80211_ioctl(ifp, cmd, data, cr);
 		}
 		break;
 
@@ -1276,12 +1273,12 @@
 			break;
 
 		default:
-			error = ieee80211_ioctl(ifp, cmd, data);
+			error = ieee80211_ioctl(ifp, cmd, data, cr);
 		}
 		break;
 
 	default:
-		error = ieee80211_ioctl(ifp, cmd, data);
+		error = ieee80211_ioctl(ifp, cmd, data, cr);
 	}
 
 	if (error == ENETRESET) {
@@ -1303,8 +1300,8 @@
 	int error, i;
 
 	error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
-	    BUS_SPACE_MAXADDR, NULL, NULL, nbuf * MCLBYTES, nbuf, MCLBYTES, 0,
-	    NULL, NULL, &sc->buf_dmat);
+	    BUS_SPACE_MAXADDR, NULL, NULL, nbuf * MCLBYTES, nbuf, MCLBYTES, BUS_DMA_ALLOCNOW,
+	    &sc->buf_dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev, "could not create buffers dma tag\n");
 		goto fail;
@@ -1370,7 +1367,7 @@
 	/* Allocate DMA memory for transmission slots */
 	error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
 	    BUS_SPACE_MAXADDR, NULL, NULL, size * IWI_TX_SLOT_SIZE, 1,
-	    size * IWI_TX_SLOT_SIZE, 0, NULL, NULL, &q->dmat);
+	    size * IWI_TX_SLOT_SIZE, BUS_DMA_ALLOCNOW, &q->dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev, "could not create dma tag\n");
 		goto fail;
@@ -1460,7 +1457,7 @@
 		buf = slot->buf = TAILQ_FIRST(&sc->sc_free_buf);
 		TAILQ_REMOVE(&sc->sc_free_buf, buf, next);
 
-		buf->m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
+		buf->m = m_getcl(MB_DONTWAIT, MT_DATA, M_PKTHDR);
 		if (buf->m == NULL) {
 			device_printf(sc->sc_dev,
 			    "could not allocate rx mbuf\n");
@@ -1680,7 +1677,7 @@
 
 	/* Allocate DMA memory for storing firmware image */
 	error = bus_dma_tag_create(NULL, 4, 0, BUS_SPACE_MAXADDR_32BIT,
-	    BUS_SPACE_MAXADDR, NULL, NULL, size, 1, size, 0, NULL, NULL, &dmat);
+	    BUS_SPACE_MAXADDR, NULL, NULL, size, 1, size, BUS_DMA_ALLOCNOW, &dmat);
 	if (error != 0) {
 		device_printf(sc->sc_dev, "could not create fw dma tag\n");
 		goto fail1;
@@ -1779,7 +1776,7 @@
 	    IWI_CTL_ALLOW_STANDBY);
 
 	/* Wait at most 1 s for firmware initialization to complete */
-	if ((error = msleep(sc, &sc->sc_mtx, 0, "iwiinit", hz)) != 0) {
+	if ((error = tsleep(sc, 0, "iwiinit", hz)) != 0) {
 		device_printf(sc->sc_dev, "timeout waiting for firmware "
 		    "initialization to complete\n");
 		goto fail4;
diff -u -r iwi-freebsd-1.1/src/sys/dev/iwi/if_iwivar.h iwi-dragonfly-1.1/src/sys/dev/iwi/if_iwivar.h
--- iwi-freebsd-1.1/src/sys/dev/iwi/if_iwivar.h	2004-10-17 14:51:34.000000000 -0400
+++ iwi-dragonfly-1.1/src/sys/dev/iwi/if_iwivar.h	2004-11-17 14:51:22.000000000 -0500
@@ -108,7 +108,7 @@
 				    enum ieee80211_state, int);
 	device_t		sc_dev;	
 
-	struct mtx		sc_mtx;
+	intrmask_t		sc_intrmask;
 
 	struct iwi_firmware	fw;
 	u_int32_t		flags;
@@ -159,5 +159,5 @@
 #define SIOCGRADIO	_IOWR('i', 139, struct ifreq)
 #define SIOCGTABLE0	_IOWR('i', 140, struct ifreq)
 
-#define IWI_LOCK(sc)	mtx_lock(&(sc)->sc_mtx)
-#define IWI_UNLOCK(sc)	mtx_unlock(&(sc)->sc_mtx)
+#define IWI_LOCK(SC)	SC->sc_intrmask = splimp()
+#define IWI_UNLOCK(SC)	splx(SC->sc_intrmask)




More information about the Submit mailing list