From nobody@FreeBSD.org  Wed Apr 21 15:34:53 2010
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 332421065677
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Apr 2010 15:34:53 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 2189E8FC0C
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Apr 2010 15:34:53 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o3LFYqcb032719
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 21 Apr 2010 15:34:52 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o3LFYqGI032718;
	Wed, 21 Apr 2010 15:34:52 GMT
	(envelope-from nobody)
Message-Id: <201004211534.o3LFYqGI032718@www.freebsd.org>
Date: Wed, 21 Apr 2010 15:34:52 GMT
From: Gennady Kudryashoff <gennady@gmx.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: After spontaneous ae0 "watchdog timeout", "stray Tx interrupt(s)", "size mismatch" messages, interface hangs up
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         145918
>Category:       kern
>Synopsis:       [ae] After spontaneous ae0 "watchdog timeout", "stray Tx interrupt(s)", "size mismatch" messages, interface hangs up
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Apr 21 15:40:02 UTC 2010
>Closed-Date:    Wed Jan 04 21:36:20 UTC 2012
>Last-Modified:  Wed Jan 04 21:36:20 UTC 2012
>Originator:     Gennady Kudryashoff
>Release:        FreeBSD 7.3 Release
>Organization:
Federal Migration Service, Russia, Moscow branch
>Environment:
FreeBSD morannon.home 7.3-RELEASE FreeBSD 7.3-RELEASE #0: Sun Mar 21 06:15:01 UTC 2010     root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
The box works as test NAT+Router+Firewall machine (AsusEEE PC 701), ae0 is internal network interface (ext is axe0).

There are spontaneous messages like that:

ae0: Size mismatch: TxS:384 TxD:14900
ae0: Received stray Tx interrupt(s).
ae0: Size mismatch: TxS:392 TxD:12336
ae0: Size mismatch: TxS:388 TxD:29285
ae0: Size mismatch: TxS:368 TxD:28270
ae0: Size mismatch: TxS:400 TxD:14896
ae0: Size mismatch: TxS:382 TxD:25445
ae0: watchdog timeout - resetting.

or

ae0: watchdog timeout - resetting.

or

ae0: Size mismatch: TxS:384 TxD:2573
ae0: Received stray Tx interrupt(s).
ae0: watchdog timeout - resetting.

After that messages appears on console and dmesg, interface doesn't respond. The only solution is

ifconfig ae0 down && ifconfig ae0 up

to make it work properly.

This behaviour is unpredictable on time and appears both under mid-heavy load and in idle state (no internal connections).

Also, according to message in http://forums.freebsd.org/showthread.php?s=3a2a2318a953d85109318a2ca26f24f0&t=11528 such behaviour seems to appear on FreeBSD 8.

I believe that a problem in the driver, because OpenBSD with different driver implementation (lii) and ArchLinux with 2.6.33 kernel works well.

>How-To-Repeat:
Install FreeBSD 7.3 on AsusEEE 701, and just wait some time (from 2h to 48h).

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Apr 21 17:24:12 UTC 2010 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145918 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Tue Jul 6 02:30:39 UTC 2010 
State-Changed-Why:  
Would you try patch at the following URL? 
http://people.freebsd.org/~yongari/ae.queue.patch 


Responsible-Changed-From-To: freebsd-net->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Tue Jul 6 02:30:39 UTC 2010 
Responsible-Changed-Why:  
Grab. 

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

