Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 May 2012 19:11:40 +0200
From:      Bernhard Schmidt <bschmidt@freebsd.org>
To:        freebsd-wireless@freebsd.org
Cc:        freebsd-net@freebsd.org, freebsd-current@freebsd.org
Subject:   Re: [CFT] Ralink RT2860, RT2870, RT3060, RT3090 support
Message-ID:  <CAAgh0_Zk0bAmpROREH%2B1Dz1vVudEgj-N3zGMyvfWXVd0i3bFFA@mail.gmail.com>
In-Reply-To: <201205051251.10431.bschmidt@freebsd.org>
References:  <201205031853.53102.bschmidt@freebsd.org> <20120505105258.28e28803@laptop> <201205051251.10431.bschmidt@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Sat, May 5, 2012 at 12:51 PM, Bernhard Schmidt <bschmidt@freebsd.org> wrote:
> Please apply attached patch (also here [1]) on top of the first one,
> it fixes channel switching for >= 3070 (called the wrong function,
> doh..) as well as a bgscan issue.
>
> [1] http://techwires.net/~bschmidt/rt2860_1.diff

And another update [1] on top of the other 2 patches.

* fix TX DMA, a wrong dmat has been used
* add some more PCI IDs
* disable debugging output by default
* disable bgscan until it's sorted out
* a printf is now hidden behind bootverbose

So far it looks quite good, no open issues at the moment, keep on testing! ;)

If nothing new comes up within the next few days I intend to commit
this by the end of the week or something.

[1] http://techwires.net/~bschmidt/rt2860_2.diff

-- 
Bernhard

[-- Attachment #2 --]
diff --git sys/dev/ral/if_ral_pci.c sys/dev/ral/if_ral_pci.c
index 15c11bd..c3438a3 100644
--- sys/dev/ral/if_ral_pci.c
+++ sys/dev/ral/if_ral_pci.c
@@ -71,17 +71,37 @@ struct ral_pci_ident {
 };
 
 static const struct ral_pci_ident ral_pci_ids[] = {
+	{ 0x1432, 0x7708, "Edimax RT2860" },
+	{ 0x1432, 0x7711, "Edimax RT3591" },
+	{ 0x1432, 0x7722, "Edimax RT3591" },
+	{ 0x1432, 0x7727, "Edimax RT2860" },
+	{ 0x1432, 0x7728, "Edimax RT2860" },
+	{ 0x1432, 0x7738, "Edimax RT2860" },
+	{ 0x1432, 0x7748, "Edimax RT2860" },
+	{ 0x1432, 0x7758, "Edimax RT2860" },
+	{ 0x1432, 0x7768, "Edimax RT2860" },
+	{ 0x1462, 0x891a, "MSI RT3090" },
 	{ 0x1814, 0x0201, "Ralink Technology RT2560" },
 	{ 0x1814, 0x0301, "Ralink Technology RT2561S" },
 	{ 0x1814, 0x0302, "Ralink Technology RT2561" },
 	{ 0x1814, 0x0401, "Ralink Technology RT2661" },
-	{ 0x1814, 0x0601, "Ralink Technology RT2860 PCI" },
-	{ 0x1814, 0x0681, "Ralink Technology RT2860 PCIe" },
-	{ 0x1814, 0x0701, "Ralink Technology RT2870 PCI" },
-	{ 0x1814, 0x0781, "Ralink Technology RT2870 PCIe" },
-	{ 0x1814, 0x3060, "Ralink Technology RT3060 PCI" },
-	{ 0x1814, 0x3090, "Ralink Technology RT3090 PCIe" },
-
+	{ 0x1814, 0x0601, "Ralink Technology RT2860" },
+	{ 0x1814, 0x0681, "Ralink Technology RT2890" },
+	{ 0x1814, 0x0701, "Ralink Technology RT2760" },
+	{ 0x1814, 0x0781, "Ralink Technology RT2790" },
+	{ 0x1814, 0x3060, "Ralink Technology RT3060" },
+	{ 0x1814, 0x3062, "Ralink Technology RT3062" },
+	{ 0x1814, 0x3090, "Ralink Technology RT3090" },
+	{ 0x1814, 0x3091, "Ralink Technology RT3091" },
+	{ 0x1814, 0x3092, "Ralink Technology RT3092" },
+	{ 0x1814, 0x3390, "Ralink Technology RT3390" },
+	{ 0x1814, 0x3562, "Ralink Technology RT3562" },
+	{ 0x1814, 0x3592, "Ralink Technology RT3592" },
+	{ 0x1814, 0x3593, "Ralink Technology RT3593" },
+	{ 0x1814, 0x5390, "Ralink Technology RT5390" },
+	{ 0x1814, 0x539a, "Ralink Technology RT5390" },
+	{ 0x1814, 0x539f, "Ralink Technology RT5390" },
+	{ 0x1a3b, 0x1059, "AWT RT2890" },
 	{ 0, 0, NULL }
 };
 
@@ -204,18 +224,9 @@ ral_pci_attach(device_t dev)
 	case 0x0401:
 		psc->sc_opns = &ral_rt2661_opns;
 		break;
-	case 0x0601:
-	case 0x0681:
-	case 0x0701:
-	case 0x0781:
-	case 0x3060:
-	case 0x3090:
+	default:
 		psc->sc_opns = &ral_rt2860_opns;
 		break;
-	default:
-		device_printf(dev, "ERROR: Unknown card 0x%04x\n",
-		    pci_get_device(dev));
-		return (ENXIO);
 	}
 
 	psc->mem_rid = RAL_PCI_BAR0;
