From nobody@FreeBSD.org  Wed Mar  2 14:25:16 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5669E106566C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  2 Mar 2011 14:25:16 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 45AC58FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed,  2 Mar 2011 14:25:16 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p22EPG74043573
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 2 Mar 2011 14:25:16 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p22EPFhW043572;
	Wed, 2 Mar 2011 14:25:16 GMT
	(envelope-from nobody)
Message-Id: <201103021425.p22EPFhW043572@red.freebsd.org>
Date: Wed, 2 Mar 2011 14:25:16 GMT
From: Dmitry Rybin <dimanenator@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bge1 mtu problem
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         155192
>Category:       kern
>Synopsis:       bge1 mtu problem
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Mar 02 14:30:12 UTC 2011
>Closed-Date:    Tue May 10 02:19:05 UTC 2011
>Last-Modified:  Tue May 10 02:19:05 UTC 2011
>Originator:     Dmitry Rybin
>Release:        8.2-STABLE
>Organization:
>Environment:
FreeBSD ground.corbina.net 8.2-STABLE FreeBSD 8.2-STABLE #1: Wed Mar  2 10:57:25 MSK 2011     root@ground:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
I coudn't set mtu over 1500 on BGE interface, but in 
http://svn.freebsd.org/viewvc/base?view=revision&revision=214997
it was commited.

Server HP DL320s, NIC Controller: Embedded NC324i PCIe Dual Port Gigabit Server Adapter

bge0@pci0:3:4:0:        class=0x020000 card=0x7039103c chip=0x166814e4 rev=0xa3 hdr=0x00
    vendor     = 'Broadcom Corporation'
    device     = 'NetXtreme BCM5714 Gigabit Ethernet'
    class      = network
    subclass   = ethernet
bge1@pci0:3:4:1:        class=0x020000 card=0x7039103c chip=0x166814e4 rev=0xa3 hdr=0x00
    vendor     = 'Broadcom Corporation'
    device     = 'NetXtreme BCM5714 Gigabit Ethernet'
    class      = network
    subclass   = ethernet

# ifconfig bge1 mtu 1501
ifconfig: ioctl (set mtu): Invalid argument
>How-To-Repeat:
# ifconfig bge1 mtu 1501
ifconfig: ioctl (set mtu): Invalid argument

$ ifconfig bge1 mtu 9000
ifconfig: ioctl (set mtu): Invalid argument
>Fix:


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: yongari 
State-Changed-When: Wed Mar 2 18:43:36 UTC 2011 
State-Changed-Why:  
The commit message you referred to does not apply to your controller. 

bge(4) supports jumbo frame on controllers that provide extended RX 
BD capability. Even though your controller BCM5714 supports very 
limited set of jumbo frame it has severe hardware limitation which 
make it hard to coexist existing controllers which have different 
and efficient jumbo frame scheme. I think other OSes also do not 
support jumbo frame on BCM5714 family.  
Because there is no easy way to support this exotic jumbo frame 
scheme without sacrificing a lot of sane controllers I have no plan 
to implement the limited jumbo frame scheme on BCM5704. I also 
think you wouldn't get much benefit from this kind of jumbo frame 
support due to the limitation of hardware. 


Responsible-Changed-From-To: freebsd-bugs->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Wed Mar 2 18:43:36 UTC 2011 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155192 
State-Changed-From-To: closed->feedback 
State-Changed-By: yongari 
State-Changed-When: Tue Mar 15 23:41:41 UTC 2011 
State-Changed-Why:  
I have experimental patch for BCM5714 jumbo frame support. 
Could you try the patch at the following URL? 
http://people.freebsd.org/~yongari/bge/bge.5714.jumbo.diff 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155192 