From: Pyun YongHyeon <pyunyh@gmail.com>
To: Gennady Kudryashoff <gennady@gmx.com>
Cc: yongari@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: kern/145918: [ae] After spontaneous ae0 "watchdog timeout", "stray Tx interrupt(s)", "size mismatch" messages, interface hangs up
Date: Tue, 6 Jul 2010 14:51:32 -0700

 On Wed, Jul 07, 2010 at 12:54:10AM +0400, Gennady Kudryashoff wrote:
 > On 06.07.2010 06:31, yongari@FreeBSD.org wrote:
 > >Synopsis: [ae] After spontaneous ae0 "watchdog timeout", "stray Tx 
 > >interrupt(s)", "size mismatch" messages, interface hangs up
 > >
 > >State-Changed-From-To: open->feedback
 > >State-Changed-By: yongari
 > >State-Changed-When: Tue Jul 6 02:30:39 UTC 2010
 > >State-Changed-Why:
 > >Would you try patch at the following URL?
 > >http://people.freebsd.org/~yongari/ae.queue.patch
 > >   
 > 
 > What version of FreeBSD should I use?
 > 
 
 8.0-RELEASE, 8.1-RC2 or 7.3-RELEASE
 
 > >
 > >Responsible-Changed-From-To: freebsd-net->yongari
 > >Responsible-Changed-By: yongari
 > >Responsible-Changed-When: Tue Jul 6 02:30:39 UTC 2010
 > >Responsible-Changed-Why:
 > >Grab.
 > >
 > >http://www.freebsd.org/cgi/query-pr.cgi?pr=145918
 > >
 > >   
 > 

From: Pyun YongHyeon <pyunyh@gmail.com>
To: Gennady Kudryashoff <gennady@gmx.com>
Cc: yongari@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: kern/145918: [ae] After spontaneous ae0 "watchdog timeout", "stray Tx interrupt(s)", "size mismatch" messages, interface hangs up
Date: Tue, 27 Jul 2010 15:14:32 -0700

 On Tue, Jul 06, 2010 at 02:51:32PM -0700, Pyun YongHyeon wrote:
 > On Wed, Jul 07, 2010 at 12:54:10AM +0400, Gennady Kudryashoff wrote:
 > > On 06.07.2010 06:31, yongari@FreeBSD.org wrote:
 > > >Synopsis: [ae] After spontaneous ae0 "watchdog timeout", "stray Tx 
 > > >interrupt(s)", "size mismatch" messages, interface hangs up
 > > >
 > > >State-Changed-From-To: open->feedback
 > > >State-Changed-By: yongari
 > > >State-Changed-When: Tue Jul 6 02:30:39 UTC 2010
 > > >State-Changed-Why:
 > > >Would you try patch at the following URL?
 > > >http://people.freebsd.org/~yongari/ae.queue.patch
 > > >   
 > > 
 > > What version of FreeBSD should I use?
 > > 
 > 
 > 8.0-RELEASE, 8.1-RC2 or 7.3-RELEASE
 > 
 
 Any progress?