diff --git sys/dev/ral/rt2860.c sys/dev/ral/rt2860.c
index caa1586..97de950 100644
--- sys/dev/ral/rt2860.c
+++ sys/dev/ral/rt2860.c
@@ -71,7 +71,6 @@ __FBSDID("$FreeBSD$");
 #ifdef RAL_DEBUG
 #define DPRINTF(x)	do { if (sc->sc_debug > 0) printf x; } while (0)
 #define DPRINTFN(n, x)	do { if (sc->sc_debug >= (n)) printf x; } while (0)
-int rt2860_debug = 0;
 #else
 #define DPRINTF(x)
 #define DPRINTFN(n, x)
@@ -229,6 +228,7 @@ rt2860_attach(device_t dev, int id)
 	uint8_t macaddr[IEEE80211_ADDR_LEN];
 
 	sc->sc_dev = dev;
+	sc->sc_debug = 0;
 
 	ifp = sc->sc_ifp = if_alloc(IFT_IEEE80211);
 	if (ifp == NULL) {
@@ -264,10 +264,12 @@ rt2860_attach(device_t dev, int id)
 
 	/* retrieve RF rev. no and various other things from EEPROM */
 	rt2860_read_eeprom(sc, macaddr);
-	device_printf(sc->sc_dev,
-	    "MAC/BBP RT%X (rev 0x%04X), RF %s (MIMO %dT%dR)\n",
-	    sc->mac_ver, sc->mac_rev, rt2860_get_rf(sc->rf_rev),
-	    sc->ntxchains, sc->nrxchains);
+	if (bootverbose) {
+		device_printf(sc->sc_dev, "MAC/BBP RT%X (rev 0x%04X), "
+		    "RF %s (MIMO %dT%dR), address %6D\n",
+		    sc->mac_ver, sc->mac_rev, rt2860_get_rf(sc->rf_rev),
+		    sc->ntxchains, sc->nrxchains, macaddr, ":");
+	}
 
 	/*
 	 * Allocate Tx (4 EDCAs + HCCA + Mgt) and Rx rings.
@@ -320,7 +322,9 @@ rt2860_attach(device_t dev, int id)
 		| IEEE80211_C_SHPREAMBLE	/* short preamble supported */
 		| IEEE80211_C_SHSLOT		/* short slot time supported */
 		| IEEE80211_C_WPA		/* capable of WPA1+WPA2 */
+#if 0
 		| IEEE80211_C_BGSCAN		/* capable of bg scanning */
+#endif
 		| IEEE80211_C_WME		/* 802.11e */
 		;
 
@@ -542,14 +546,6 @@ rt2860_alloc_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring)
 
 	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
 
-	error = bus_dma_tag_create(bus_get_dma_tag(sc->sc_dev), 1, 0,
-	    BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES,
-	    RT2860_MAX_SCATTER, MCLBYTES, 0, NULL, NULL, &ring->data_dmat);
-	if (error != 0) {
-		device_printf(sc->sc_dev, "could not create data DMA tag\n");
-		goto fail;
-	}
-
 	return 0;
 
 fail:	rt2860_free_tx_ring(sc, ring);
