diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2005-11-26 19:05:25 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2005-11-26 19:05:25 +0000 |
commit | ba980029c6ab368d404cb8a5cf7a54a9592b01b4 (patch) | |
tree | 7aed7c05be21fb9885521be4c99e1eeb7522ed63 /sys/dev/pci/if_em.c | |
parent | 803fb16ffc9b414c65471a36a091a53e8598a9c2 (diff) |
set Ethernet flow control parameters in em_hardware_init()
after the PBA size has been set.
Diffstat (limited to 'sys/dev/pci/if_em.c')
-rw-r--r-- | sys/dev/pci/if_em.c | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/sys/dev/pci/if_em.c b/sys/dev/pci/if_em.c index a2580423fb0..eee026c6b29 100644 --- a/sys/dev/pci/if_em.c +++ b/sys/dev/pci/if_em.c @@ -31,7 +31,7 @@ POSSIBILITY OF SUCH DAMAGE. ***************************************************************************/ -/* $OpenBSD: if_em.c,v 1.94 2005/11/19 22:17:15 brad Exp $ */ +/* $OpenBSD: if_em.c,v 1.95 2005/11/26 19:05:24 brad Exp $ */ /* $FreeBSD: if_em.c,v 1.46 2004/09/29 18:28:28 mlaier Exp $ */ #include <dev/pci/if_em.h> @@ -225,16 +225,6 @@ em_attach(struct device *parent, struct device *self, void *aux) sc->hw.tbi_compatibility_en = TRUE; sc->rx_buffer_len = EM_RXBUFFER_2048; - /* - * These parameters control the automatic generation(Tx) and - * response(Rx) to Ethernet PAUSE frames. - */ - sc->hw.fc_high_water = FC_DEFAULT_HI_THRESH; - sc->hw.fc_low_water = FC_DEFAULT_LO_THRESH; - sc->hw.fc_pause_time = FC_DEFAULT_TX_TIMER; - sc->hw.fc_send_xon = TRUE; - sc->hw.fc = em_fc_full; - sc->hw.phy_init_script = 1; sc->hw.phy_reset_disable = FALSE; @@ -1424,6 +1414,8 @@ em_free_pci_resources(struct em_softc *sc) int em_hardware_init(struct em_softc *sc) { + u_int16_t rx_buffer_size; + INIT_DEBUGOUT("em_hardware_init: begin"); /* Issue a global reset */ em_reset_hw(&sc->hw); @@ -1444,6 +1436,28 @@ em_hardware_init(struct em_softc *sc) return (EIO); } + /* + * These parameters control the automatic generation (Tx) and + * response (Rx) to Ethernet PAUSE frames. + * - High water mark should allow for at least two frames to be + * received after sending an XOFF. + * - Low water mark works best when it is very near the high water mark. + * This allows the receiver to restart by sending XON when it has drained + * a bit. Here we use an arbitary value of 1500 which will restart after + * one full frame is pulled from the buffer. There could be several smaller + * frames in the buffer and if so they will not trigger the XON until their + * total number reduces the buffer by 1500. + * - The pause time is fairly large at 1000 x 512ns = 512 usec. + */ + rx_buffer_size = ((E1000_READ_REG(&sc->hw, PBA) & 0xffff) << 10 ); + + sc->hw.fc_high_water = rx_buffer_size - + EM_ROUNDUP(sc->hw.max_frame_size, 1024); + sc->hw.fc_low_water = sc->hw.fc_high_water - 1500; + sc->hw.fc_pause_time = 0x1000; + sc->hw.fc_send_xon = TRUE; + sc->hw.fc = em_fc_full; + if (em_init_hw(&sc->hw) < 0) { printf("%s: Hardware Initialization Failed", sc->sc_dv.dv_xname); |