State-Changed-From-To: feedback->closed 
State-Changed-By: yongari 
State-Changed-When: Mon Jan 17 19:54:05 UTC 2011 
State-Changed-Why:  
Feedback timeout. 
If you see the issue again please try patch posted in the PR and 
let me know the result. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=145918 
State-Changed-From-To: closed->open 
State-Changed-By: yongari 
State-Changed-When: Tue Oct 18 21:23:54 UTC 2011 
State-Changed-Why:  
Reopen, I got an active tester who is suffering from the same issue. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/145918: commit references a PR
Date: Fri, 11 Nov 2011 19:15:44 +0000 (UTC)

 Author: yongari
 Date: Fri Nov 11 19:15:32 2011
 New Revision: 227452
 URL: http://svn.freebsd.org/changeset/base/227452
 
 Log:
   To send a frame, controller requires a prepended TX header and
   the length of frame should be treated as multiple of 4. Actual
   frame length is set in the TX header. The TX header position
   should be aligned on 4 byte boundary and actual frame start
   position should be aligned on 4 byte boundary as well. This means
   we need 4(TX header length) + 3(frame length fixup) additional free
   space in TX buffer in addition to actual frame length.
   Make sure TX handler check these additional bytes.
   ae_tx_avail_size() returns actual free space in TX buffer to ease
   the calculation of available TX buffer space in caller. While I'm
   here, replace magic number to appropriate sizeof operator to
   enhance readability.
   
   This change should fix controller lockup issue happened under
   certain conditions but it still does not fix watchdog timeout. It
   seems the watchdog timeout is side-effect of TxS and TxD
   mismatches. The root cause of TxD/TxD mismatch is not known yet but
   it looks like silicon bug. I guess driver may have to reinitialize
   controller whenever it sees TxS and TxD mismatches but leave it as
   it was at this moment.
   
   PR:	kern/145918
 
 Modified:
   head/sys/dev/ae/if_ae.c
 
 Modified: head/sys/dev/ae/if_ae.c
 ==============================================================================
 --- head/sys/dev/ae/if_ae.c	Fri Nov 11 15:24:17 2011	(r227451)
 +++ head/sys/dev/ae/if_ae.c	Fri Nov 11 19:15:32 2011	(r227452)
 @@ -1431,7 +1431,7 @@ ae_tx_avail_size(ae_softc_t *sc)
  	else
  		avail = sc->txd_ack - sc->txd_cur;
  
 -	return (avail - 4);	/* 4-byte header. */
 +	return (avail);
  }
  
  static int
 @@ -1448,7 +1448,7 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  	len = m0->m_pkthdr.len;
  	
  	if ((sc->flags & AE_FLAG_TXAVAIL) == 0 ||
 -	    ae_tx_avail_size(sc) < len) {
 +	    len + sizeof(ae_txd_t) + 3 > ae_tx_avail_size(sc)) {
  #ifdef AE_DEBUG
  		if_printf(sc->ifp, "No free Tx available.\n");
  #endif
 @@ -1457,11 +1457,10 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  
  	hdr = (ae_txd_t *)(sc->txd_base + sc->txd_cur);
  	bzero(hdr, sizeof(*hdr));
 -	sc->txd_cur = (sc->txd_cur + 4) % AE_TXD_BUFSIZE_DEFAULT; /* Header
 -								     size. */
 -	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur; /* Space available to
 -							* the end of the ring
 -							*/
 +	/* Skip header size. */
 +	sc->txd_cur = (sc->txd_cur + sizeof(ae_txd_t)) % AE_TXD_BUFSIZE_DEFAULT;
 +	/* Space available to the end of the ring */
 +	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur;
  	if (to_end >= len) {
  		m_copydata(m0, 0, len, (caddr_t)(sc->txd_base + sc->txd_cur));
  	} else {
 @@ -1840,8 +1839,8 @@ ae_tx_intr(ae_softc_t *sc)
  		/*
  		 * Move txd ack and align on 4-byte boundary.
  		 */
 -		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) + 4 + 3) & ~3) %
 -		    AE_TXD_BUFSIZE_DEFAULT;
 +		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) +
 +		    sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT;
  
  		if ((flags & AE_TXS_SUCCESS) != 0)
  			ifp->if_opackets++;
 _______________________________________________
 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: open->patched 
