From 14bbd30f2e95daab34254dcc58e9ee1b623cb4e0 Mon Sep 17 00:00:00 2001 From: Gleb Smirnoff Date: Sun, 18 Dec 2005 20:26:12 +0000 Subject: [PATCH] Since BGE_MBX_TX_HOST_PROD0_LO register is write-only to software, we can cache its value in the softc. Eliminates one PCI register write per call to bge_start(). A 1.8% speedup for UDP_RR test on my old box. Obtained from: NetBSD(jonathan) via delphij --- sys/dev/bge/if_bge.c | 14 ++++++++++---- sys/dev/bge/if_bgereg.h | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index 16fc559773a..e380e267c3d 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -947,11 +947,15 @@ bge_init_tx_ring(sc) sc->bge_txcnt = 0; sc->bge_tx_saved_considx = 0; - CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, 0); + /* Initialize transmit producer index for host-memory send ring. */ + sc->bge_tx_prodidx = 0; + CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, sc->bge_tx_prodidx); + /* 5700 b2 errata */ if (sc->bge_chiprev == BGE_CHIPREV_5700_BX) - CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, 0); + CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, sc->bge_tx_prodidx); + /* NIC-memory send ring not used; initialize to zero. */ CSR_WRITE_4(sc, BGE_MBX_TX_NIC_PROD0_LO, 0); /* 5700 b2 errata */ if (sc->bge_chiprev == BGE_CHIPREV_5700_BX) @@ -3040,7 +3044,7 @@ bge_start_locked(ifp) { struct bge_softc *sc; struct mbuf *m_head = NULL; - u_int32_t prodidx = 0; + uint32_t prodidx; int count = 0; sc = ifp->if_softc; @@ -3048,7 +3052,7 @@ bge_start_locked(ifp) if (!sc->bge_link || IFQ_DRV_IS_EMPTY(&ifp->if_snd)) return; - prodidx = CSR_READ_4(sc, BGE_MBX_TX_HOST_PROD0_LO); + prodidx = sc->bge_tx_prodidx; while(sc->bge_cdata.bge_tx_chain[prodidx] == NULL) { IFQ_DRV_DEQUEUE(&ifp->if_snd, m_head); @@ -3108,6 +3112,8 @@ bge_start_locked(ifp) if (sc->bge_chiprev == BGE_CHIPREV_5700_BX) CSR_WRITE_4(sc, BGE_MBX_TX_HOST_PROD0_LO, prodidx); + sc->bge_tx_prodidx = prodidx; + /* * Set a timeout in case the chip goes out to lunch. */ diff --git a/sys/dev/bge/if_bgereg.h b/sys/dev/bge/if_bgereg.h index e894e636303..9deb9595d5b 100644 --- a/sys/dev/bge/if_bgereg.h +++ b/sys/dev/bge/if_bgereg.h @@ -2416,6 +2416,7 @@ struct bge_softc { u_int32_t bge_stat_ticks; u_int32_t bge_rx_coal_ticks; u_int32_t bge_tx_coal_ticks; + u_int32_t bge_tx_prodidx; u_int32_t bge_rx_max_coal_bds; u_int32_t bge_tx_max_coal_bds; u_int32_t bge_tx_buf_ratio;