@@ -567,9 +563,9 @@ rt2860_reset_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring)
 			continue;	/* nothing mapped in this slot */
 
 		if (data->m != NULL) {
-			bus_dmamap_sync(ring->data_dmat, data->map,
+			bus_dmamap_sync(sc->txwi_dmat, data->map,
 			    BUS_DMASYNC_POSTWRITE);
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			m_freem(data->m);
 			data->m = NULL;
 		}
@@ -606,9 +602,9 @@ rt2860_free_tx_ring(struct rt2860_softc *sc, struct rt2860_tx_ring *ring)
 			continue;	/* nothing mapped in this slot */
 
 		if (data->m != NULL) {
-			bus_dmamap_sync(ring->data_dmat, data->map,
+			bus_dmamap_sync(sc->txwi_dmat, data->map,
 			    BUS_DMASYNC_POSTWRITE);
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			m_freem(data->m);
 		}
 		if (data->ni != NULL)
@@ -1150,9 +1146,9 @@ rt2860_tx_intr(struct rt2860_softc *sc, int qid)
 		struct rt2860_tx_data *data = ring->data[ring->next];
 
 		if (data != NULL) {
-			bus_dmamap_sync(ring->data_dmat, data->map,
+			bus_dmamap_sync(sc->txwi_dmat, data->map,
 			    BUS_DMASYNC_POSTWRITE);
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			if (data->m->m_flags & M_TXCB) {
 				ieee80211_process_callback(data->ni, data->m,
 				    0);
@@ -1611,7 +1607,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 	memcpy(txwi + 1, wh, hdrlen);
 	m_adj(m, hdrlen);
 
-	error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs,
+	error = bus_dmamap_load_mbuf_sg(sc->txwi_dmat, data->map, m, segs,
 	    &nsegs, 0);
 	if (__predict_false(error != 0 && error != EFBIG)) {
 		device_printf(sc->sc_dev, "can't map mbuf (error %d)\n",
@@ -1625,7 +1621,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 
 		if (ring->queued + ntxds >= RT2860_TX_RING_COUNT) {
 			/* not enough free TXDs, force mbuf defrag */
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			error = EFBIG;
 		}
 	}
@@ -1639,7 +1635,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 		}
 		m = m1;
 
-		error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m,
+		error = bus_dmamap_load_mbuf_sg(sc->txwi_dmat, data->map, m,
 		    segs, &nsegs, 0);
 		if (__predict_false(error != 0)) {
 			device_printf(sc->sc_dev, "can't map mbuf (error %d)\n",
@@ -1653,7 +1649,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 
 		if (ring->queued + ntxds >= RT2860_TX_RING_COUNT) {
 			/* this is a hopeless case, drop the mbuf! */
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			m_freem(m);
 			return ENOBUFS;
 		}
@@ -1697,7 +1693,7 @@ rt2860_tx(struct rt2860_softc *sc, struct mbuf *m, struct ieee80211_node *ni)
 	ring->data[ring->cur] = data;
 
 	bus_dmamap_sync(sc->txwi_dmat, sc->txwi_map, BUS_DMASYNC_PREWRITE);
-	bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(sc->txwi_dmat, data->map, BUS_DMASYNC_PREWRITE);
 	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
 
 	DPRINTFN(4, ("sending frame qid=%d wcid=%d nsegs=%d ridx=%d\n",
@@ -1863,7 +1859,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m,
 	memcpy(txwi + 1, wh, hdrlen);
 	m_adj(m, hdrlen);
 
-	error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m, segs,
+	error = bus_dmamap_load_mbuf_sg(sc->txwi_dmat, data->map, m, segs,
 	    &nsegs, 0);
 	if (__predict_false(error != 0 && error != EFBIG)) {
 		device_printf(sc->sc_dev, "can't map mbuf (error %d)\n",
@@ -1877,7 +1873,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m,
 
 		if (ring->queued + ntxds >= RT2860_TX_RING_COUNT) {
 			/* not enough free TXDs, force mbuf defrag */
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			error = EFBIG;
 		}
 	}
@@ -1891,7 +1887,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m,
 		}
 		m = m1;
 
-		error = bus_dmamap_load_mbuf_sg(ring->data_dmat, data->map, m,
+		error = bus_dmamap_load_mbuf_sg(sc->txwi_dmat, data->map, m,
 		    segs, &nsegs, 0);
 		if (__predict_false(error != 0)) {
 			device_printf(sc->sc_dev, "can't map mbuf (error %d)\n",
@@ -1905,7 +1901,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m,
 
 		if (ring->queued + ntxds >= RT2860_TX_RING_COUNT) {
 			/* this is a hopeless case, drop the mbuf! */
-			bus_dmamap_unload(ring->data_dmat, data->map);
+			bus_dmamap_unload(sc->txwi_dmat, data->map);
 			m_freem(m);
 			return ENOBUFS;
 		}
@@ -1949,7 +1945,7 @@ rt2860_tx_raw(struct rt2860_softc *sc, struct mbuf *m,
 	ring->data[ring->cur] = data;
 
 	bus_dmamap_sync(sc->txwi_dmat, sc->txwi_map, BUS_DMASYNC_PREWRITE);
-	bus_dmamap_sync(ring->data_dmat, data->map, BUS_DMASYNC_PREWRITE);
+	bus_dmamap_sync(sc->txwi_dmat, data->map, BUS_DMASYNC_PREWRITE);
 	bus_dmamap_sync(ring->desc_dmat, ring->desc_map, BUS_DMASYNC_PREWRITE);
 
 	DPRINTFN(4, ("sending frame qid=%d wcid=%d nsegs=%d ridx=%d\n",
diff --git sys/dev/ral/rt2860var.h sys/dev/ral/rt2860var.h
index ffd1a1a..06b95e5 100644
--- sys/dev/ral/rt2860var.h
+++ sys/dev/ral/rt2860var.h
@@ -75,7 +75,6 @@ struct rt2860_tx_ring {
 	bus_addr_t		paddr;
 	bus_dma_tag_t		desc_dmat;
 	bus_dmamap_t		desc_map;
-	bus_dma_tag_t		data_dmat;
 	bus_dma_segment_t	seg;
 	struct rt2860_tx_data	*data[RT2860_TX_RING_COUNT];
 	int			cur;

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAAgh0_Zk0bAmpROREH%2B1Dz1vVudEgj-N3zGMyvfWXVd0i3bFFA>