summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2007-11-19 19:34:26 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2007-11-19 19:34:26 +0000
commit338d40982ed6fccaa410c5f88a483e3f27e54c10 (patch)
treee755bbdca5d813707f421c0a1cbd1f72a90ddf97
parent6ffc97ca5bbfd227c58b312f42dd1675553ec0e9 (diff)
all TX rings have the same fixed size (256 entries) and this is not
configurable so simplify rings allocation a bit.
-rw-r--r--sys/dev/pci/if_iwn.c53
-rw-r--r--sys/dev/pci/if_iwnvar.h5
-rw-r--r--sys/dev/pci/if_wpi.c53
-rw-r--r--sys/dev/pci/if_wpivar.h5
4 files changed, 42 insertions, 74 deletions
diff --git a/sys/dev/pci/if_iwn.c b/sys/dev/pci/if_iwn.c
index fb2f2d7cda4..791312ffb17 100644
--- a/sys/dev/pci/if_iwn.c
+++ b/sys/dev/pci/if_iwn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwn.c,v 1.12 2007/11/17 18:50:54 damien Exp $ */
+/* $OpenBSD: if_iwn.c,v 1.13 2007/11/19 19:34:25 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -92,7 +92,7 @@ int iwn_alloc_rx_ring(struct iwn_softc *, struct iwn_rx_ring *);
void iwn_reset_rx_ring(struct iwn_softc *, struct iwn_rx_ring *);
void iwn_free_rx_ring(struct iwn_softc *, struct iwn_rx_ring *);
int iwn_alloc_tx_ring(struct iwn_softc *, struct iwn_tx_ring *,
- int, int);
+ int);
void iwn_reset_tx_ring(struct iwn_softc *, struct iwn_tx_ring *);
void iwn_free_tx_ring(struct iwn_softc *, struct iwn_tx_ring *);
struct ieee80211_node *iwn_node_alloc(struct ieee80211com *);
@@ -273,16 +273,13 @@ iwn_attach(struct device *parent, struct device *self, void *aux)
}
for (i = 0; i < IWN_NTXQUEUES; i++) {
- struct iwn_tx_ring *txq = &sc->txq[i];
- error = iwn_alloc_tx_ring(sc, txq, IWN_TX_RING_COUNT, i);
- if (error != 0) {
+ if ((error = iwn_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
printf(": could not allocate Tx ring %d\n", i);
goto fail4;
}
}
- error = iwn_alloc_rx_ring(sc, &sc->rxq);
- if (error != 0) {
+ if ((error = iwn_alloc_rx_ring(sc, &sc->rxq)) != 0) {
printf(": could not allocate Rx ring\n");
goto fail4;
}
@@ -660,43 +657,34 @@ iwn_free_rx_ring(struct iwn_softc *sc, struct iwn_rx_ring *ring)
}
int
-iwn_alloc_tx_ring(struct iwn_softc *sc, struct iwn_tx_ring *ring, int count,
- int qid)
+iwn_alloc_tx_ring(struct iwn_softc *sc, struct iwn_tx_ring *ring, int qid)
{
+ bus_size_t size;
int i, error;
ring->qid = qid;
- ring->count = count;
ring->queued = 0;
ring->cur = 0;
+ size = IWN_TX_RING_COUNT * sizeof (struct iwn_tx_desc);
error = iwn_dma_contig_alloc(sc->sc_dmat, &ring->desc_dma,
- (void **)&ring->desc, count * sizeof (struct iwn_tx_desc),
- IWN_RING_DMA_ALIGN, BUS_DMA_NOWAIT);
+ (void **)&ring->desc, size, IWN_RING_DMA_ALIGN, BUS_DMA_NOWAIT);
if (error != 0) {
printf("%s: could not allocate tx ring DMA memory\n",
sc->sc_dev.dv_xname);
goto fail;
}
+ size = IWN_TX_RING_COUNT * sizeof (struct iwn_tx_cmd);
error = iwn_dma_contig_alloc(sc->sc_dmat, &ring->cmd_dma,
- (void **)&ring->cmd, count * sizeof (struct iwn_tx_cmd), 4,
- BUS_DMA_NOWAIT);
+ (void **)&ring->cmd, size, 4, BUS_DMA_NOWAIT);
if (error != 0) {
printf("%s: could not allocate tx cmd DMA memory\n",
sc->sc_dev.dv_xname);
goto fail;
}
- ring->data = malloc(count * sizeof (struct iwn_tx_data), M_DEVBUF,
- M_NOWAIT | M_ZERO);
- if (ring->data == NULL) {
- printf("%s: could not allocate tx data slots\n",
- sc->sc_dev.dv_xname);
- goto fail;
- }
-
- for (i = 0; i < count; i++) {
+ for (i = 0; i < IWN_TX_RING_COUNT; i++) {
struct iwn_tx_data *data = &ring->data[i];
error = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
@@ -738,7 +726,7 @@ iwn_reset_tx_ring(struct iwn_softc *sc, struct iwn_tx_ring *ring)
#endif
iwn_mem_unlock(sc);
- for (i = 0; i < ring->count; i++) {
+ for (i = 0; i < IWN_TX_RING_COUNT; i++) {
struct iwn_tx_data *data = &ring->data[i];
if (data->m != NULL) {
@@ -760,16 +748,13 @@ iwn_free_tx_ring(struct iwn_softc *sc, struct iwn_tx_ring *ring)
iwn_dma_contig_free(&ring->desc_dma);
iwn_dma_contig_free(&ring->cmd_dma);
- if (ring->data != NULL) {
- for (i = 0; i < ring->count; i++) {
- struct iwn_tx_data *data = &ring->data[i];
+ for (i = 0; i < IWN_TX_RING_COUNT; i++) {
+ struct iwn_tx_data *data = &ring->data[i];
- if (data->m != NULL) {
- bus_dmamap_unload(sc->sc_dmat, data->map);
- m_freem(data->m);
- }
+ if (data->m != NULL) {
+ bus_dmamap_unload(sc->sc_dmat, data->map);
+ m_freem(data->m);
}
- free(ring->data, M_DEVBUF);
}
}
@@ -1915,7 +1900,7 @@ iwn_start(struct ifnet *ifp)
IF_POLL(&ic->ic_mgtq, m0);
if (m0 != NULL) {
/* management frames go into ring 0 */
- if (sc->txq[0].queued >= sc->txq[0].count - 8) {
+ if (sc->txq[0].queued >= IWN_TX_RING_COUNT - 8) {
ifp->if_flags |= IFF_OACTIVE;
break;
}
@@ -1936,7 +1921,7 @@ iwn_start(struct ifnet *ifp)
IFQ_POLL(&ifp->if_snd, m0);
if (m0 == NULL)
break;
- if (sc->txq[0].queued >= sc->txq[0].count - 8) {
+ if (sc->txq[0].queued >= IWN_TX_RING_COUNT - 8) {
/* there is no place left in this ring */
ifp->if_flags |= IFF_OACTIVE;
break;
diff --git a/sys/dev/pci/if_iwnvar.h b/sys/dev/pci/if_iwnvar.h
index 7e430d79979..6c1affe3186 100644
--- a/sys/dev/pci/if_iwnvar.h
+++ b/sys/dev/pci/if_iwnvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_iwnvar.h,v 1.1 2007/09/06 16:37:03 damien Exp $ */
+/* $OpenBSD: if_iwnvar.h,v 1.2 2007/11/19 19:34:25 damien Exp $ */
/*-
* Copyright (c) 2007
@@ -71,9 +71,8 @@ struct iwn_tx_ring {
struct iwn_dma_info cmd_dma;
struct iwn_tx_desc *desc;
struct iwn_tx_cmd *cmd;
- struct iwn_tx_data *data;
+ struct iwn_tx_data data[IWN_TX_RING_COUNT];
int qid;
- int count;
int queued;
int cur;
};
diff --git a/sys/dev/pci/if_wpi.c b/sys/dev/pci/if_wpi.c
index 1c795cde7ad..d608e619b3a 100644
--- a/sys/dev/pci/if_wpi.c
+++ b/sys/dev/pci/if_wpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpi.c,v 1.57 2007/11/03 13:10:29 damien Exp $ */
+/* $OpenBSD: if_wpi.c,v 1.58 2007/11/19 19:34:25 damien Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -90,7 +90,7 @@ int wpi_alloc_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
void wpi_reset_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
void wpi_free_rx_ring(struct wpi_softc *, struct wpi_rx_ring *);
int wpi_alloc_tx_ring(struct wpi_softc *, struct wpi_tx_ring *,
- int, int);
+ int);
void wpi_reset_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
void wpi_free_tx_ring(struct wpi_softc *, struct wpi_tx_ring *);
struct ieee80211_node *wpi_node_alloc(struct ieee80211com *);
@@ -250,16 +250,13 @@ wpi_attach(struct device *parent, struct device *self, void *aux)
}
for (i = 0; i < WPI_NTXQUEUES; i++) {
- struct wpi_tx_ring *txq = &sc->txq[i];
- error = wpi_alloc_tx_ring(sc, txq, WPI_TX_RING_COUNT, i);
- if (error != 0) {
+ if ((error = wpi_alloc_tx_ring(sc, &sc->txq[i], i)) != 0) {
printf(": could not allocate Tx ring %d\n", i);
goto fail3;
}
}
- error = wpi_alloc_rx_ring(sc, &sc->rxq);
- if (error != 0) {
+ if ((error = wpi_alloc_rx_ring(sc, &sc->rxq)) != 0) {
printf(": could not allocate Rx ring\n");
goto fail3;
}
@@ -629,19 +626,18 @@ wpi_free_rx_ring(struct wpi_softc *sc, struct wpi_rx_ring *ring)
}
int
-wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int count,
- int qid)
+wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int qid)
{
+ bus_size_t size;
int i, error;
ring->qid = qid;
- ring->count = count;
ring->queued = 0;
ring->cur = 0;
+ size = WPI_TX_RING_COUNT * sizeof (struct wpi_tx_desc);
error = wpi_dma_contig_alloc(sc->sc_dmat, &ring->desc_dma,
- (void **)&ring->desc, count * sizeof (struct wpi_tx_desc),
- WPI_RING_DMA_ALIGN, BUS_DMA_NOWAIT);
+ (void **)&ring->desc, size, WPI_RING_DMA_ALIGN, BUS_DMA_NOWAIT);
if (error != 0) {
printf("%s: could not allocate tx ring DMA memory\n",
sc->sc_dev.dv_xname);
@@ -651,24 +647,16 @@ wpi_alloc_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring, int count,
/* update shared page with ring's base address */
sc->shared->txbase[qid] = htole32(ring->desc_dma.paddr);
+ size = WPI_TX_RING_COUNT * sizeof (struct wpi_tx_cmd);
error = wpi_dma_contig_alloc(sc->sc_dmat, &ring->cmd_dma,
- (void **)&ring->cmd, count * sizeof (struct wpi_tx_cmd), 4,
- BUS_DMA_NOWAIT);
+ (void **)&ring->cmd, size, 4, BUS_DMA_NOWAIT);
if (error != 0) {
printf("%s: could not allocate tx cmd DMA memory\n",
sc->sc_dev.dv_xname);
goto fail;
}
- ring->data = malloc(count * sizeof (struct wpi_tx_data), M_DEVBUF,
- M_NOWAIT | M_ZERO);
- if (ring->data == NULL) {
- printf("%s: could not allocate tx data slots\n",
- sc->sc_dev.dv_xname);
- goto fail;
- }
-
- for (i = 0; i < count; i++) {
+ for (i = 0; i < WPI_TX_RING_COUNT; i++) {
struct wpi_tx_data *data = &ring->data[i];
error = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
@@ -710,7 +698,7 @@ wpi_reset_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring)
#endif
wpi_mem_unlock(sc);
- for (i = 0; i < ring->count; i++) {
+ for (i = 0; i < WPI_TX_RING_COUNT; i++) {
struct wpi_tx_data *data = &ring->data[i];
if (data->m != NULL) {
@@ -732,16 +720,13 @@ wpi_free_tx_ring(struct wpi_softc *sc, struct wpi_tx_ring *ring)
wpi_dma_contig_free(&ring->desc_dma);
wpi_dma_contig_free(&ring->cmd_dma);
- if (ring->data != NULL) {
- for (i = 0; i < ring->count; i++) {
- struct wpi_tx_data *data = &ring->data[i];
+ for (i = 0; i < WPI_TX_RING_COUNT; i++) {
+ struct wpi_tx_data *data = &ring->data[i];
- if (data->m != NULL) {
- bus_dmamap_unload(sc->sc_dmat, data->map);
- m_freem(data->m);
- }
+ if (data->m != NULL) {
+ bus_dmamap_unload(sc->sc_dmat, data->map);
+ m_freem(data->m);
}
- free(ring->data, M_DEVBUF);
}
}
@@ -1792,7 +1777,7 @@ wpi_start(struct ifnet *ifp)
IF_POLL(&ic->ic_mgtq, m0);
if (m0 != NULL) {
/* management frames go into ring 0 */
- if (sc->txq[0].queued >= sc->txq[0].count - 8) {
+ if (sc->txq[0].queued >= WPI_TX_RING_COUNT - 8) {
ifp->if_flags |= IFF_OACTIVE;
break;
}
@@ -1813,7 +1798,7 @@ wpi_start(struct ifnet *ifp)
IFQ_POLL(&ifp->if_snd, m0);
if (m0 == NULL)
break;
- if (sc->txq[0].queued >= sc->txq[0].count - 8) {
+ if (sc->txq[0].queued >= WPI_TX_RING_COUNT - 8) {
/* there is no place left in this ring */
ifp->if_flags |= IFF_OACTIVE;
break;
diff --git a/sys/dev/pci/if_wpivar.h b/sys/dev/pci/if_wpivar.h
index 29b51f04962..4e85b81c9e5 100644
--- a/sys/dev/pci/if_wpivar.h
+++ b/sys/dev/pci/if_wpivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_wpivar.h,v 1.14 2007/09/11 18:52:32 damien Exp $ */
+/* $OpenBSD: if_wpivar.h,v 1.15 2007/11/19 19:34:25 damien Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -73,9 +73,8 @@ struct wpi_tx_ring {
struct wpi_dma_info cmd_dma;
struct wpi_tx_desc *desc;
struct wpi_tx_cmd *cmd;
- struct wpi_tx_data *data;
+ struct wpi_tx_data data[WPI_TX_RING_COUNT];
int qid;
- int count;
int queued;
int cur;
};