From: YongHyeon PYUN <pyunyh@gmail.com>
To: DR <dimanenator@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: kern/155192: bge1 mtu problem
Date: Wed, 16 Mar 2011 12:24:57 -0700

 --qDbXVdCdHGoSgWSk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 
 On Wed, Mar 16, 2011 at 12:40:38PM +0300, DR wrote:
 > HM... first server OK, mtu=9000, but on second "bge1: no memory for
 
 This means bge0 work with MTU 9000, right?
 
 > std Rx buffers"
 
 Since you have more than 4GB memory I guess it came from resource
 shortage. You would wonder why you see that since you have plenty
 of RAM. Due to some known issues, bge(4) limits DMA address space
 of PCI-X controller to be lower than 4GB. Using jumbo buffers can
 easily consume all available resources(you have two controllers!).
 I'm not sure whether relaxing 4GB DMA address space limitation
 would work or not on your box. Removing 4GB DMA address space
 limitation for PCI-X bge(4) controller caused other problems in the
 past so you have to pay attention to stability of driver after
 applying attached patch.
 
 > Servers are indetical HP DL320s.
 > 
 
 --qDbXVdCdHGoSgWSk
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="bge.5714.jumbo.diff2"
 
 Index: sys/dev/bge/if_bgereg.h
 ===================================================================
 --- sys/dev/bge/if_bgereg.h	(revision 219701)
 +++ sys/dev/bge/if_bgereg.h	(working copy)
 @@ -2748,6 +2748,7 @@
  	uint32_t		bge_flags;
  #define	BGE_FLAG_TBI		0x00000001
  #define	BGE_FLAG_JUMBO		0x00000002
 +#define	BGE_FLAG_JUMBO_STD	0x00000004
  #define	BGE_FLAG_EADDR		0x00000008
  #define	BGE_FLAG_MII_SERDES	0x00000010
  #define	BGE_FLAG_CPMU_PRESENT	0x00000020
 Index: sys/dev/bge/if_bge.c
 ===================================================================
 --- sys/dev/bge/if_bge.c	(revision 219701)
 +++ sys/dev/bge/if_bge.c	(working copy)
 @@ -943,10 +943,19 @@
  	bus_dmamap_t map;
  	int error, nsegs;
  
 -	m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 -	if (m == NULL)
 -		return (ENOBUFS);
 -	m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD &&
 +	    (sc->bge_ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN +
 +	    ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) {
 +		m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MJUM9BYTES;
 +	} else {
 +		m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	}
  	if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
  		m_adj(m, ETHER_ALIGN);
  
 @@ -2385,7 +2394,7 @@
  bge_dma_alloc(struct bge_softc *sc)
  {
  	bus_addr_t lowaddr;
 -	bus_size_t boundary, sbsz, txsegsz, txmaxsegsz;
 +	bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
  	int i, error;
  
  	lowaddr = BUS_SPACE_MAXADDR;
 @@ -2482,8 +2491,10 @@
  		 * Limiting DMA address space to 32bits seems to address
  		 * it.
  		 */
 +#if 0
  		if (sc->bge_flags & BGE_FLAG_PCIX)
  			lowaddr = BUS_SPACE_MAXADDR_32BIT;
 +#endif
  	}
  	error = bus_dma_tag_create(bus_get_dma_tag(sc->bge_dev),
  	    1, boundary, lowaddr, BUS_SPACE_MAXADDR, NULL,
 @@ -2513,9 +2524,13 @@
  	}
  
  	/* Create tag for Rx mbufs. */
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD)
 +		rxmaxsegsz = MJUM9BYTES;
 +	else
 +		rxmaxsegsz = MCLBYTES;
  	error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0,
 -	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1,
 -	    MCLBYTES, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
 +	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rxmaxsegsz, 1,
 +	    rxmaxsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
  
  	if (error) {
  		device_printf(sc->bge_dev, "could not allocate RX dma tag\n");
 @@ -2759,7 +2774,7 @@
  	case BGE_ASICREV_BCM5714_A0:
  	case BGE_ASICREV_BCM5780:
  	case BGE_ASICREV_BCM5714:
 -		sc->bge_flags |= BGE_FLAG_5714_FAMILY /* | BGE_FLAG_JUMBO */;
 +		sc->bge_flags |= BGE_FLAG_5714_FAMILY | BGE_FLAG_JUMBO_STD;
  		/* FALLTHROUGH */
  	case BGE_ASICREV_BCM5750:
  	case BGE_ASICREV_BCM5752:
 @@ -3560,7 +3575,8 @@
  	    sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD);
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTWRITE);
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN))
  		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
  		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE);
 @@ -4689,7 +4705,8 @@
  	}
  
  	/* Init jumbo RX ring. */
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN)) {
  		if (bge_init_rx_ring_jumbo(sc) != 0) {
  			device_printf(sc->bge_dev,
 @@ -4914,14 +4931,19 @@
  
  	switch (command) {
  	case SIOCSIFMTU:
 +		if (BGE_IS_JUMBO_CAPABLE(sc) ||
 +		    (sc->bge_flags & BGE_FLAG_JUMBO_STD)) {
 +			if (ifr->ifr_mtu < ETHERMIN ||
 +			    ifr->ifr_mtu > BGE_JUMBO_MTU) {
 +				error = EINVAL;
 +				break;
 +			}
 +		} else if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) {
 +			error = EINVAL; 
 +			break;
 +		}
  		BGE_LOCK(sc);
 -		if (ifr->ifr_mtu < ETHERMIN ||
 -		    ((BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > BGE_JUMBO_MTU) ||
 -		    ((!BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > ETHERMTU))
 -			error = EINVAL;
 -		else if (ifp->if_mtu != ifr->ifr_mtu) {
 +		if (ifp->if_mtu != ifr->ifr_mtu) {
  			ifp->if_mtu = ifr->ifr_mtu;
  			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
  				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 
 --qDbXVdCdHGoSgWSk--

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/155192: commit references a PR
Date: Tue,  5 Apr 2011 17:42:09 +0000 (UTC)

 Author: yongari
 Date: Tue Apr  5 17:41:54 2011
 New Revision: 220368
 URL: http://svn.freebsd.org/changeset/base/220368
 
 Log:
   Add initial jumbo frame support for BCM5714/BCM5715 and BCM5780.
   Unlike other controllers which have more advanced jumbo support,
   these controllers have one send ring, one standard receive producer
   ring and one receive return ring. In order to receive jumbo frames
   on the controllers, driver now will increase Rx buffer size to 9k.
   Two Rx modes are supported on these controllers and I chose
   standard Rx BDs over extended Rx BDs. The extended Rx BD mode
   allows up to 4 segmentations for each Rx BDs such that kernel does
   not have to allocate large buffer of contiguous memory for
   receiving. The extended Rx BD mode is already used on controllers
   that have separate jumbo receive ring. However, using extended Rx
   BDs on BCM5714/BCM5715/BCM5780 reduces the number of Rx BDs to 256
   entries which in turn may reduce the performance.  Also UMA backed
   page allocator for jumbo frame returns contiguous memory so using
   extended Rx BD has no advantage on FreeBSD unless highly customized
   local allocator implemented in driver is used.
   To use jumbo buffers in standard receive ring, Rx buffer allocation
   handler was changed to allocate MJUM9BYTES sized mbuf.
   
   PR:		kern/155192
   Tested by:	Vijay Singh <vijju.singh <> gmail dot com>
   Submitted by:	mjacob (initial version)
 
 Modified:
   head/sys/dev/bge/if_bge.c
   head/sys/dev/bge/if_bgereg.h
 
 Modified: head/sys/dev/bge/if_bge.c
 ==============================================================================
 --- head/sys/dev/bge/if_bge.c	Tue Apr  5 16:14:54 2011	(r220367)
 +++ head/sys/dev/bge/if_bge.c	Tue Apr  5 17:41:54 2011	(r220368)
 @@ -943,10 +943,19 @@ bge_newbuf_std(struct bge_softc *sc, int
  	bus_dmamap_t map;
  	int error, nsegs;
  
 -	m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 -	if (m == NULL)
 -		return (ENOBUFS);
 -	m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD &&
 +	    (sc->bge_ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN +
 +	    ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) {
 +		m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MJUM9BYTES;
 +	} else {
 +		m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	}
  	if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
  		m_adj(m, ETHER_ALIGN);
  
 @@ -2385,7 +2394,7 @@ static int
  bge_dma_alloc(struct bge_softc *sc)
  {
  	bus_addr_t lowaddr;
 -	bus_size_t boundary, sbsz, txsegsz, txmaxsegsz;
 +	bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
  	int i, error;
  
  	lowaddr = BUS_SPACE_MAXADDR;
 @@ -2513,9 +2522,13 @@ bge_dma_alloc(struct bge_softc *sc)
  	}
  
  	/* Create tag for Rx mbufs. */
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD)
 +		rxmaxsegsz = MJUM9BYTES;
 +	else
 +		rxmaxsegsz = MCLBYTES;
  	error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0,
 -	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1,
 -	    MCLBYTES, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
 +	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rxmaxsegsz, 1,
 +	    rxmaxsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
  
  	if (error) {
  		device_printf(sc->bge_dev, "could not allocate RX dma tag\n");
 @@ -2759,7 +2772,7 @@ bge_attach(device_t dev)
  	case BGE_ASICREV_BCM5714_A0:
  	case BGE_ASICREV_BCM5780:
  	case BGE_ASICREV_BCM5714:
 -		sc->bge_flags |= BGE_FLAG_5714_FAMILY /* | BGE_FLAG_JUMBO */;
 +		sc->bge_flags |= BGE_FLAG_5714_FAMILY | BGE_FLAG_JUMBO_STD;
  		/* FALLTHROUGH */
  	case BGE_ASICREV_BCM5750:
  	case BGE_ASICREV_BCM5752:
 @@ -3560,7 +3573,8 @@ bge_rxeof(struct bge_softc *sc, uint16_t
  	    sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD);
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTWRITE);
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN))
  		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
  		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE);
 @@ -4689,7 +4703,8 @@ bge_init_locked(struct bge_softc *sc)
  	}
  
  	/* Init jumbo RX ring. */
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN)) {
  		if (bge_init_rx_ring_jumbo(sc) != 0) {
  			device_printf(sc->bge_dev,
 @@ -4914,14 +4929,19 @@ bge_ioctl(struct ifnet *ifp, u_long comm
  
  	switch (command) {
  	case SIOCSIFMTU:
 +		if (BGE_IS_JUMBO_CAPABLE(sc) ||
 +		    (sc->bge_flags & BGE_FLAG_JUMBO_STD)) {
 +			if (ifr->ifr_mtu < ETHERMIN ||
 +			    ifr->ifr_mtu > BGE_JUMBO_MTU) {
 +				error = EINVAL;
 +				break;
 +			}
 +		} else if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) {
 +			error = EINVAL; 
 +			break;
 +		}
  		BGE_LOCK(sc);
 -		if (ifr->ifr_mtu < ETHERMIN ||
 -		    ((BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > BGE_JUMBO_MTU) ||
 -		    ((!BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > ETHERMTU))
 -			error = EINVAL;
 -		else if (ifp->if_mtu != ifr->ifr_mtu) {
 +		if (ifp->if_mtu != ifr->ifr_mtu) {
  			ifp->if_mtu = ifr->ifr_mtu;
  			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
  				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 
 Modified: head/sys/dev/bge/if_bgereg.h
 ==============================================================================
 --- head/sys/dev/bge/if_bgereg.h	Tue Apr  5 16:14:54 2011	(r220367)
 +++ head/sys/dev/bge/if_bgereg.h	Tue Apr  5 17:41:54 2011	(r220368)
 @@ -2748,6 +2748,7 @@ struct bge_softc {
  	uint32_t		bge_flags;
  #define	BGE_FLAG_TBI		0x00000001
  #define	BGE_FLAG_JUMBO		0x00000002
 +#define	BGE_FLAG_JUMBO_STD	0x00000004
  #define	BGE_FLAG_EADDR		0x00000008
  #define	BGE_FLAG_MII_SERDES	0x00000010
  #define	BGE_FLAG_CPMU_PRESENT	0x00000020
 _______________________________________________
 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"
 
State-Changed-From-To: feedback->patched 
State-Changed-By: yongari 
State-Changed-When: Tue Apr 5 22:17:38 UTC 2011 
State-Changed-Why:  
Fixed in HEAD(r220368). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155192 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/155192: commit references a PR
Date: Mon,  2 May 2011 22:49:57 +0000 (UTC)

 Author: yongari
 Date: Mon May  2 22:49:43 2011
 New Revision: 221351
 URL: http://svn.freebsd.org/changeset/base/221351
 
 Log:
   MFC r220368:
     Add initial jumbo frame support for BCM5714/BCM5715 and BCM5780.
     Unlike other controllers which have more advanced jumbo support,
     these controllers have one send ring, one standard receive producer
     ring and one receive return ring. In order to receive jumbo frames
     on the controllers, driver now will increase Rx buffer size to 9k.
     Two Rx modes are supported on these controllers and I chose
     standard Rx BDs over extended Rx BDs. The extended Rx BD mode
     allows up to 4 segmentations for each Rx BDs such that kernel does
     not have to allocate large buffer of contiguous memory for
     receiving. The extended Rx BD mode is already used on controllers
     that have separate jumbo receive ring. However, using extended Rx
     BDs on BCM5714/BCM5715/BCM5780 reduces the number of Rx BDs to 256
     entries which in turn may reduce the performance.  Also UMA backed
     page allocator for jumbo frame returns contiguous memory so using
     extended Rx BD has no advantage on FreeBSD unless highly customized
     local allocator implemented in driver is used.
     To use jumbo buffers in standard receive ring, Rx buffer allocation
     handler was changed to allocate MJUM9BYTES sized mbuf.
   
     PR:		kern/155192
     Tested by:	Vijay Singh <vijju.singh <> gmail dot com>
     Submitted by:	mjacob (initial version)
 
 Modified:
   stable/8/sys/dev/bge/if_bge.c
   stable/8/sys/dev/bge/if_bgereg.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)
 
 Modified: stable/8/sys/dev/bge/if_bge.c
 ==============================================================================
 --- stable/8/sys/dev/bge/if_bge.c	Mon May  2 22:03:30 2011	(r221350)
 +++ stable/8/sys/dev/bge/if_bge.c	Mon May  2 22:49:43 2011	(r221351)
 @@ -943,10 +943,19 @@ bge_newbuf_std(struct bge_softc *sc, int
  	bus_dmamap_t map;
  	int error, nsegs;
  
 -	m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 -	if (m == NULL)
 -		return (ENOBUFS);
 -	m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD &&
 +	    (sc->bge_ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN +
 +	    ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) {
 +		m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MJUM9BYTES;
 +	} else {
 +		m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	}
  	if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
  		m_adj(m, ETHER_ALIGN);
  
 @@ -2385,7 +2394,7 @@ static int
  bge_dma_alloc(struct bge_softc *sc)
  {
  	bus_addr_t lowaddr;
 -	bus_size_t boundary, sbsz, txsegsz, txmaxsegsz;
 +	bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
  	int i, error;
  
  	lowaddr = BUS_SPACE_MAXADDR;
 @@ -2513,9 +2522,13 @@ bge_dma_alloc(struct bge_softc *sc)
  	}
  
  	/* Create tag for Rx mbufs. */
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD)
 +		rxmaxsegsz = MJUM9BYTES;
 +	else
 +		rxmaxsegsz = MCLBYTES;
  	error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0,
 -	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1,
 -	    MCLBYTES, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
 +	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rxmaxsegsz, 1,
 +	    rxmaxsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
  
  	if (error) {
  		device_printf(sc->bge_dev, "could not allocate RX dma tag\n");
 @@ -2759,7 +2772,7 @@ bge_attach(device_t dev)
  	case BGE_ASICREV_BCM5714_A0:
  	case BGE_ASICREV_BCM5780:
  	case BGE_ASICREV_BCM5714:
 -		sc->bge_flags |= BGE_FLAG_5714_FAMILY /* | BGE_FLAG_JUMBO */;
 +		sc->bge_flags |= BGE_FLAG_5714_FAMILY | BGE_FLAG_JUMBO_STD;
  		/* FALLTHROUGH */
  	case BGE_ASICREV_BCM5750:
  	case BGE_ASICREV_BCM5752:
 @@ -3560,7 +3573,8 @@ bge_rxeof(struct bge_softc *sc, uint16_t
  	    sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD);
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTWRITE);
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN))
  		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
  		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE);
 @@ -4689,7 +4703,8 @@ bge_init_locked(struct bge_softc *sc)
  	}
  
  	/* Init jumbo RX ring. */
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN)) {
  		if (bge_init_rx_ring_jumbo(sc) != 0) {
  			device_printf(sc->bge_dev,
 @@ -4914,14 +4929,19 @@ bge_ioctl(struct ifnet *ifp, u_long comm
  
  	switch (command) {
  	case SIOCSIFMTU:
 +		if (BGE_IS_JUMBO_CAPABLE(sc) ||
 +		    (sc->bge_flags & BGE_FLAG_JUMBO_STD)) {
 +			if (ifr->ifr_mtu < ETHERMIN ||
 +			    ifr->ifr_mtu > BGE_JUMBO_MTU) {
 +				error = EINVAL;
 +				break;
 +			}
 +		} else if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) {
 +			error = EINVAL; 
 +			break;
 +		}
  		BGE_LOCK(sc);
 -		if (ifr->ifr_mtu < ETHERMIN ||
 -		    ((BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > BGE_JUMBO_MTU) ||
 -		    ((!BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > ETHERMTU))
 -			error = EINVAL;
 -		else if (ifp->if_mtu != ifr->ifr_mtu) {
 +		if (ifp->if_mtu != ifr->ifr_mtu) {
  			ifp->if_mtu = ifr->ifr_mtu;
  			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
  				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 
 Modified: stable/8/sys/dev/bge/if_bgereg.h
 ==============================================================================
 --- stable/8/sys/dev/bge/if_bgereg.h	Mon May  2 22:03:30 2011	(r221350)
 +++ stable/8/sys/dev/bge/if_bgereg.h	Mon May  2 22:49:43 2011	(r221351)
 @@ -2748,6 +2748,7 @@ struct bge_softc {
  	uint32_t		bge_flags;
  #define	BGE_FLAG_TBI		0x00000001
  #define	BGE_FLAG_JUMBO		0x00000002
 +#define	BGE_FLAG_JUMBO_STD	0x00000004
  #define	BGE_FLAG_EADDR		0x00000008
  #define	BGE_FLAG_MII_SERDES	0x00000010
  #define	BGE_FLAG_CPMU_PRESENT	0x00000020
 _______________________________________________
 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: kern/155192: commit references a PR
Date: Mon,  2 May 2011 22:52:31 +0000 (UTC)

 Author: yongari
 Date: Mon May  2 22:52:22 2011
 New Revision: 221352
 URL: http://svn.freebsd.org/changeset/base/221352
 
 Log:
   MFC r220368:
     Add initial jumbo frame support for BCM5714/BCM5715 and BCM5780.
     Unlike other controllers which have more advanced jumbo support,
     these controllers have one send ring, one standard receive producer
     ring and one receive return ring. In order to receive jumbo frames
     on the controllers, driver now will increase Rx buffer size to 9k.
     Two Rx modes are supported on these controllers and I chose
     standard Rx BDs over extended Rx BDs. The extended Rx BD mode
     allows up to 4 segmentations for each Rx BDs such that kernel does
     not have to allocate large buffer of contiguous memory for
     receiving. The extended Rx BD mode is already used on controllers
     that have separate jumbo receive ring. However, using extended Rx
     BDs on BCM5714/BCM5715/BCM5780 reduces the number of Rx BDs to 256
     entries which in turn may reduce the performance.  Also UMA backed
     page allocator for jumbo frame returns contiguous memory so using
     extended Rx BD has no advantage on FreeBSD unless highly customized
     local allocator implemented in driver is used.
     To use jumbo buffers in standard receive ring, Rx buffer allocation
     handler was changed to allocate MJUM9BYTES sized mbuf.
   
     PR:		kern/155192
     Tested by:	Vijay Singh <vijju.singh <> gmail dot com>
     Submitted by:	mjacob (initial version)
 
 Modified:
   stable/7/sys/dev/bge/if_bge.c
   stable/7/sys/dev/bge/if_bgereg.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/bge/if_bge.c
 ==============================================================================
 --- stable/7/sys/dev/bge/if_bge.c	Mon May  2 22:49:43 2011	(r221351)
 +++ stable/7/sys/dev/bge/if_bge.c	Mon May  2 22:52:22 2011	(r221352)
 @@ -943,10 +943,19 @@ bge_newbuf_std(struct bge_softc *sc, int
  	bus_dmamap_t map;
  	int error, nsegs;
  
 -	m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 -	if (m == NULL)
 -		return (ENOBUFS);
 -	m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD &&
 +	    (sc->bge_ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN +
 +	    ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) {
 +		m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MJUM9BYTES;
 +	} else {
 +		m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR);
 +		if (m == NULL)
 +			return (ENOBUFS);
 +		m->m_len = m->m_pkthdr.len = MCLBYTES;
 +	}
  	if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0)
  		m_adj(m, ETHER_ALIGN);
  
 @@ -2385,7 +2394,7 @@ static int
  bge_dma_alloc(struct bge_softc *sc)
  {
  	bus_addr_t lowaddr;
 -	bus_size_t boundary, sbsz, txsegsz, txmaxsegsz;
 +	bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz;
  	int i, error;
  
  	lowaddr = BUS_SPACE_MAXADDR;
 @@ -2513,9 +2522,13 @@ bge_dma_alloc(struct bge_softc *sc)
  	}
  
  	/* Create tag for Rx mbufs. */
 +	if (sc->bge_flags & BGE_FLAG_JUMBO_STD)
 +		rxmaxsegsz = MJUM9BYTES;
 +	else
 +		rxmaxsegsz = MCLBYTES;
  	error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0,
 -	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, MCLBYTES, 1,
 -	    MCLBYTES, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
 +	    BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rxmaxsegsz, 1,
 +	    rxmaxsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag);
  
  	if (error) {
  		device_printf(sc->bge_dev, "could not allocate RX dma tag\n");
 @@ -2759,7 +2772,7 @@ bge_attach(device_t dev)
  	case BGE_ASICREV_BCM5714_A0:
  	case BGE_ASICREV_BCM5780:
  	case BGE_ASICREV_BCM5714:
 -		sc->bge_flags |= BGE_FLAG_5714_FAMILY /* | BGE_FLAG_JUMBO */;
 +		sc->bge_flags |= BGE_FLAG_5714_FAMILY | BGE_FLAG_JUMBO_STD;
  		/* FALLTHROUGH */
  	case BGE_ASICREV_BCM5750:
  	case BGE_ASICREV_BCM5752:
 @@ -3560,7 +3573,8 @@ bge_rxeof(struct bge_softc *sc, uint16_t
  	    sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD);
  	bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag,
  	    sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTWRITE);
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN))
  		bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag,
  		    sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE);
 @@ -4685,7 +4699,8 @@ bge_init_locked(struct bge_softc *sc)
  	}
  
  	/* Init jumbo RX ring. */
 -	if (ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
 +	if (BGE_IS_JUMBO_CAPABLE(sc) &&
 +	    ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN >
  	    (MCLBYTES - ETHER_ALIGN)) {
  		if (bge_init_rx_ring_jumbo(sc) != 0) {
  			device_printf(sc->bge_dev,
 @@ -4910,14 +4925,19 @@ bge_ioctl(struct ifnet *ifp, u_long comm
  
  	switch (command) {
  	case SIOCSIFMTU:
 +		if (BGE_IS_JUMBO_CAPABLE(sc) ||
 +		    (sc->bge_flags & BGE_FLAG_JUMBO_STD)) {
 +			if (ifr->ifr_mtu < ETHERMIN ||
 +			    ifr->ifr_mtu > BGE_JUMBO_MTU) {
 +				error = EINVAL;
 +				break;
 +			}
 +		} else if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) {
 +			error = EINVAL; 
 +			break;
 +		}
  		BGE_LOCK(sc);
 -		if (ifr->ifr_mtu < ETHERMIN ||
 -		    ((BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > BGE_JUMBO_MTU) ||
 -		    ((!BGE_IS_JUMBO_CAPABLE(sc)) &&
 -		    ifr->ifr_mtu > ETHERMTU))
 -			error = EINVAL;
 -		else if (ifp->if_mtu != ifr->ifr_mtu) {
 +		if (ifp->if_mtu != ifr->ifr_mtu) {
  			ifp->if_mtu = ifr->ifr_mtu;
  			if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
  				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 
 Modified: stable/7/sys/dev/bge/if_bgereg.h
 ==============================================================================
 --- stable/7/sys/dev/bge/if_bgereg.h	Mon May  2 22:49:43 2011	(r221351)
 +++ stable/7/sys/dev/bge/if_bgereg.h	Mon May  2 22:52:22 2011	(r221352)
 @@ -2748,6 +2748,7 @@ struct bge_softc {
  	uint32_t		bge_flags;
  #define	BGE_FLAG_TBI		0x00000001
  #define	BGE_FLAG_JUMBO		0x00000002
 +#define	BGE_FLAG_JUMBO_STD	0x00000004
  #define	BGE_FLAG_EADDR		0x00000008
  #define	BGE_FLAG_MII_SERDES	0x00000010
  #define	BGE_FLAG_CPMU_PRESENT	0x00000020
 _______________________________________________
 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"
 
State-Changed-From-To: patched->closed 
State-Changed-By: yongari 
State-Changed-When: Tue May 10 02:18:41 UTC 2011 
State-Changed-Why:  
MFC to both stable/8 and stable/7 complete. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155192 
>Unformatted:
