diff options
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/cardbus/if_dc_cardbus.c | 3 | ||||
-rw-r--r-- | sys/dev/ic/dc.c | 104 | ||||
-rw-r--r-- | sys/dev/ic/dcreg.h | 18 | ||||
-rw-r--r-- | sys/dev/pci/if_dc_pci.c | 3 |
4 files changed, 96 insertions, 32 deletions
diff --git a/sys/dev/cardbus/if_dc_cardbus.c b/sys/dev/cardbus/if_dc_cardbus.c index 69713ada995..4b8c7119cdc 100644 --- a/sys/dev/cardbus/if_dc_cardbus.c +++ b/sys/dev/cardbus/if_dc_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dc_cardbus.c,v 1.6 2001/08/22 16:38:38 aaron Exp $ */ +/* $OpenBSD: if_dc_cardbus.c,v 1.7 2001/12/06 05:42:12 jason Exp $ */ #include <sys/param.h> #include <sys/systm.h> @@ -106,6 +106,7 @@ dc_cardbus_attach(parent, self, aux) cardbusreg_t reg; bus_addr_t addr; + sc->sc_dmat = ca->ca_dmat; sc->dc_unit = sc->sc_dev.dv_unit; csc->sc_ct = ct; csc->sc_tag = ca->ca_tag; diff --git a/sys/dev/ic/dc.c b/sys/dev/ic/dc.c index e8463ecc594..2f5b00b28bb 100644 --- a/sys/dev/ic/dc.c +++ b/sys/dev/ic/dc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dc.c,v 1.34 2001/11/06 19:53:18 miod Exp $ */ +/* $OpenBSD: dc.c,v 1.35 2001/12/06 05:42:12 jason Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -1587,7 +1587,7 @@ void dc_attach(sc) struct dc_softc *sc; { struct ifnet *ifp; - int error = 0, mac_offset, tmp; + int error = 0, mac_offset, tmp, i; /* * Get station address from the EEPROM. @@ -1624,21 +1624,63 @@ void dc_attach(sc) break; } + if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct dc_list_data), + PAGE_SIZE, 0, sc->sc_listseg, 1, &sc->sc_listnseg, + BUS_DMA_NOWAIT) != 0) { + printf(": can't alloc list mem\n"); + goto fail; + } + if (bus_dmamem_map(sc->sc_dmat, sc->sc_listseg, sc->sc_listnseg, + sizeof(struct dc_list_data), &sc->sc_listkva, + BUS_DMA_NOWAIT) != 0) { + printf(": can't map list mem\n"); + goto fail; + } + if (bus_dmamap_create(sc->sc_dmat, sizeof(struct dc_list_data), 1, + sizeof(struct dc_list_data), 0, BUS_DMA_NOWAIT, + &sc->sc_listmap) != 0) { + printf(": can't alloc list map\n"); + goto fail; + } + if (bus_dmamap_load(sc->sc_dmat, sc->sc_listmap, sc->sc_listkva, + sizeof(struct dc_list_data), NULL, BUS_DMA_NOWAIT) != 0) { + printf(": can't load list map\n"); + goto fail; + } + sc->dc_ldata = (struct dc_list_data *)sc->sc_listkva; + bzero(sc->dc_ldata, sizeof(struct dc_list_data)); + + for (i = 0; i < DC_TX_LIST_CNT; i++) { + if (bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, + BUS_DMA_NOWAIT, &sc->sc_txsd[i].sd_map) != 0) { + printf(": tx dmamap create failed\n"); + goto fail; + } + sc->sc_txsd[i].sd_mbuf = NULL; + if (i == DC_TX_LIST_CNT - 1) + sc->sc_txsd[i].sd_next = sc->sc_txsd; + else + sc->sc_txsd[i].sd_next = sc->sc_txsd + (i + 1); + } + + for (i = 0; i < DC_RX_LIST_CNT; i++) { + if (bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, + BUS_DMA_NOWAIT, &sc->sc_rxsd[i].sd_map) != 0) { + printf(": rx dmamap create failed\n"); + goto fail; + } + sc->sc_rxsd[i].sd_mbuf = NULL; + if (i == DC_RX_LIST_CNT - 1) + sc->sc_rxsd[i].sd_next = sc->sc_rxsd; + else + sc->sc_rxsd[i].sd_next = sc->sc_rxsd + (i + 1); + } + /* * A 21143 or clone chip was detected. Inform the world. */ printf(" address %s\n", ether_sprintf(sc->arpcom.ac_enaddr)); - sc->dc_ldata_ptr = malloc(sizeof(struct dc_list_data), M_DEVBUF, - M_NOWAIT); - if (sc->dc_ldata_ptr == NULL) { - printf("%s: no memory for list buffers!\n", sc->dc_unit); - goto fail; - } - - sc->dc_ldata = (struct dc_list_data *)sc->dc_ldata_ptr; - bzero(sc->dc_ldata, sizeof(struct dc_list_data)); - ifp = &sc->arpcom.ac_if; ifp->if_softc = sc; ifp->if_mtu = ETHERMTU; @@ -1762,20 +1804,22 @@ int dc_list_tx_init(sc) struct dc_chain_data *cd; struct dc_list_data *ld; int i; + bus_addr_t next; cd = &sc->dc_cdata; ld = sc->dc_ldata; for (i = 0; i < DC_TX_LIST_CNT; i++) { - if (i == (DC_TX_LIST_CNT - 1)) { - ld->dc_tx_list[i].dc_next = - vtophys(&ld->dc_tx_list[0]); - } else { - ld->dc_tx_list[i].dc_next = - vtophys(&ld->dc_tx_list[i + 1]); - } + next = sc->sc_listmap->dm_segs[0].ds_addr; + if (i == (DC_TX_LIST_CNT - 1)) + next += + offsetof(struct dc_list_data, dc_tx_list[0]); + else + next += + offsetof(struct dc_list_data, dc_tx_list[i + 1]); cd->dc_tx_chain[i] = NULL; ld->dc_tx_list[i].dc_data = 0; ld->dc_tx_list[i].dc_ctl = 0; + ld->dc_tx_list[i].dc_next = next; } cd->dc_tx_prod = cd->dc_tx_cons = cd->dc_tx_cnt = 0; @@ -1795,6 +1839,7 @@ int dc_list_rx_init(sc) struct dc_chain_data *cd; struct dc_list_data *ld; int i; + bus_addr_t next; cd = &sc->dc_cdata; ld = sc->dc_ldata; @@ -1802,13 +1847,14 @@ int dc_list_rx_init(sc) for (i = 0; i < DC_RX_LIST_CNT; i++) { if (dc_newbuf(sc, i, NULL) == ENOBUFS) return(ENOBUFS); - if (i == (DC_RX_LIST_CNT - 1)) { - ld->dc_rx_list[i].dc_next = - vtophys(&ld->dc_rx_list[0]); - } else { - ld->dc_rx_list[i].dc_next = - vtophys(&ld->dc_rx_list[i + 1]); - } + next = sc->sc_listmap->dm_segs[0].ds_addr; + if (i == (DC_RX_LIST_CNT - 1)) + next += + offsetof(struct dc_list_data, dc_rx_list[0]); + else + next += + offsetof(struct dc_list_data, dc_rx_list[i + 1]); + ld->dc_rx_list[i].dc_next = next; } cd->dc_rx_prod = 0; @@ -2688,8 +2734,10 @@ void dc_init(xsc) /* * Load the address of the RX list. */ - CSR_WRITE_4(sc, DC_RXADDR, vtophys(&sc->dc_ldata->dc_rx_list[0])); - CSR_WRITE_4(sc, DC_TXADDR, vtophys(&sc->dc_ldata->dc_tx_list[0])); + CSR_WRITE_4(sc, DC_RXADDR, sc->sc_listmap->dm_segs[0].ds_addr + + offsetof(struct dc_list_data, dc_rx_list[0])); + CSR_WRITE_4(sc, DC_TXADDR, sc->sc_listmap->dm_segs[0].ds_addr + + offsetof(struct dc_list_data, dc_tx_list[0])); /* * Enable interrupts. diff --git a/sys/dev/ic/dcreg.h b/sys/dev/ic/dcreg.h index 2d0af2f004e..e1e83783b04 100644 --- a/sys/dev/ic/dcreg.h +++ b/sys/dev/ic/dcreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: dcreg.h,v 1.14 2001/06/23 22:03:07 fgsch Exp $ */ +/* $OpenBSD: dcreg.h,v 1.15 2001/12/06 05:42:12 jason Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -669,6 +669,14 @@ struct dc_mii_frame { /* End of PNIC specific registers */ +/* software descriptor */ +struct dc_swdesc { + bus_dmamap_t sd_map; + struct mbuf * sd_mbuf; + struct dc_swdesc * sd_next; +}; + + struct dc_softc { struct device sc_dev; void *sc_ih; @@ -695,7 +703,6 @@ struct dc_softc { u_int8_t *dc_srom; struct dc_mediainfo *dc_mi; struct dc_list_data *dc_ldata; - caddr_t dc_ldata_ptr; struct dc_chain_data dc_cdata; u_int32_t dc_csid; u_int dc_revision; @@ -703,6 +710,13 @@ struct dc_softc { #ifdef SRM_MEDIA int dc_srm_media; #endif + bus_dma_tag_t sc_dmat; + bus_dmamap_t sc_listmap; + bus_dma_segment_t sc_listseg[1]; + int sc_listnseg; + caddr_t sc_listkva; + struct dc_swdesc sc_txsd[DC_TX_LIST_CNT]; + struct dc_swdesc sc_rxsd[DC_RX_LIST_CNT]; }; #define DC_TX_POLL 0x00000001 diff --git a/sys/dev/pci/if_dc_pci.c b/sys/dev/pci/if_dc_pci.c index 14412d74ab6..c916d3e3089 100644 --- a/sys/dev/pci/if_dc_pci.c +++ b/sys/dev/pci/if_dc_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_dc_pci.c,v 1.19 2001/11/06 19:53:19 miod Exp $ */ +/* $OpenBSD: if_dc_pci.c,v 1.20 2001/12/06 05:42:12 jason Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -190,6 +190,7 @@ void dc_pci_attach(parent, self, aux) int found = 0; s = splimp(); + sc->sc_dmat = pa->pa_dmat; sc->dc_unit = sc->sc_dev.dv_unit; /* |