> Date: Sat, 25 Jul 2009 20:43:16 -0400
> From: Brad <[email protected]>
>
> Here are some fixes for the stge(4) driver for its flow control
> support.
>
> - Bump up the un-PAUSE flow threshold from 0 to 3056 bytes.
> >From FreeBSD, also used by the Linux driver.
>
> - Update the miibus status change function to properly update the
> MAC if the PHY has negotiated flow control.
Makes sense, and although it is difficult to check the flow control
stuff is actually working, it doesn't cause any regressions.
Committed.
> Index: if_stge.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/pci/if_stge.c,v
> retrieving revision 1.46
> diff -u -p -r1.46 if_stge.c
> --- if_stge.c 21 Jul 2009 17:27:46 -0000 1.46
> +++ if_stge.c 26 Jul 2009 00:17:18 -0000
> @@ -1286,11 +1286,11 @@ stge_init(struct ifnet *ifp)
>
> /*
> * Send a PAUSE frame when we reach 29,696 bytes in the Rx
> - * FIFO, and send an un-PAUSE frame when the FIFO is totally
> - * empty again.
> + * FIFO, and send an un-PAUSE frame when we reach 3056 bytes
> + * in the Rx FIFO.
> */
> CSR_WRITE_2(sc, STGE_FlowOnTresh, 29696 / 16);
> - CSR_WRITE_2(sc, STGE_FlowOffThresh, 0);
> + CSR_WRITE_2(sc, STGE_FlowOffThresh, 3056 / 16);
>
> /*
> * Set the maximum frame size.
> @@ -1613,13 +1613,18 @@ void
> stge_mii_statchg(struct device *self)
> {
> struct stge_softc *sc = (struct stge_softc *) self;
> + struct mii_data *mii = &sc->sc_mii;
>
> - if (sc->sc_mii.mii_media_active & IFM_FDX)
> + sc->sc_MACCtrl &= ~(MC_DuplexSelect | MC_RxFlowControlEnable |
> + MC_TxFlowControlEnable);
> +
> + if (((mii->mii_media_active & IFM_GMASK) & IFM_FDX) != 0)
> sc->sc_MACCtrl |= MC_DuplexSelect;
> - else
> - sc->sc_MACCtrl &= ~MC_DuplexSelect;
>
> - /* XXX 802.1x flow-control? */
> + if (((mii->mii_media_active & IFM_GMASK) & IFM_ETH_RXPAUSE) != 0)
> + sc->sc_MACCtrl |= MC_RxFlowControlEnable;
> + if (((mii->mii_media_active & IFM_GMASK) & IFM_ETH_TXPAUSE) != 0)
> + sc->sc_MACCtrl |= MC_TxFlowControlEnable;
>
> CSR_WRITE_4(sc, STGE_MACCtrl, sc->sc_MACCtrl);
> }