Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Now that we're allocating rx software state from...
details: https://anonhg.NetBSD.org/src/rev/d3000b50f024
branches: trunk
changeset: 745696:d3000b50f024
user: thorpej <thorpej%NetBSD.org@localhost>
date: Mon Mar 09 01:53:11 2020 +0000
description:
Now that we're allocating rx software state from a fixed pool, we
don't have to round-trip pointers in a sketchy way -- we can round-
trip indices.
diffstat:
sys/dev/pci/if_txp.c | 19 +++++++++++++------
1 files changed, 13 insertions(+), 6 deletions(-)
diffs (62 lines):
diff -r fb6ced8ee12a -r d3000b50f024 sys/dev/pci/if_txp.c
--- a/sys/dev/pci/if_txp.c Mon Mar 09 01:47:50 2020 +0000
+++ b/sys/dev/pci/if_txp.c Mon Mar 09 01:53:11 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_txp.c,v 1.69 2020/03/09 00:32:53 thorpej Exp $ */
+/* $NetBSD: if_txp.c,v 1.70 2020/03/09 01:53:11 thorpej Exp $ */
/*
* Copyright (c) 2001
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.69 2020/03/09 00:32:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_txp.c,v 1.70 2020/03/09 01:53:11 thorpej Exp $");
#include "opt_inet.h"
@@ -678,6 +678,13 @@
sc->sc_rxd_pool[sc->sc_txd_pool_ptr++] = sd;
}
+static inline uint32_t
+txp_rxd_idx(struct txp_softc *sc, struct txp_swdesc *sd)
+{
+ KASSERT(sd >= &sc->sc_rxd[0] && sd < &sc->sc_rxd[RXBUF_ENTRIES]);
+ return (uint32_t)(sd - &sc->sc_rxd[0]);
+}
+
static void
txp_rx_reclaim(struct txp_softc *sc, struct txp_rx_ring *r,
struct txp_dma_alloc *dma)
@@ -709,7 +716,7 @@
}
/* retrieve stashed pointer */
- memcpy(&sd, __UNVOLATILE(&rxd->rx_vaddrlo), sizeof(sd));
+ sd = &sc->sc_rxd[rxd->rx_vaddrlo];
bus_dmamap_sync(sc->sc_dmat, sd->sd_map, 0,
sd->sd_map->dm_mapsize, BUS_DMASYNC_POSTREAD);
@@ -834,7 +841,7 @@
sizeof(struct txp_rxbuf_desc), BUS_DMASYNC_POSTWRITE);
/* stash away pointer */
- memcpy(__UNVOLATILE(&rbd->rb_vaddrlo), &sd, sizeof(sd));
+ rbd->rb_vaddrlo = txp_rxd_idx(sc, sd);
rbd->rb_paddrlo =
htole32(BUS_ADDR_LO32(sd->sd_map->dm_segs[0].ds_addr));
@@ -1104,9 +1111,9 @@
sc->sc_rxbufs = (struct txp_rxbuf_desc *)sc->sc_rxbufring_dma.dma_vaddr;
for (nb = 0; nb < RXBUF_ENTRIES; nb++) {
sd = &sc->sc_rxd[nb];
+
/* stash away pointer */
- memcpy(__UNVOLATILE(&sc->sc_rxbufs[nb].rb_vaddrlo), &sd,
- sizeof(sd));
+ sc->sc_rxbufs[nb].rb_vaddrlo = txp_rxd_idx(sc, sd);
MGETHDR(sd->sd_mbuf, M_WAIT, MT_DATA);
if (sd->sd_mbuf == NULL) {
Home |
Main Index |
Thread Index |
Old Index