From mbertsch@core.radioactivedata.org  Thu Feb 28 11:38:17 2002
Return-Path: <mbertsch@core.radioactivedata.org>
Received: from core.radioactivedata.org (146-115-123-124.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com [146.115.123.124])
	by hub.freebsd.org (Postfix) with ESMTP id 6042837B405
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 28 Feb 2002 11:38:15 -0800 (PST)
Received: (from mbertsch@localhost)
	by core.radioactivedata.org (8.11.6/8.9.3) id g1S1wGa24290;
	Wed, 27 Feb 2002 20:58:16 -0500 (EST)
	(envelope-from mbertsch)
Message-Id: <200202280158.g1S1wGa24290@core.radioactivedata.org>
Date: Wed, 27 Feb 2002 20:58:16 -0500 (EST)
From: Mike DeGraw-Bertsch <mbertsch@radioactivedata.org>
Reply-To: Mike DeGraw-Bertsch <mbertsch@radioactivedata.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] Nit typo in security.7
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         35422
>Category:       docs
>Synopsis:       [PATCH] Nit typo in security.7
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-doc
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          doc-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Feb 28 11:40:01 PST 2002
>Closed-Date:    Thu Feb 28 14:46:58 PST 2002
>Last-Modified:  Fri Oct  8 21:00:09 UTC 2010
>Originator:     Mike DeGraw-Bertsch
>Release:        FreeBSD 4.5-PRERELEASE i386
>Organization:
>Environment:
System: FreeBSD core.radioactivedata.org 4.5-PRERELEASE FreeBSD 4.5-PRERELEASE #0: Sun Feb 10 15:18:22 EST 2002 root@core.radioactivedata.org:/usr/src/sys/compile/GENERIC i386

>Description:
security.7 reads "...by putting the min the wheel group..." instead of "...them in..."

>How-To-Repeat:
man security.7

>Fix:

*** security.7  Wed Feb 27 20:46:39 2002
--- security.7.fix      Tue Feb 26 14:23:15 2002
***************
*** 159,165 ****
  in the wheel group are allowed to
  .Sq su
  to root.  You should never give staff
! members native wheel access by putting the min the wheel group in their
  password entry.  Staff accounts should be placed in a
  .Sq staff
  group, and then added to the wheel group via the
--- 159,165 ----
  in the wheel group are allowed to
  .Sq su
  to root.  You should never give staff
