Date: Wed, 10 Jul 2013 11:35:12 +0900 From: Yonghyeon PYUN <pyunyh@gmail.com> To: Andreas Longwitz <longwitz@incore.de> Cc: freebsd-net@freebsd.org Subject: Re: sis(4) flow control Message-ID: <20130710023512.GB2753@michelle.cdnetworks.com> In-Reply-To: <51DC1599.8040805@incore.de> References: <51DC1599.8040805@incore.de>
next in thread | previous in thread | raw e-mail | index | archive | help
--1UWUbFP1cBYEclgG Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Jul 09, 2013 at 03:52:25PM +0200, Andreas Longwitz wrote: > Some of my soekris boxes run with sis interfaces. Because I need > ethernet flow control on these boxes I use the following patch (against > 8-Stable) for some years: > > --- if_sis.c.orig 2013-05-15 20:01:16.000000000 +0200 > +++ if_sis.c 2013-06-24 15:58:05.000000000 +0200 > @@ -1965,6 +1965,18 @@ > } > #endif > > + if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr >= NS_SRR_16A) { > + if (ifp->if_flags & IFF_LINK0) { > + /* > + * Configure Ethernet flow control for outgoing frames. > + * Enable reception of 802.3x multicast pause frames. > + */ > + SIS_SETBIT(sc, NS_PCR, NS_PCR_PAUSE ); > + } else { > + SIS_CLRBIT(sc, NS_PCR, NS_PCR_PAUSE ); > + } > + } > + > mii = device_get_softc(sc->sis_miibus); > > /* Set MAC address */ > > Other network drivers (eg. vr) have this functionality inside, it would > be fine if sis learns flow control too. > Hmm, does the change really make flow-control work? I believe flow-control should be negotiated with remote link partner so you have to announce flow-control capability to link partner. In addition, it seems DP83815/DP83816 does not support TX flow-control so it just honors RX pause frames. Try attached patch and let me know how it works. --1UWUbFP1cBYEclgG Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="sis.flow.diff" Index: sys/dev/sis/if_sis.c =================================================================== --- sys/dev/sis/if_sis.c (revision 253125) +++ sys/dev/sis/if_sis.c (working copy) @@ -619,10 +619,22 @@ sis_miibus_statchg(device_t dev) SIS_SETBIT(sc, SIS_TX_CFG, (SIS_TXCFG_IGN_HBEAT | SIS_TXCFG_IGN_CARR)); SIS_SETBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS); + if (sc->sis_type == SIS_TYPE_83815) { + if ((IFM_OPTIONS(mii->mii_media_active) & + IFM_ETH_RXPAUSE) != 0) + SIS_SETBIT(sc, NS_PCR, NS_PCR_PAUSE_DA | + NS_PCR_PAUSE_MCAST | NS_PCR_PAUSE_ENABLE); + else + SIS_CLRBIT(sc, NS_PCR, NS_PCR_PAUSE_DA | + NS_PCR_PAUSE_MCAST | NS_PCR_PAUSE_ENABLE); + } } else { SIS_CLRBIT(sc, SIS_TX_CFG, (SIS_TXCFG_IGN_HBEAT | SIS_TXCFG_IGN_CARR)); SIS_CLRBIT(sc, SIS_RX_CFG, SIS_RXCFG_RX_TXPKTS); + if (sc->sis_type == SIS_TYPE_83815) + SIS_CLRBIT(sc, NS_PCR, NS_PCR_PAUSE_DA | + NS_PCR_PAUSE_MCAST | NS_PCR_PAUSE_ENABLE); } if (sc->sis_type == SIS_TYPE_83815 && sc->sis_srr >= NS_SRR_16A) { @@ -1074,7 +1086,8 @@ sis_attach(device_t dev) * Do MII setup. */ error = mii_attach(dev, &sc->sis_miibus, ifp, sis_ifmedia_upd, - sis_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, 0); + sis_ifmedia_sts, BMSR_DEFCAPMASK, MII_PHY_ANY, MII_OFFSET_ANY, + sc->sis_type == SIS_TYPE_83815 ? MIIF_DOPAUSE : 0); if (error != 0) { device_printf(dev, "attaching PHYs failed\n"); goto fail; Index: sys/dev/sis/if_sisreg.h =================================================================== --- sys/dev/sis/if_sisreg.h (revision 253125) +++ sys/dev/sis/if_sisreg.h (working copy) @@ -78,6 +78,7 @@ #define NS_IHR 0x1C #define NS_CLKRUN 0x3C #define NS_WCSR 0x40 +#define NS_PCR 0x44 #define NS_SRR 0x58 #define NS_BMCR 0x80 #define NS_BMSR 0x84 @@ -123,6 +124,15 @@ #define NS_WCSR_DET_PATTERN3 0x40000000 #define NS_WCSR_DET_MAGIC 0x80000000 +#define NS_PCR_PAUSE_CNT_MASK 0x0000FFFF +#define NS_PCR_MLD_ENABLE 0x00010000 +#define NS_PCR_PAUSE_NEG 0x00200000 +#define NS_PCR_PAUSE_RCVD 0x00400000 +#define NS_PCR_PAUSE_ACT 0x00800000 +#define NS_PCR_PAUSE_DA 0x20000000 +#define NS_PCR_PAUSE_MCAST 0x40000000 +#define NS_PCR_PAUSE_ENABLE 0x80000000 + /* NS silicon revisions */ #define NS_SRR_15C 0x302 #define NS_SRR_15D 0x403 --1UWUbFP1cBYEclgG--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130710023512.GB2753>