State-Changed-By: yongari 
State-Changed-When: Fri Nov 11 19:24:10 UTC 2011 
State-Changed-Why:  
Fixed in HEAD(r227452). 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/145918: commit references a PR
Date: Wed,  4 Jan 2012 21:25:31 +0000 (UTC)

 Author: yongari
 Date: Wed Jan  4 21:25:11 2012
 New Revision: 229520
 URL: http://svn.freebsd.org/changeset/base/229520
 
 Log:
   MFC r227452:
     To send a frame, controller requires a prepended TX header and
     the length of frame should be treated as multiple of 4. Actual
     frame length is set in the TX header. The TX header position
     should be aligned on 4 byte boundary and actual frame start
     position should be aligned on 4 byte boundary as well. This means
     we need 4(TX header length) + 3(frame length fixup) additional free
     space in TX buffer in addition to actual frame length.
     Make sure TX handler check these additional bytes.
     ae_tx_avail_size() returns actual free space in TX buffer to ease
     the calculation of available TX buffer space in caller. While I'm
     here, replace magic number to appropriate sizeof operator to
     enhance readability.
   
     This change should fix controller lockup issue happened under
     certain conditions but it still does not fix watchdog timeout. It
     seems the watchdog timeout is side-effect of TxS and TxD
     mismatches. The root cause of TxD/TxD mismatch is not known yet but
     it looks like silicon bug. I guess driver may have to reinitialize
     controller whenever it sees TxS and TxD mismatches but leave it as
     it was at this moment.
   
     PR:	kern/145918
 
 Modified:
   stable/9/sys/dev/ae/if_ae.c
 Directory Properties:
   stable/9/sys/   (props changed)
   stable/9/sys/amd64/include/xen/   (props changed)
   stable/9/sys/boot/   (props changed)
   stable/9/sys/boot/i386/efi/   (props changed)
   stable/9/sys/boot/ia64/efi/   (props changed)
   stable/9/sys/boot/ia64/ski/   (props changed)
   stable/9/sys/boot/powerpc/boot1.chrp/   (props changed)
   stable/9/sys/boot/powerpc/ofw/   (props changed)
   stable/9/sys/cddl/contrib/opensolaris/   (props changed)
   stable/9/sys/conf/   (props changed)
   stable/9/sys/contrib/dev/acpica/   (props changed)
   stable/9/sys/contrib/octeon-sdk/   (props changed)
   stable/9/sys/contrib/pf/   (props changed)
   stable/9/sys/contrib/x86emu/   (props changed)
 
 Modified: stable/9/sys/dev/ae/if_ae.c
 ==============================================================================
 --- stable/9/sys/dev/ae/if_ae.c	Wed Jan  4 21:14:22 2012	(r229519)
 +++ stable/9/sys/dev/ae/if_ae.c	Wed Jan  4 21:25:11 2012	(r229520)
 @@ -1431,7 +1431,7 @@ ae_tx_avail_size(ae_softc_t *sc)
  	else
  		avail = sc->txd_ack - sc->txd_cur;
  
 -	return (avail - 4);	/* 4-byte header. */
 +	return (avail);
  }
  
  static int
 @@ -1448,7 +1448,7 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  	len = m0->m_pkthdr.len;
  	
  	if ((sc->flags & AE_FLAG_TXAVAIL) == 0 ||
 -	    ae_tx_avail_size(sc) < len) {
 +	    len + sizeof(ae_txd_t) + 3 > ae_tx_avail_size(sc)) {
  #ifdef AE_DEBUG
  		if_printf(sc->ifp, "No free Tx available.\n");
  #endif
 @@ -1457,11 +1457,10 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  
  	hdr = (ae_txd_t *)(sc->txd_base + sc->txd_cur);
  	bzero(hdr, sizeof(*hdr));
 -	sc->txd_cur = (sc->txd_cur + 4) % AE_TXD_BUFSIZE_DEFAULT; /* Header
 -								     size. */
 -	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur; /* Space available to
 -							* the end of the ring
 -							*/
 +	/* Skip header size. */
 +	sc->txd_cur = (sc->txd_cur + sizeof(ae_txd_t)) % AE_TXD_BUFSIZE_DEFAULT;
 +	/* Space available to the end of the ring */
 +	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur;
  	if (to_end >= len) {
  		m_copydata(m0, 0, len, (caddr_t)(sc->txd_base + sc->txd_cur));
  	} else {
 @@ -1840,8 +1839,8 @@ ae_tx_intr(ae_softc_t *sc)
  		/*
  		 * Move txd ack and align on 4-byte boundary.
  		 */
 -		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) + 4 + 3) & ~3) %
 -		    AE_TXD_BUFSIZE_DEFAULT;
 +		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) +
 +		    sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT;
  
  		if ((flags & AE_TXS_SUCCESS) != 0)
  			ifp->if_opackets++;
 _______________________________________________
 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/145918: commit references a PR