! members native wheel access by putting them in the wheel group in their
  password entry.  Staff accounts should be placed in a
  .Sq staff
  group, and then added to the wheel group via the

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: keramida 
State-Changed-When: Thu Feb 28 14:46:58 PST 2002 
State-Changed-Why:  
Change committed to both -CURRENT and -STABLE. 
Thank you :-) 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=35422 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/35422: commit references a PR
Date: Thu,  2 Sep 2010 18:10:25 +0000 (UTC)

 Author: yongari
 Date: Thu Sep  2 18:10:11 2010
 New Revision: 212157
 URL: http://svn.freebsd.org/changeset/base/212157
 
 Log:
   Unlike most other controllers, NS DP83815/DP83816 controllers seem
   to pad with 0xFF when it encounter short frames.  According to RFC
   1042 the pad bytes should be 0x00.
   Because manual padding consumes extra CPU cycles, introduce a new
   tunable which controls the padding behavior. Turning this tunable
   on will have driver pad manually but it's disabled by default. Users
   can enable software padding by setting the following tunable to
   non-zero value.
   
   dev.sis.%d.manual_pad="1"
   
   PR:	kern/35422 (patch not used)
 
 Modified:
   head/sys/dev/sis/if_sis.c
   head/sys/dev/sis/if_sisreg.h
 
 Modified: head/sys/dev/sis/if_sis.c
 ==============================================================================
 --- head/sys/dev/sis/if_sis.c	Thu Sep  2 17:51:41 2010	(r212156)
 +++ head/sys/dev/sis/if_sis.c	Thu Sep  2 18:10:11 2010	(r212157)
 @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
  #include <sys/module.h>
  #include <sys/socket.h>
  #include <sys/sockio.h>
 +#include <sys/sysctl.h>
  
  #include <net/if.h>
  #include <net/if_arp.h>
 @@ -150,6 +151,7 @@ static int sis_rxeof(struct sis_softc *)
  static void sis_start(struct ifnet *);
  static void sis_startl(struct ifnet *);
  static void sis_stop(struct sis_softc *);
 +static void sis_add_sysctls(struct sis_softc *);
  static void sis_watchdog(struct sis_softc *);
  
  
 @@ -710,24 +712,24 @@ sis_miibus_statchg(device_t dev)
  	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
  		return;
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
  	    (IFM_ACTIVE | IFM_AVALID)) {
  		switch (IFM_SUBTYPE(mii->mii_media_active)) {
  		case IFM_10_T:
 -			sc->sis_link++;
  			CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_10);
 +			sc->sis_flags |= SIS_FLAG_LINK;
  			break;
  		case IFM_100_TX:
 -			sc->sis_link++;
  			CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100);
 +			sc->sis_flags |= SIS_FLAG_LINK;
  			break;
  		default:
  			break;
  		}
  	}
  
 -	if (sc->sis_link == 0) {
 +	if ((sc->sis_flags & SIS_FLAG_LINK) == 0) {
  		/*
  		 * Stopping MACs seem to reset SIS_TX_LISTPTR and
  		 * SIS_RX_LISTPTR which in turn requires resetting
 @@ -1122,6 +1124,8 @@ sis_attach(device_t dev)
  		break;
  	}
  
 +	sis_add_sysctls(sc);
 +
  	/* Allocate DMA'able memory. */
  	if ((error = sis_dma_alloc(sc)) != 0)
  		goto fail;
 @@ -1698,7 +1702,7 @@ sis_tick(void *xsc)
  	mii = device_get_softc(sc->sis_miibus);
  	mii_tick(mii);
  	sis_watchdog(sc);
 -	if (sc->sis_link == 0)
 +	if ((sc->sis_flags & SIS_FLAG_LINK) == 0)
  		sis_miibus_statchg(sc->sis_dev);
  	callout_reset(&sc->sis_stat_ch, hz,  sis_tick, sc);
  }
 @@ -1829,9 +1833,41 @@ sis_encap(struct sis_softc *sc, struct m
  	bus_dma_segment_t	segs[SIS_MAXTXSEGS];
  	bus_dmamap_t		map;
  	int			error, i, frag, nsegs, prod;
 +	int			padlen;
  
  	prod = sc->sis_tx_prod;
  	txd = &sc->sis_txdesc[prod];
 +	if ((sc->sis_flags & SIS_FLAG_MANUAL_PAD) != 0 &&
 +	    (*m_head)->m_pkthdr.len < SIS_MIN_FRAMELEN) {
 +		m = *m_head;
 +		padlen = SIS_MIN_FRAMELEN - m->m_pkthdr.len;
 +		if (M_WRITABLE(m) == 0) {
 +			/* Get a writable copy. */
 +			m = m_dup(*m_head, M_DONTWAIT);
 +			m_freem(*m_head);
 +			if (m == NULL) {
 +				*m_head = NULL;
 +				return (ENOBUFS);
 +			}
 +			*m_head = m;
 +		}
 +		if (m->m_next != NULL || M_TRAILINGSPACE(m) < padlen) {
 +			m = m_defrag(m, M_DONTWAIT);
 +			if (m == NULL) {
 +				m_freem(*m_head);
 +				*m_head = NULL;
 +				return (ENOBUFS);
 +			}
 +		}
 +		/*
 +		 * Manually pad short frames, and zero the pad space
 +		 * to avoid leaking data.
 +		 */
 +		bzero(mtod(m, char *) + m->m_pkthdr.len, padlen);
 +		m->m_pkthdr.len += padlen;
 +		m->m_len = m->m_pkthdr.len;
 +		*m_head = m;
 +	}
  	error = bus_dmamap_load_mbuf_sg(sc->sis_tx_tag, txd->tx_dmamap,
  	    *m_head, segs, &nsegs, 0);
  	if (error == EFBIG) {
 @@ -1918,7 +1954,7 @@ sis_startl(struct ifnet *ifp)
  	SIS_LOCK_ASSERT(sc);
  
  	if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
 -	    IFF_DRV_RUNNING || sc->sis_link == 0)
 +	    IFF_DRV_RUNNING || (sc->sis_flags & SIS_FLAG_LINK) == 0)
  		return;
  
  	for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
 @@ -2025,6 +2061,13 @@ sis_initl(struct sis_softc *sc)
  		return;
  	}
  
 +	if (sc->sis_type == SIS_TYPE_83815 || sc->sis_type == SIS_TYPE_83816) {
 +		if (sc->sis_manual_pad != 0)
 +			sc->sis_flags |= SIS_FLAG_MANUAL_PAD;
 +		else
 +			sc->sis_flags &= ~SIS_FLAG_MANUAL_PAD;
 +	}
 +
  	/*
  	 * Short Cable Receive Errors (MP21.E)
  	 * also: Page 78 of the DP83815 data sheet (september 2002 version)
 @@ -2125,7 +2168,7 @@ sis_initl(struct sis_softc *sc)
  	/* Clear MAC disable. */
  	SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE | SIS_CSR_RX_DISABLE);
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  	mii_mediachg(mii);
  
  	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 @@ -2148,7 +2191,6 @@ sis_ifmedia_upd(struct ifnet *ifp)
  
  	SIS_LOCK(sc);
  	mii = device_get_softc(sc->sis_miibus);
 -	sc->sis_link = 0;
  	if (mii->mii_instance) {
  		struct mii_softc	*miisc;
  		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
 @@ -2304,7 +2346,7 @@ sis_stop(struct sis_softc *sc)
  	CSR_WRITE_4(sc, SIS_TX_LISTPTR, 0);
  	CSR_WRITE_4(sc, SIS_RX_LISTPTR, 0);
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  
  	/*
  	 * Free data in the RX lists.
 @@ -2351,6 +2393,32 @@ sis_shutdown(device_t dev)
  	return (0);
  }
  
 +static void
 +sis_add_sysctls(struct sis_softc *sc)
 +{
 +	struct sysctl_ctx_list *ctx;
 +	struct sysctl_oid_list *children;
 +	char tn[32];
 +	int unit;
 +
 +	ctx = device_get_sysctl_ctx(sc->sis_dev);
 +	children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sis_dev));
 +
 +	unit = device_get_unit(sc->sis_dev);
 +	/*
 +	 * Unlike most other controllers, NS DP83815/DP83816 controllers
 +	 * seem to pad with 0xFF when it encounter short frames.  According
 +	 * to RFC 1042 the pad bytes should be 0x00.  Turning this tunable
 +	 * on will have driver pad manully but it's disabled by default
 +	 * because it will consume extra CPU cycles for short frames.
 +	 */
 +	sc->sis_manual_pad = 0;
 +	snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit);
 +	TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad);
 +	SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad",
 +	    CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames");
 +}
 +
  static device_method_t sis_methods[] = {
  	/* Device interface */
  	DEVMETHOD(device_probe,		sis_probe),
 
 Modified: head/sys/dev/sis/if_sisreg.h
 ==============================================================================
 --- head/sys/dev/sis/if_sisreg.h	Thu Sep  2 17:51:41 2010	(r212156)
 +++ head/sys/dev/sis/if_sisreg.h	Thu Sep  2 18:10:11 2010	(r212157)
 @@ -449,7 +449,10 @@ struct sis_softc {
  	device_t		sis_miibus;
  	uint8_t			sis_type;
  	uint8_t			sis_rev;
 -	uint8_t			sis_link;
 +	uint32_t		sis_flags;
 +#define	SIS_FLAG_MANUAL_PAD	0x0800
 +#define	SIS_FLAG_LINK		0x8000
 +	int			sis_manual_pad;
  	uint32_t		sis_srr;
  	struct sis_desc		*sis_rx_list;
  	struct sis_desc		*sis_tx_list;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/35422: commit references a PR
Date: Fri,  8 Oct 2010 20:51:39 +0000 (UTC)

 Author: yongari
 Date: Fri Oct  8 20:51:33 2010
 New Revision: 213626
 URL: http://svn.freebsd.org/changeset/base/213626
 
 Log:
   MFC r212157:
     Unlike most other controllers, NS DP83815/DP83816 controllers seem
     to pad with 0xFF when it encounter short frames.  According to RFC
     1042 the pad bytes should be 0x00.
     Because manual padding consumes extra CPU cycles, introduce a new
     tunable which controls the padding behavior. Turning this tunable
     on will have driver pad manually but it's disabled by default. Users
     can enable software padding by setting the following tunable to
     non-zero value.
   
     dev.sis.%d.manual_pad="1"
   
     PR:	kern/35422 (patch not used)
 
 Modified:
   stable/8/sys/dev/sis/if_sis.c
   stable/8/sys/dev/sis/if_sisreg.h
 Directory Properties:
   stable/8/sys/   (props changed)
   stable/8/sys/amd64/include/xen/   (props changed)
   stable/8/sys/cddl/contrib/opensolaris/   (props changed)
   stable/8/sys/contrib/dev/acpica/   (props changed)
   stable/8/sys/contrib/pf/   (props changed)
   stable/8/sys/dev/xen/xenpci/   (props changed)
 
 Modified: stable/8/sys/dev/sis/if_sis.c
 ==============================================================================
 --- stable/8/sys/dev/sis/if_sis.c	Fri Oct  8 20:49:44 2010	(r213625)
 +++ stable/8/sys/dev/sis/if_sis.c	Fri Oct  8 20:51:33 2010	(r213626)
 @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
  #include <sys/module.h>
  #include <sys/socket.h>
  #include <sys/sockio.h>
 +#include <sys/sysctl.h>
  
  #include <net/if.h>
  #include <net/if_arp.h>
 @@ -150,6 +151,7 @@ static int sis_rxeof(struct sis_softc *)
  static void sis_start(struct ifnet *);
  static void sis_startl(struct ifnet *);
  static void sis_stop(struct sis_softc *);
 +static void sis_add_sysctls(struct sis_softc *);
  static void sis_watchdog(struct sis_softc *);
  
  
 @@ -710,24 +712,24 @@ sis_miibus_statchg(device_t dev)
  	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
  		return;
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
  	    (IFM_ACTIVE | IFM_AVALID)) {
  		switch (IFM_SUBTYPE(mii->mii_media_active)) {
  		case IFM_10_T:
 -			sc->sis_link++;
  			CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_10);
 +			sc->sis_flags |= SIS_FLAG_LINK;
  			break;
  		case IFM_100_TX:
 -			sc->sis_link++;
  			CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100);
 +			sc->sis_flags |= SIS_FLAG_LINK;
  			break;
  		default:
  			break;
  		}
  	}
  
 -	if (sc->sis_link == 0) {
 +	if ((sc->sis_flags & SIS_FLAG_LINK) == 0) {
  		/*
  		 * Stopping MACs seem to reset SIS_TX_LISTPTR and
  		 * SIS_RX_LISTPTR which in turn requires resetting
 @@ -1122,6 +1124,8 @@ sis_attach(device_t dev)
  		break;
  	}
  
 +	sis_add_sysctls(sc);
 +
  	/* Allocate DMA'able memory. */
  	if ((error = sis_dma_alloc(sc)) != 0)
  		goto fail;
 @@ -1698,7 +1702,7 @@ sis_tick(void *xsc)
  	mii = device_get_softc(sc->sis_miibus);
  	mii_tick(mii);
  	sis_watchdog(sc);
 -	if (sc->sis_link == 0)
 +	if ((sc->sis_flags & SIS_FLAG_LINK) == 0)
  		sis_miibus_statchg(sc->sis_dev);
  	callout_reset(&sc->sis_stat_ch, hz,  sis_tick, sc);
  }
 @@ -1829,9 +1833,41 @@ sis_encap(struct sis_softc *sc, struct m
  	bus_dma_segment_t	segs[SIS_MAXTXSEGS];
  	bus_dmamap_t		map;
  	int			error, i, frag, nsegs, prod;
 +	int			padlen;
  
  	prod = sc->sis_tx_prod;
  	txd = &sc->sis_txdesc[prod];
 +	if ((sc->sis_flags & SIS_FLAG_MANUAL_PAD) != 0 &&
 +	    (*m_head)->m_pkthdr.len < SIS_MIN_FRAMELEN) {
 +		m = *m_head;
 +		padlen = SIS_MIN_FRAMELEN - m->m_pkthdr.len;
 +		if (M_WRITABLE(m) == 0) {
 +			/* Get a writable copy. */
 +			m = m_dup(*m_head, M_DONTWAIT);
 +			m_freem(*m_head);
 +			if (m == NULL) {
 +				*m_head = NULL;
 +				return (ENOBUFS);
 +			}
 +			*m_head = m;
 +		}
 +		if (m->m_next != NULL || M_TRAILINGSPACE(m) < padlen) {
 +			m = m_defrag(m, M_DONTWAIT);
 +			if (m == NULL) {
 +				m_freem(*m_head);
 +				*m_head = NULL;
 +				return (ENOBUFS);
 +			}
 +		}
 +		/*
 +		 * Manually pad short frames, and zero the pad space
 +		 * to avoid leaking data.
 +		 */
 +		bzero(mtod(m, char *) + m->m_pkthdr.len, padlen);
 +		m->m_pkthdr.len += padlen;
 +		m->m_len = m->m_pkthdr.len;
 +		*m_head = m;
 +	}
  	error = bus_dmamap_load_mbuf_sg(sc->sis_tx_tag, txd->tx_dmamap,
  	    *m_head, segs, &nsegs, 0);
  	if (error == EFBIG) {
 @@ -1918,7 +1954,7 @@ sis_startl(struct ifnet *ifp)
  	SIS_LOCK_ASSERT(sc);
  
  	if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
 -	    IFF_DRV_RUNNING || sc->sis_link == 0)
 +	    IFF_DRV_RUNNING || (sc->sis_flags & SIS_FLAG_LINK) == 0)
  		return;
  
  	for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
 @@ -2025,6 +2061,13 @@ sis_initl(struct sis_softc *sc)
  		return;
  	}
  
 +	if (sc->sis_type == SIS_TYPE_83815 || sc->sis_type == SIS_TYPE_83816) {
 +		if (sc->sis_manual_pad != 0)
 +			sc->sis_flags |= SIS_FLAG_MANUAL_PAD;
 +		else
 +			sc->sis_flags &= ~SIS_FLAG_MANUAL_PAD;
 +	}
 +
  	/*
  	 * Short Cable Receive Errors (MP21.E)
  	 * also: Page 78 of the DP83815 data sheet (september 2002 version)
 @@ -2125,7 +2168,7 @@ sis_initl(struct sis_softc *sc)
  	/* Clear MAC disable. */
  	SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE | SIS_CSR_RX_DISABLE);
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  	mii_mediachg(mii);
  
  	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 @@ -2148,7 +2191,6 @@ sis_ifmedia_upd(struct ifnet *ifp)
  
  	SIS_LOCK(sc);
  	mii = device_get_softc(sc->sis_miibus);
 -	sc->sis_link = 0;
  	if (mii->mii_instance) {
  		struct mii_softc	*miisc;
  		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
 @@ -2304,7 +2346,7 @@ sis_stop(struct sis_softc *sc)
  	CSR_WRITE_4(sc, SIS_TX_LISTPTR, 0);
  	CSR_WRITE_4(sc, SIS_RX_LISTPTR, 0);
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  
  	/*
  	 * Free data in the RX lists.
 @@ -2351,6 +2393,32 @@ sis_shutdown(device_t dev)
  	return (0);
  }
  
 +static void
 +sis_add_sysctls(struct sis_softc *sc)
 +{
 +	struct sysctl_ctx_list *ctx;
 +	struct sysctl_oid_list *children;
 +	char tn[32];
 +	int unit;
 +
 +	ctx = device_get_sysctl_ctx(sc->sis_dev);
 +	children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sis_dev));
 +
 +	unit = device_get_unit(sc->sis_dev);
 +	/*
 +	 * Unlike most other controllers, NS DP83815/DP83816 controllers
 +	 * seem to pad with 0xFF when it encounter short frames.  According
 +	 * to RFC 1042 the pad bytes should be 0x00.  Turning this tunable
 +	 * on will have driver pad manully but it's disabled by default
 +	 * because it will consume extra CPU cycles for short frames.
 +	 */
 +	sc->sis_manual_pad = 0;
 +	snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit);
 +	TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad);
 +	SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad",
 +	    CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames");
 +}
 +
  static device_method_t sis_methods[] = {
  	/* Device interface */
  	DEVMETHOD(device_probe,		sis_probe),
 
 Modified: stable/8/sys/dev/sis/if_sisreg.h
 ==============================================================================
 --- stable/8/sys/dev/sis/if_sisreg.h	Fri Oct  8 20:49:44 2010	(r213625)
 +++ stable/8/sys/dev/sis/if_sisreg.h	Fri Oct  8 20:51:33 2010	(r213626)
 @@ -449,7 +449,10 @@ struct sis_softc {
  	device_t		sis_miibus;
  	uint8_t			sis_type;
  	uint8_t			sis_rev;
 -	uint8_t			sis_link;
 +	uint32_t		sis_flags;
 +#define	SIS_FLAG_MANUAL_PAD	0x0800
 +#define	SIS_FLAG_LINK		0x8000
 +	int			sis_manual_pad;
  	uint32_t		sis_srr;
  	struct sis_desc		*sis_rx_list;
  	struct sis_desc		*sis_tx_list;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: docs/35422: commit references a PR
Date: Fri,  8 Oct 2010 20:52:52 +0000 (UTC)

 Author: yongari
 Date: Fri Oct  8 20:52:47 2010
 New Revision: 213627
 URL: http://svn.freebsd.org/changeset/base/213627
 
 Log:
   MFC r212157:
     Unlike most other controllers, NS DP83815/DP83816 controllers seem
     to pad with 0xFF when it encounter short frames.  According to RFC
     1042 the pad bytes should be 0x00.
     Because manual padding consumes extra CPU cycles, introduce a new
     tunable which controls the padding behavior. Turning this tunable
     on will have driver pad manually but it's disabled by default. Users
     can enable software padding by setting the following tunable to
     non-zero value.
   
     dev.sis.%d.manual_pad="1"
   
     PR:	kern/35422 (patch not used)
 
 Modified:
   stable/7/sys/dev/sis/if_sis.c
   stable/7/sys/dev/sis/if_sisreg.h
 Directory Properties:
   stable/7/sys/   (props changed)
   stable/7/sys/cddl/contrib/opensolaris/   (props changed)
   stable/7/sys/contrib/dev/acpica/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
 
 Modified: stable/7/sys/dev/sis/if_sis.c
 ==============================================================================
 --- stable/7/sys/dev/sis/if_sis.c	Fri Oct  8 20:51:33 2010	(r213626)
 +++ stable/7/sys/dev/sis/if_sis.c	Fri Oct  8 20:52:47 2010	(r213627)
 @@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
  #include <sys/module.h>
  #include <sys/socket.h>
  #include <sys/sockio.h>
 +#include <sys/sysctl.h>
  
  #include <net/if.h>
  #include <net/if_arp.h>
 @@ -150,6 +151,7 @@ static void sis_rxeof(struct sis_softc *
  static void sis_start(struct ifnet *);
  static void sis_startl(struct ifnet *);
  static void sis_stop(struct sis_softc *);
 +static void sis_add_sysctls(struct sis_softc *);
  static void sis_watchdog(struct sis_softc *);
  
  
 @@ -710,24 +712,24 @@ sis_miibus_statchg(device_t dev)
  	    (ifp->if_drv_flags & IFF_DRV_RUNNING) == 0)
  		return;
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  	if ((mii->mii_media_status & (IFM_ACTIVE | IFM_AVALID)) ==
  	    (IFM_ACTIVE | IFM_AVALID)) {
  		switch (IFM_SUBTYPE(mii->mii_media_active)) {
  		case IFM_10_T:
 -			sc->sis_link++;
  			CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_10);
 +			sc->sis_flags |= SIS_FLAG_LINK;
  			break;
  		case IFM_100_TX:
 -			sc->sis_link++;
  			CSR_WRITE_4(sc, SIS_TX_CFG, SIS_TXCFG_100);
 +			sc->sis_flags |= SIS_FLAG_LINK;
  			break;
  		default:
  			break;
  		}
  	}
  
 -	if (sc->sis_link == 0) {
 +	if ((sc->sis_flags & SIS_FLAG_LINK) == 0) {
  		/*
  		 * Stopping MACs seem to reset SIS_TX_LISTPTR and
  		 * SIS_RX_LISTPTR which in turn requires resetting
 @@ -1122,6 +1124,8 @@ sis_attach(device_t dev)
  		break;
  	}
  
 +	sis_add_sysctls(sc);
 +
  	/* Allocate DMA'able memory. */
  	if ((error = sis_dma_alloc(sc)) != 0)
  		goto fail;
 @@ -1696,7 +1700,7 @@ sis_tick(void *xsc)
  	mii = device_get_softc(sc->sis_miibus);
  	mii_tick(mii);
  	sis_watchdog(sc);
 -	if (sc->sis_link == 0)
 +	if ((sc->sis_flags & SIS_FLAG_LINK) == 0)
  		sis_miibus_statchg(sc->sis_dev);
  	callout_reset(&sc->sis_stat_ch, hz,  sis_tick, sc);
  }
 @@ -1825,9 +1829,41 @@ sis_encap(struct sis_softc *sc, struct m
  	bus_dma_segment_t	segs[SIS_MAXTXSEGS];
  	bus_dmamap_t		map;
  	int			error, i, frag, nsegs, prod;
 +	int			padlen;
  
  	prod = sc->sis_tx_prod;
  	txd = &sc->sis_txdesc[prod];
 +	if ((sc->sis_flags & SIS_FLAG_MANUAL_PAD) != 0 &&
 +	    (*m_head)->m_pkthdr.len < SIS_MIN_FRAMELEN) {
 +		m = *m_head;
 +		padlen = SIS_MIN_FRAMELEN - m->m_pkthdr.len;
 +		if (M_WRITABLE(m) == 0) {
 +			/* Get a writable copy. */
 +			m = m_dup(*m_head, M_DONTWAIT);
 +			m_freem(*m_head);
 +			if (m == NULL) {
 +				*m_head = NULL;
 +				return (ENOBUFS);
 +			}
 +			*m_head = m;
 +		}
 +		if (m->m_next != NULL || M_TRAILINGSPACE(m) < padlen) {
 +			m = m_defrag(m, M_DONTWAIT);
 +			if (m == NULL) {
 +				m_freem(*m_head);
 +				*m_head = NULL;
 +				return (ENOBUFS);
 +			}
 +		}
 +		/*
 +		 * Manually pad short frames, and zero the pad space
 +		 * to avoid leaking data.
 +		 */
 +		bzero(mtod(m, char *) + m->m_pkthdr.len, padlen);
 +		m->m_pkthdr.len += padlen;
 +		m->m_len = m->m_pkthdr.len;
 +		*m_head = m;
 +	}
  	error = bus_dmamap_load_mbuf_sg(sc->sis_tx_tag, txd->tx_dmamap,
  	    *m_head, segs, &nsegs, 0);
  	if (error == EFBIG) {
 @@ -1914,7 +1950,7 @@ sis_startl(struct ifnet *ifp)
  	SIS_LOCK_ASSERT(sc);
  
  	if ((ifp->if_drv_flags & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
 -	    IFF_DRV_RUNNING || sc->sis_link == 0)
 +	    IFF_DRV_RUNNING || (sc->sis_flags & SIS_FLAG_LINK) == 0)
  		return;
  
  	for (queued = 0; !IFQ_DRV_IS_EMPTY(&ifp->if_snd) &&
 @@ -2021,6 +2057,13 @@ sis_initl(struct sis_softc *sc)
  		return;
  	}
  
 +	if (sc->sis_type == SIS_TYPE_83815 || sc->sis_type == SIS_TYPE_83816) {
 +		if (sc->sis_manual_pad != 0)
 +			sc->sis_flags |= SIS_FLAG_MANUAL_PAD;
 +		else
 +			sc->sis_flags &= ~SIS_FLAG_MANUAL_PAD;
 +	}
 +
  	/*
  	 * Short Cable Receive Errors (MP21.E)
  	 * also: Page 78 of the DP83815 data sheet (september 2002 version)
 @@ -2121,7 +2164,7 @@ sis_initl(struct sis_softc *sc)
  	/* Clear MAC disable. */
  	SIS_CLRBIT(sc, SIS_CSR, SIS_CSR_TX_DISABLE | SIS_CSR_RX_DISABLE);
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  	mii_mediachg(mii);
  
  	ifp->if_drv_flags |= IFF_DRV_RUNNING;
 @@ -2144,7 +2187,6 @@ sis_ifmedia_upd(struct ifnet *ifp)
  
  	SIS_LOCK(sc);
  	mii = device_get_softc(sc->sis_miibus);
 -	sc->sis_link = 0;
  	if (mii->mii_instance) {
  		struct mii_softc	*miisc;
  		LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
 @@ -2300,7 +2342,7 @@ sis_stop(struct sis_softc *sc)
  	CSR_WRITE_4(sc, SIS_TX_LISTPTR, 0);
  	CSR_WRITE_4(sc, SIS_RX_LISTPTR, 0);
  
 -	sc->sis_link = 0;
 +	sc->sis_flags &= ~SIS_FLAG_LINK;
  
  	/*
  	 * Free data in the RX lists.
 @@ -2346,6 +2388,32 @@ sis_shutdown(device_t dev)
  	SIS_UNLOCK(sc);
  }
  
 +static void
 +sis_add_sysctls(struct sis_softc *sc)
 +{
 +	struct sysctl_ctx_list *ctx;
 +	struct sysctl_oid_list *children;
 +	char tn[32];
 +	int unit;
 +
 +	ctx = device_get_sysctl_ctx(sc->sis_dev);
 +	children = SYSCTL_CHILDREN(device_get_sysctl_tree(sc->sis_dev));
 +
 +	unit = device_get_unit(sc->sis_dev);
 +	/*
 +	 * Unlike most other controllers, NS DP83815/DP83816 controllers
 +	 * seem to pad with 0xFF when it encounter short frames.  According
 +	 * to RFC 1042 the pad bytes should be 0x00.  Turning this tunable
 +	 * on will have driver pad manully but it's disabled by default
 +	 * because it will consume extra CPU cycles for short frames.
 +	 */
 +	sc->sis_manual_pad = 0;
 +	snprintf(tn, sizeof(tn), "dev.sis.%d.manual_pad", unit);
 +	TUNABLE_INT_FETCH(tn, &sc->sis_manual_pad);
 +	SYSCTL_ADD_INT(ctx, children, OID_AUTO, "manual_pad",
 +	    CTLFLAG_RW, &sc->sis_manual_pad, 0, "Manually pad short frames");
 +}
 +
  static device_method_t sis_methods[] = {
  	/* Device interface */
  	DEVMETHOD(device_probe,		sis_probe),
 
 Modified: stable/7/sys/dev/sis/if_sisreg.h
 ==============================================================================
 --- stable/7/sys/dev/sis/if_sisreg.h	Fri Oct  8 20:51:33 2010	(r213626)
 +++ stable/7/sys/dev/sis/if_sisreg.h	Fri Oct  8 20:52:47 2010	(r213627)
 @@ -449,7 +449,10 @@ struct sis_softc {
  	device_t		sis_miibus;
  	uint8_t			sis_type;
  	uint8_t			sis_rev;
 -	uint8_t			sis_link;
 +	uint32_t		sis_flags;
 +#define	SIS_FLAG_MANUAL_PAD	0x0800
 +#define	SIS_FLAG_LINK		0x8000
 +	int			sis_manual_pad;
  	uint32_t		sis_srr;
  	struct sis_desc		*sis_rx_list;
  	struct sis_desc		*sis_tx_list;
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
>Unformatted:
