diff options
author | 2007-04-23 09:54:42 +0000 | |
---|---|---|
committer | 2007-04-23 09:54:42 +0000 | |
commit | 4ad3850fe4714e4edcce7210f1dc577f803c0a37 (patch) | |
tree | ab4077f3433be948db831755d41942f108073b1b | |
parent | Clean up an obsolete allocator. (diff) | |
download | wireguard-openbsd-4ad3850fe4714e4edcce7210f1dc577f803c0a37.tar.xz wireguard-openbsd-4ad3850fe4714e4edcce7210f1dc577f803c0a37.zip |
add tht_write_dmap, and tht_write_pad.
tht_write_dmap will walk a loaded bus_dmamap_t and write the appropriate
pbd's to the fifo.
tht_write_pad will take the length of the whole descriptor and add a 4 byte
pad to the descriptor if necessary.
-rw-r--r-- | sys/dev/pci/if_tht.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/sys/dev/pci/if_tht.c b/sys/dev/pci/if_tht.c index 52dcc2d3946..7048529c78e 100644 --- a/sys/dev/pci/if_tht.c +++ b/sys/dev/pci/if_tht.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tht.c,v 1.52 2007/04/22 13:14:11 dlg Exp $ */ +/* $OpenBSD: if_tht.c,v 1.53 2007/04/23 09:54:42 dlg Exp $ */ /* * Copyright (c) 2007 David Gwynne <dlg@openbsd.org> @@ -471,6 +471,10 @@ void tht_fifo_read(struct tht_softc *, struct tht_fifo *, void *, size_t); void tht_fifo_write(struct tht_softc *, struct tht_fifo *, void *, size_t); +void tht_fifo_write_dmap(struct tht_softc *, + struct tht_fifo *, bus_dmamap_t); +void tht_fifo_write_pad(struct tht_softc *, + struct tht_fifo *, int); void tht_fifo_post(struct tht_softc *, struct tht_fifo *); @@ -1305,6 +1309,35 @@ tht_fifo_write(struct tht_softc *sc, struct tht_fifo *tf, } void +tht_fifo_write_dmap(struct tht_softc *sc, struct tht_fifo *tf, + bus_dmamap_t dmap) +{ + struct tht_pbd pbd; + u_int64_t dva; + int i; + + for (i = 0; i < dmap->dm_nsegs; i++) { + dva = dmap->dm_segs[i].ds_addr; + + pbd.addr_lo = htole32(dva); + pbd.addr_hi = htole32(dva >> 32); + pbd.len = htole32(dmap->dm_segs[i].ds_len); + + tht_fifo_write(sc, tf, &pbd, sizeof(pbd)); + } +} + +void +tht_fifo_write_pad(struct tht_softc *sc, struct tht_fifo *tf, int bc) +{ + const static u_int32_t pad = 0x0; + + /* this assumes you'll only ever be writing multiples of 4 bytes */ + if (bc % 8) + tht_fifo_write(sc, tf, (void *)&pad, sizeof(pad)); +} + +void tht_fifo_post(struct tht_softc *sc, struct tht_fifo *tf) { bus_dmamap_sync(sc->sc_thtc->sc_dmat, THT_DMA_MAP(tf->tf_mem), |