Date: Wed,  4 Jan 2012 21:27:13 +0000 (UTC)

 Author: yongari
 Date: Wed Jan  4 21:27:03 2012
 New Revision: 229522
 URL: http://svn.freebsd.org/changeset/base/229522
 
 Log:
   MFC r227452:
     To send a frame, controller requires a prepended TX header and
     the length of frame should be treated as multiple of 4. Actual
     frame length is set in the TX header. The TX header position
     should be aligned on 4 byte boundary and actual frame start
     position should be aligned on 4 byte boundary as well. This means
     we need 4(TX header length) + 3(frame length fixup) additional free
     space in TX buffer in addition to actual frame length.
     Make sure TX handler check these additional bytes.
     ae_tx_avail_size() returns actual free space in TX buffer to ease
     the calculation of available TX buffer space in caller. While I'm
     here, replace magic number to appropriate sizeof operator to
     enhance readability.
   
     This change should fix controller lockup issue happened under
     certain conditions but it still does not fix watchdog timeout. It
     seems the watchdog timeout is side-effect of TxS and TxD
     mismatches. The root cause of TxD/TxD mismatch is not known yet but
     it looks like silicon bug. I guess driver may have to reinitialize
     controller whenever it sees TxS and TxD mismatches but leave it as
     it was at this moment.
   
     PR:	kern/145918
 
 Modified:
   stable/8/sys/dev/ae/if_ae.c
 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/ae/if_ae.c
 ==============================================================================
 --- stable/8/sys/dev/ae/if_ae.c	Wed Jan  4 21:26:47 2012	(r229521)
 +++ stable/8/sys/dev/ae/if_ae.c	Wed Jan  4 21:27:03 2012	(r229522)
 @@ -1432,7 +1432,7 @@ ae_tx_avail_size(ae_softc_t *sc)
  	else
  		avail = sc->txd_ack - sc->txd_cur;
  
 -	return (avail - 4);	/* 4-byte header. */
 +	return (avail);
  }
  
  static int
 @@ -1449,7 +1449,7 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  	len = m0->m_pkthdr.len;
  	
  	if ((sc->flags & AE_FLAG_TXAVAIL) == 0 ||
 -	    ae_tx_avail_size(sc) < len) {
 +	    len + sizeof(ae_txd_t) + 3 > ae_tx_avail_size(sc)) {
  #ifdef AE_DEBUG
  		if_printf(sc->ifp, "No free Tx available.\n");
  #endif
 @@ -1458,11 +1458,10 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  
  	hdr = (ae_txd_t *)(sc->txd_base + sc->txd_cur);
  	bzero(hdr, sizeof(*hdr));
 -	sc->txd_cur = (sc->txd_cur + 4) % AE_TXD_BUFSIZE_DEFAULT; /* Header
 -								     size. */
 -	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur; /* Space available to
 -							* the end of the ring
 -							*/
 +	/* Skip header size. */
 +	sc->txd_cur = (sc->txd_cur + sizeof(ae_txd_t)) % AE_TXD_BUFSIZE_DEFAULT;
 +	/* Space available to the end of the ring */
 +	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur;
  	if (to_end >= len) {
  		m_copydata(m0, 0, len, (caddr_t)(sc->txd_base + sc->txd_cur));
  	} else {
 @@ -1841,8 +1840,8 @@ ae_tx_intr(ae_softc_t *sc)
  		/*
  		 * Move txd ack and align on 4-byte boundary.
  		 */
 -		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) + 4 + 3) & ~3) %
 -		    AE_TXD_BUFSIZE_DEFAULT;
 +		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) +
 +		    sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT;
  
  		if ((flags & AE_TXS_SUCCESS) != 0)
  			ifp->if_opackets++;
 _______________________________________________
 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/145918: commit references a PR
