Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci bus_dmamap_sync for rx descriptors too, derived ...
details: https://anonhg.NetBSD.org/src/rev/aa880c6afeed
branches: trunk
changeset: 331224:aa880c6afeed
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Tue Aug 05 21:54:39 2014 +0000
description:
bus_dmamap_sync for rx descriptors too, derived from openbsd driver
diffstat:
sys/dev/pci/if_wpi.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++---
sys/dev/pci/if_wpivar.h | 5 +++--
2 files changed, 49 insertions(+), 5 deletions(-)
diffs (142 lines):
diff -r 449ff5ca064d -r aa880c6afeed sys/dev/pci/if_wpi.c
--- a/sys/dev/pci/if_wpi.c Tue Aug 05 20:28:56 2014 +0000
+++ b/sys/dev/pci/if_wpi.c Tue Aug 05 21:54:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wpi.c,v 1.63 2014/08/05 17:25:16 jmcneill Exp $ */
+/* $NetBSD: if_wpi.c,v 1.64 2014/08/05 21:54:39 jmcneill Exp $ */
/*-
* Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.63 2014/08/05 17:25:16 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.64 2014/08/05 21:54:39 jmcneill Exp $");
/*
* Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -628,6 +628,14 @@
struct wpi_rx_data *data = &ring->data[i];
struct wpi_rbuf *rbuf;
+ error = bus_dmamap_create(sc->sc_dmat, WPI_RBUF_SIZE, 1,
+ WPI_RBUF_SIZE, 0, BUS_DMA_NOWAIT, &data->map);
+ if (error) {
+ aprint_error_dev(sc->sc_dev,
+ "could not allocate rx dma map\n");
+ goto fail;
+ }
+
MGETHDR(data->m, M_DONTWAIT, MT_DATA);
if (data->m == NULL) {
aprint_error_dev(sc->sc_dev,
@@ -648,6 +656,15 @@
rbuf);
data->m->m_flags |= M_EXT_RW;
+ error = bus_dmamap_load(sc->sc_dmat, data->map,
+ mtod(data->m, void *), WPI_RBUF_SIZE, NULL,
+ BUS_DMA_NOWAIT | BUS_DMA_READ);
+ if (error) {
+ aprint_error_dev(sc->sc_dev,
+ "could not load mbuf: %d\n", error);
+ goto fail;
+ }
+
ring->desc[i] = htole32(rbuf->paddr);
}
@@ -690,8 +707,13 @@
wpi_dma_contig_free(&ring->desc_dma);
for (i = 0; i < WPI_RX_RING_COUNT; i++) {
- if (ring->data[i].m != NULL)
+ if (ring->data[i].m != NULL) {
+ bus_dmamap_unload(sc->sc_dmat, ring->data[i].map);
m_freem(ring->data[i].m);
+ }
+ if (ring->data[i].map != NULL) {
+ bus_dmamap_destroy(sc->sc_dmat, ring->data[i].map);
+ }
}
}
@@ -1451,6 +1473,8 @@
struct mbuf *m, *mnew;
int data_off;
+ bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize,
+ BUS_DMASYNC_POSTREAD);
stat = (struct wpi_rx_stat *)(desc + 1);
if (stat->len > WPI_STAT_MAXLEN) {
@@ -1506,6 +1530,7 @@
return;
}
} else {
+ int error;
MGETHDR(mnew, M_DONTWAIT, MT_DATA);
if (mnew == NULL) {
@@ -1521,11 +1546,23 @@
rbuf);
mnew->m_flags |= M_EXT_RW;
+ bus_dmamap_unload(sc->sc_dmat, data->map);
m = data->m;
data->m = mnew;
+ error = bus_dmamap_load(sc->sc_dmat, data->map,
+ mtod(data->m, void *), WPI_RBUF_SIZE, NULL,
+ BUS_DMA_NOWAIT | BUS_DMA_READ);
+ if (error) {
+ panic("%s: bus_dmamap_load failed: %d\n",
+ device_xname(sc->sc_dev), error);
+ }
+
/* update Rx descriptor */
ring->desc[ring->cur] = htole32(rbuf->paddr);
+ bus_dmamap_sync(sc->sc_dmat, ring->desc_dma.map, 0,
+ ring->desc_dma.size,
+ BUS_DMASYNC_PREWRITE);
m->m_data = (char*)m->m_data + data_off;
m->m_pkthdr.len = m->m_len = le16toh(head->len);
@@ -1655,11 +1692,17 @@
struct ifnet *ifp = ic->ic_ifp;
uint32_t hw;
+ bus_dmamap_sync(sc->sc_dmat, sc->shared_dma.map, 0,
+ sizeof(struct wpi_shared), BUS_DMASYNC_POSTREAD);
+
hw = le32toh(sc->shared->next);
while (sc->rxq.cur != hw) {
struct wpi_rx_data *data = &sc->rxq.data[sc->rxq.cur];
struct wpi_rx_desc *desc = mtod(data->m, struct wpi_rx_desc *);
+ bus_dmamap_sync(sc->sc_dmat, data->map, 0, data->map->dm_mapsize,
+ BUS_DMASYNC_POSTREAD);
+
DPRINTFN(4, ("rx notification qid=%x idx=%d flags=%x type=%d "
"len=%d\n", desc->qid, desc->idx, desc->flags,
desc->type, le32toh(desc->len)));
diff -r 449ff5ca064d -r aa880c6afeed sys/dev/pci/if_wpivar.h
--- a/sys/dev/pci/if_wpivar.h Tue Aug 05 20:28:56 2014 +0000
+++ b/sys/dev/pci/if_wpivar.h Tue Aug 05 21:54:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_wpivar.h,v 1.15 2010/01/19 22:07:02 pooka Exp $ */
+/* $NetBSD: if_wpivar.h,v 1.16 2014/08/05 21:54:39 jmcneill Exp $ */
/*-
* Copyright (c) 2006
@@ -92,7 +92,8 @@
};
struct wpi_rx_data {
- struct mbuf *m;
+ bus_dmamap_t map;
+ struct mbuf *m;
};
struct wpi_rx_ring {
Home |
Main Index |
Thread Index |
Old Index