From owner-freebsd-net@FreeBSD.ORG Wed Jul 10 02:35:20 2013 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E80049D6 for ; Wed, 10 Jul 2013 02:35:20 +0000 (UTC) (envelope-from pyunyh@gmail.com) Received: from mail-pa0-x229.google.com (mail-pa0-x229.google.com [IPv6:2607:f8b0:400e:c03::229]) by mx1.freebsd.org (Postfix) with ESMTP id C3D811CC7 for ; Wed, 10 Jul 2013 02:35:20 +0000 (UTC) Received: by mail-pa0-f41.google.com with SMTP id bj3so6220963pad.0 for ; Tue, 09 Jul 2013 19:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:date:to:cc:subject:message-id:reply-to:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=EsZkKECbNRjnfTF7+4BF0riusX0GT8AbUdc5P9hElMQ=; b=VH0zWGtc7BDyq2xwBsk6DVRwTrrUVD/uGnnKSv7pJmHfaUObM7J0gbusdW0STs4A+R 089tMvRY14yVvnZEu+nXp168nPcwcNJ1rgtdJtKE0pgv5AZw5CENj9mR267vTl2i5mfN 3U7omEhdg/KC724kRmYQCV+mH77a3iPSx2RqaoQ3z8Qnvd3dGC+S7GD+IFVxmKq6MuTs TLynX8csFIeX4UOpP+yjDS0uhfxSqZtvda3GtAgnONyKZUM8EqV/QF7YevP7t7wBU8Nk dzmQFSWN22MFRoChU0UjQVBT2fsCIZeUK3YOdfpaJZ+7zeTMEPdjPPzS5tB8PsxAPC1C WKvw== X-Received: by 10.68.239.164 with SMTP id vt4mr19322101pbc.115.1373423720581; Tue, 09 Jul 2013 19:35:20 -0700 (PDT) Received: from pyunyh@gmail.com (lpe4.p59-icn.cdngp.net. [114.111.62.249]) by mx.google.com with ESMTPSA id dg3sm31112996pbc.24.2013.07.09.19.35.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 09 Jul 2013 19:35:19 -0700 (PDT) Received: by pyunyh@gmail.com (sSMTP sendmail emulation); Wed, 10 Jul 2013 11:35:12 +0900 From: Yonghyeon PYUN Date: Wed, 10 Jul 2013 11:35:12 +0900 To: Andreas Longwitz Subject: Re: sis(4) flow control Message-ID: <20130710023512.GB2753@michelle.cdnetworks.com> References: <51DC1599.8040805@incore.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="1UWUbFP1cBYEclgG" Content-Disposition: inline In-Reply-To: <51DC1599.8040805@incore.de> User-Agent: Mutt/1.4.2.3i Cc: freebsd-net@freebsd.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: pyunyh@gmail.com List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 02:35:21 -0000 --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--