Date: Wed,  4 Jan 2012 21:29:04 +0000 (UTC)

 Author: yongari
 Date: Wed Jan  4 21:28:49 2012
 New Revision: 229523
 URL: http://svn.freebsd.org/changeset/base/229523
 
 Log:
   MFC r227452:
     To send a frame, controller requires a prepended TX header and
     the length of frame should be treated as multiple of 4. Actual
     frame length is set in the TX header. The TX header position
     should be aligned on 4 byte boundary and actual frame start
     position should be aligned on 4 byte boundary as well. This means
     we need 4(TX header length) + 3(frame length fixup) additional free
     space in TX buffer in addition to actual frame length.
     Make sure TX handler check these additional bytes.
     ae_tx_avail_size() returns actual free space in TX buffer to ease
     the calculation of available TX buffer space in caller. While I'm
     here, replace magic number to appropriate sizeof operator to
     enhance readability.
   
     This change should fix controller lockup issue happened under
     certain conditions but it still does not fix watchdog timeout. It
     seems the watchdog timeout is side-effect of TxS and TxD
     mismatches. The root cause of TxD/TxD mismatch is not known yet but
     it looks like silicon bug. I guess driver may have to reinitialize
     controller whenever it sees TxS and TxD mismatches but leave it as
     it was at this moment.
   
     PR:	kern/145918
 
 Modified:
   stable/7/sys/dev/ae/if_ae.c
 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/ae/if_ae.c
 ==============================================================================
 --- stable/7/sys/dev/ae/if_ae.c	Wed Jan  4 21:27:03 2012	(r229522)
 +++ stable/7/sys/dev/ae/if_ae.c	Wed Jan  4 21:28:49 2012	(r229523)
 @@ -1432,7 +1432,7 @@ ae_tx_avail_size(ae_softc_t *sc)
  	else
  		avail = sc->txd_ack - sc->txd_cur;
  
 -	return (avail - 4);	/* 4-byte header. */
 +	return (avail);
  }
  
  static int
 @@ -1449,7 +1449,7 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  	len = m0->m_pkthdr.len;
  	
  	if ((sc->flags & AE_FLAG_TXAVAIL) == 0 ||
 -	    ae_tx_avail_size(sc) < len) {
 +	    len + sizeof(ae_txd_t) + 3 > ae_tx_avail_size(sc)) {
  #ifdef AE_DEBUG
  		if_printf(sc->ifp, "No free Tx available.\n");
  #endif
 @@ -1458,11 +1458,10 @@ ae_encap(ae_softc_t *sc, struct mbuf **m
  
  	hdr = (ae_txd_t *)(sc->txd_base + sc->txd_cur);
  	bzero(hdr, sizeof(*hdr));
 -	sc->txd_cur = (sc->txd_cur + 4) % AE_TXD_BUFSIZE_DEFAULT; /* Header
 -								     size. */
 -	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur; /* Space available to
 -							* the end of the ring
 -							*/
 +	/* Skip header size. */
 +	sc->txd_cur = (sc->txd_cur + sizeof(ae_txd_t)) % AE_TXD_BUFSIZE_DEFAULT;
 +	/* Space available to the end of the ring */
 +	to_end = AE_TXD_BUFSIZE_DEFAULT - sc->txd_cur;
  	if (to_end >= len) {
  		m_copydata(m0, 0, len, (caddr_t)(sc->txd_base + sc->txd_cur));
  	} else {
 @@ -1841,8 +1840,8 @@ ae_tx_intr(ae_softc_t *sc)
  		/*
  		 * Move txd ack and align on 4-byte boundary.
  		 */
 -		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) + 4 + 3) & ~3) %
 -		    AE_TXD_BUFSIZE_DEFAULT;
 +		sc->txd_ack = ((sc->txd_ack + le16toh(txd->len) +
 +		    sizeof(ae_txs_t) + 3) & ~3) % AE_TXD_BUFSIZE_DEFAULT;
  
  		if ((flags & AE_TXS_SUCCESS) != 0)
  			ifp->if_opackets++;
 _______________________________________________
 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: Wed Jan 4 21:35:45 UTC 2012 
State-Changed-Why:  
MFC to stable/[7-9] complete. 
Thansk for reporting and testing! 

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