diff options
-rw-r--r-- | sys/dev/pci/if_bnx.c | 103 | ||||
-rw-r--r-- | sys/dev/pci/if_bnxreg.h | 22 |
2 files changed, 56 insertions, 69 deletions
diff --git a/sys/dev/pci/if_bnx.c b/sys/dev/pci/if_bnx.c index 5005a0f631d..89368eb2aa4 100644 --- a/sys/dev/pci/if_bnx.c +++ b/sys/dev/pci/if_bnx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnx.c,v 1.3 2006/06/26 05:52:04 brad Exp $ */ +/* $OpenBSD: if_bnx.c,v 1.4 2006/08/09 15:49:49 marco Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -1794,46 +1794,42 @@ bnx_dma_free(struct bnx_softc *sc) DBPRINT(sc,BNX_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); /* Destroy the status block. */ - if (sc->status_block != NULL) { + if (sc->status_block != NULL && sc->status_map != NULL) { + bus_dmamap_unload(sc->bnx_dmatag, sc->status_map); bus_dmamem_unmap(sc->bnx_dmatag, (caddr_t)sc->status_block, BNX_STATUS_BLK_SZ); bus_dmamem_free(sc->bnx_dmatag, &sc->status_seg, sc->status_rseg); - sc->status_block = NULL; - } - if (sc->status_map != NULL) { - bus_dmamap_unload(sc->bnx_dmatag, sc->status_map); bus_dmamap_destroy(sc->bnx_dmatag, sc->status_map); + sc->status_block = NULL; + sc->status_map = NULL; } /* Destroy the statistics block. */ - if (sc->stats_block != NULL) { + if (sc->stats_block != NULL && sc->stats_map != NULL) { + bus_dmamap_unload(sc->bnx_dmatag, sc->stats_map); bus_dmamem_unmap(sc->bnx_dmatag, (caddr_t)sc->stats_block, BNX_STATS_BLK_SZ); bus_dmamem_free(sc->bnx_dmatag, &sc->stats_seg, sc->stats_rseg); - sc->stats_block = NULL; - } - if (sc->stats_map != NULL) { - bus_dmamap_unload(sc->bnx_dmatag, sc->stats_map); bus_dmamap_destroy(sc->bnx_dmatag, sc->stats_map); + sc->stats_block = NULL; + sc->stats_map = NULL; } /* Free, unmap and destroy all TX buffer descriptor chain pages. */ for (i = 0; i < TX_PAGES; i++ ) { - if (sc->tx_bd_chain[i] != NULL) { + if (sc->tx_bd_chain[i] != NULL && + sc->tx_bd_chain_map[i] != NULL) { + bus_dmamap_unload(sc->bnx_dmatag, sc->tx_bd_chain_map[i]); bus_dmamem_unmap(sc->bnx_dmatag, (caddr_t)sc->tx_bd_chain[i], BNX_TX_CHAIN_PAGE_SZ); bus_dmamem_free(sc->bnx_dmatag, &sc->tx_bd_chain_seg[i], sc->tx_bd_chain_rseg[i]); - sc->tx_bd_chain[i] = NULL; - } - - if (sc->tx_bd_chain_map[i] != NULL) { - bus_dmamap_unload(sc->bnx_dmatag, sc->tx_bd_chain_map[i]); bus_dmamap_destroy(sc->bnx_dmatag, sc->tx_bd_chain_map[i]); + sc->tx_bd_chain[i] = NULL; + sc->tx_bd_chain_map[i] = NULL; } - } /* Unload and destroy the TX mbuf maps. */ @@ -1846,19 +1842,18 @@ bnx_dma_free(struct bnx_softc *sc) /* Free, unmap and destroy all RX buffer descriptor chain pages. */ for (i = 0; i < RX_PAGES; i++ ) { - if (sc->rx_bd_chain[i] != NULL) { + if (sc->rx_bd_chain[i] != NULL && + sc->rx_bd_chain_map[i] != NULL) { + bus_dmamap_unload(sc->bnx_dmatag, sc->rx_bd_chain_map[i]); bus_dmamem_unmap(sc->bnx_dmatag, (caddr_t)sc->rx_bd_chain[i], BNX_RX_CHAIN_PAGE_SZ); bus_dmamem_free(sc->bnx_dmatag, &sc->rx_bd_chain_seg[i], sc->rx_bd_chain_rseg[i]); - sc->rx_bd_chain[i] = NULL; - } - if (sc->rx_bd_chain_map[i] != NULL) { - bus_dmamap_unload(sc->bnx_dmatag, sc->rx_bd_chain_map[i]); bus_dmamap_destroy(sc->bnx_dmatag, sc->rx_bd_chain_map[i]); + sc->rx_bd_chain[i] = NULL; + sc->rx_bd_chain_map[i] = NULL; } - } /* Unload and destroy the RX mbuf maps. */ @@ -1992,6 +1987,13 @@ bnx_dma_alloc(struct bnx_softc *sc) * Allocate DMA memory for the status block, map the memory into DMA * space, and fetch the physical address of the block. */ + if (bus_dmamap_create(sc->bnx_dmatag, BNX_STATUS_BLK_SZ, 1, + BNX_STATUS_BLK_SZ, 0, BUS_DMA_NOWAIT, &sc->status_map)) { + printf(": Could not create status block DMA map!\n"); + rc = ENOMEM; + goto bnx_dma_alloc_exit; + } + if (bus_dmamem_alloc(sc->bnx_dmatag, BNX_STATUS_BLK_SZ, BNX_DMA_ALIGN, BNX_DMA_BOUNDARY, &sc->status_seg, 1, &sc->status_rseg, BUS_DMA_NOWAIT)) { @@ -2007,13 +2009,6 @@ bnx_dma_alloc(struct bnx_softc *sc) goto bnx_dma_alloc_exit; } - if (bus_dmamap_create(sc->bnx_dmatag, BNX_STATUS_BLK_SZ, 1, - BNX_STATUS_BLK_SZ, 0, BUS_DMA_NOWAIT, &sc->status_map)) { - printf(": Could not create status block DMA map!\n"); - rc = ENOMEM; - goto bnx_dma_alloc_exit; - } - if (bus_dmamap_load(sc->bnx_dmatag, sc->status_map, sc->status_block, BNX_STATUS_BLK_SZ, NULL, BUS_DMA_NOWAIT)) { printf(": Could not load status block DMA memory!\n"); @@ -2032,6 +2027,13 @@ bnx_dma_alloc(struct bnx_softc *sc) * Allocate DMA memory for the statistics block, map the memory into * DMA space, and fetch the physical address of the block. */ + if (bus_dmamap_create(sc->bnx_dmatag, BNX_STATS_BLK_SZ, 1, + BNX_STATS_BLK_SZ, 0, BUS_DMA_NOWAIT, &sc->stats_map)) { + printf(": Could not create stats block DMA map!\n"); + rc = ENOMEM; + goto bnx_dma_alloc_exit; + } + if (bus_dmamem_alloc(sc->bnx_dmatag, BNX_STATS_BLK_SZ, BNX_DMA_ALIGN, BNX_DMA_BOUNDARY, &sc->stats_seg, 1, &sc->stats_rseg, BUS_DMA_NOWAIT)) { @@ -2047,13 +2049,6 @@ bnx_dma_alloc(struct bnx_softc *sc) goto bnx_dma_alloc_exit; } - if (bus_dmamap_create(sc->bnx_dmatag, BNX_STATS_BLK_SZ, 1, - BNX_STATS_BLK_SZ, 0, BUS_DMA_NOWAIT, &sc->stats_map)) { - printf(": Could not create stats block DMA map!\n"); - rc = ENOMEM; - goto bnx_dma_alloc_exit; - } - if (bus_dmamap_load(sc->bnx_dmatag, sc->stats_map, sc->stats_block, BNX_STATS_BLK_SZ, NULL, BUS_DMA_NOWAIT)) { printf(": Could not load status block DMA memory!\n"); @@ -2073,6 +2068,14 @@ bnx_dma_alloc(struct bnx_softc *sc) * and fetch the physical address of the block. */ for (i = 0; i < TX_PAGES; i++) { + if (bus_dmamap_create(sc->bnx_dmatag, BNX_TX_CHAIN_PAGE_SZ, 1, + BNX_TX_CHAIN_PAGE_SZ, 0, BUS_DMA_NOWAIT, + &sc->tx_bd_chain_map[i])) { + printf(": Could not create Tx desc %d DMA map!\n", i); + rc = ENOMEM; + goto bnx_dma_alloc_exit; + } + if (bus_dmamem_alloc(sc->bnx_dmatag, BNX_TX_CHAIN_PAGE_SZ, BCM_PAGE_SIZE, BNX_DMA_BOUNDARY, &sc->tx_bd_chain_seg[i], 1, &sc->tx_bd_chain_rseg[i], BUS_DMA_NOWAIT)) { @@ -2089,14 +2092,6 @@ bnx_dma_alloc(struct bnx_softc *sc) goto bnx_dma_alloc_exit; } - if (bus_dmamap_create(sc->bnx_dmatag, BNX_TX_CHAIN_PAGE_SZ, 1, - BNX_TX_CHAIN_PAGE_SZ, 0, BUS_DMA_NOWAIT, - &sc->tx_bd_chain_map[i])) { - printf(": Could not create Tx desc %d DMA map!\n", i); - rc = ENOMEM; - goto bnx_dma_alloc_exit; - } - if (bus_dmamap_load(sc->bnx_dmatag, sc->tx_bd_chain_map[i], (caddr_t)sc->tx_bd_chain[i], BNX_STATS_BLK_SZ, NULL, BUS_DMA_NOWAIT)) { @@ -2130,6 +2125,14 @@ bnx_dma_alloc(struct bnx_softc *sc) * and fetch the physical address of the block. */ for (i = 0; i < RX_PAGES; i++) { + if (bus_dmamap_create(sc->bnx_dmatag, BNX_RX_CHAIN_PAGE_SZ, 1, + BNX_RX_CHAIN_PAGE_SZ, 0, BUS_DMA_NOWAIT, + &sc->rx_bd_chain_map[i])) { + printf(": Could not create Rx desc %d DMA map!\n", i); + rc = ENOMEM; + goto bnx_dma_alloc_exit; + } + if (bus_dmamem_alloc(sc->bnx_dmatag, BNX_RX_CHAIN_PAGE_SZ, BCM_PAGE_SIZE, BNX_DMA_BOUNDARY, &sc->rx_bd_chain_seg[i], 1, &sc->rx_bd_chain_rseg[i], BUS_DMA_NOWAIT)) { @@ -2146,14 +2149,6 @@ bnx_dma_alloc(struct bnx_softc *sc) goto bnx_dma_alloc_exit; } - if (bus_dmamap_create(sc->bnx_dmatag, BNX_RX_CHAIN_PAGE_SZ, 1, - BNX_RX_CHAIN_PAGE_SZ, 0, BUS_DMA_NOWAIT, - &sc->rx_bd_chain_map[i])) { - printf(": Could not create Rx desc %d DMA map!\n", i); - rc = ENOMEM; - goto bnx_dma_alloc_exit; - } - if (bus_dmamap_load(sc->bnx_dmatag, sc->rx_bd_chain_map[i], (caddr_t)sc->rx_bd_chain[i], BNX_STATS_BLK_SZ, NULL, BUS_DMA_NOWAIT)) { diff --git a/sys/dev/pci/if_bnxreg.h b/sys/dev/pci/if_bnxreg.h index 99849985546..f2cbef78e9d 100644 --- a/sys/dev/pci/if_bnxreg.h +++ b/sys/dev/pci/if_bnxreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bnxreg.h,v 1.1 2006/06/26 04:57:54 brad Exp $ */ +/* $OpenBSD: if_bnxreg.h,v 1.2 2006/08/09 15:49:49 marco Exp $ */ /*- * Copyright (c) 2006 Broadcom Corporation @@ -685,15 +685,15 @@ struct flash_spec { #define PCI_CLRBIT(pc, tag, reg, x) pci_conf_write(pc, tag, reg, (pci_conf_read(pc, tag, reg) & ~(x))) #define BNX_STATS(x) (u_long) stats->stat_ ## x ## _lo -#if (BUS_SPACE_MAXADDR > 0xFFFFFFFF) -#define BNX_ADDR_LO(y) ((u64) (y) & 0xFFFFFFFF) -#define BNX_ADDR_HI(y) ((u64) (y) >> 32) + +#if __LP64__ +#define BNX_ADDR_LO(y) ((u64)(y) & 0xffffffff) +#define BNX_ADDR_HI(y) ((u64)(y) >> 32) #else -#define BNX_ADDR_LO(y) ((u32)y) -#define BNX_ADDR_HI(y) (0) +#define BNX_ADDR_LO(y) ((u32)(y)) +#define BNX_ADDR_HI(y) ((u32)0) #endif - /* * The following data structures are generated from RTL code. * Do not modify any values below this line. @@ -4581,14 +4581,6 @@ struct fw_info { #define BNX_DMA_ALIGN 8 #define BNX_DMA_BOUNDARY 0 -/* The BCM5708 has a problem with addresses greater that 40bits. */ -/* Handle the sizing issue in an architecture agnostic fashion. */ -#if (BUS_SPACE_MAXADDR < 0xFFFFFFFFFF) -#define BNX_BUS_SPACE_MAXADDR BUS_SPACE_MAXADDR -#else -#define BNX_BUS_SPACE_MAXADDR 0xFFFFFFFFFF -#endif - #define BNX_MIN_MTU 60 #define BNX_MIN_ETHER_MTU 64 |