From rh@ts7.matriplex.com  Mon Dec 18 11:57:16 2000
Return-Path: <rh@ts7.matriplex.com>
Received: from ts7.matriplex.com (rt.matriplex.com [208.131.42.11])
	by hub.freebsd.org (Postfix) with ESMTP id 11C2337B402
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 18 Dec 2000 11:57:16 -0800 (PST)
Received: (from root@localhost)
	by ts7.matriplex.com (8.9.3/8.9.3) id LAA00400;
	Mon, 18 Dec 2000 11:55:15 -0800 (PST)
	(envelope-from rh)
Message-Id: <200012181955.LAA00400@ts7.matriplex.com>
Date: Mon, 18 Dec 2000 11:55:15 -0800 (PST)
From: rh <rh@ts7.matriplex.com>
Reply-To: rh@ts7.matriplex.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: Fore PCA200E ATM driver problems with FreeBSD 4.1
X-Send-Pr-Version: 3.2

>Number:         23620
>Category:       kern
>Synopsis:       Fore PCA200E ATM driver problems with FreeBSD 4.1
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pirzyk
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Dec 18 12:00:03 PST 2000
>Closed-Date:    Wed Jun 20 13:48:22 PDT 2001
>Last-Modified:  Wed Jun 20 13:48:57 PDT 2001
>Originator:     rh@matriplex.com
>Release:        FreeBSD 4.1-RELEASE i386
>Organization:
Matriplex, inc.
>Environment:

FreeBSD 4.1 or later with the Fore PCA200E driver compiled in.
HARP options are assumed. 

>Description:

When using HARP and the Fore PCA200E driver (hfa), severe packet
loss occurs.  This will result in very low performance.

>How-To-Repeat:

Compile kernel with the following ATM options:
  device          hfa
  options         ATM_CORE                #core ATM protocol family
  options         ATM_IP                  #IP over ATM support
  options         ATM_SIGPVC              #SIGPVC signalling manager
  options         ATM_UNI                 #UNI signalling manager

Initialize ATM normally:
  /sbin/fore_dnld
  /sbin/atm set netif hfa0 atm 1
  /sbin/atm attach hfa0 uni31
  /sbin/ilmid
  /sbin/atm set arpserver atm0 <arpserver address>

Now ping another host on the ATM network.  Example:
  --- 192.168.100.18 ping statistics ---
  11 packets transmitted, 8 packets received, 27% packet loss
  round-trip min/avg/max/stddev = 0.617/0.870/1.161/0.146 ms                      
>Fix:

There are two problems in the Fore driver code.  The first is an offset
that became negative with the new 4.1 mbuf size, and an expedient fix
was suggested by Joseph Thomas on 09/01/2000.  This is the first part
of the patch.

The other problem is that the Fore driver uses the m_pkthdr field in
the mbuf chain for its own private data, but does not clear it before
handing the mbuf chain to the HARP layer.  With the pre-4.1 mbufs, this
did not (apparently) cause any harm, but the new mbuf structure adds
new fields, which now contain corrupted data.  The solution is to
clear these fields before the Fore driver passes the mbuf chain up
to the HARP layer.

A better solution might be to clear the entire mbuf m_pkthdr structure
so that future changes to the mbuf structure will not expose any new
problems with the driver's private data.  Such a change might look
like this:  bzero(mhead->m_pkthdr, sizeof(struct pkthdr));
The best solution is probably to rewrite the driver so that it does
not use the m_pkthdr field for its private data.  From the way the
#defines are written, it seems that this may have been the intention
of the author.

A working patch for the driver follows:

diff -U5 sys/dev/hfa/fore.h sys.new/dev/hfa/fore.h
--- sys/dev/hfa/fore.h	Fri Aug 27 17:41:48 1999
+++ sys.new/dev/hfa/fore.h	Mon Dec 18 10:26:49 2000
@@ -115,11 +115,11 @@
  *			BUF_DATA_ALIGN) - BUF1_SM_HDR)
  *	#define	BUF1_SM_SIZE	MAX(BUF1_SM_LEN - BUF1_SM_DOFF, 64)
  *
  */
 #if ((BSD >= 199103) && defined(FORE_PCI))
-#define	BUF1_SM_DOFF	((BUF1_SM_HOFF + SIZEOF_Buf_handle) - BUF1_SM_HDR)
+#define	BUF1_SM_DOFF	(SIZEOF_Buf_handle)
 #define	BUF1_SM_SIZE	(BUF1_SM_LEN - BUF1_SM_DOFF)
 #endif
 #if ((BSD < 199103) && defined(FORE_SBUS) && defined(sun4c))
 #define	BUF1_SM_DOFF	(BUF_DATA_ALIGN - BUF1_SM_HDR)
 #define	BUF1_SM_SIZE	(BUF1_SM_LEN - BUF1_SM_DOFF)
diff -U5 sys/dev/hfa/fore_receive.c sys.new/dev/hfa/fore_receive.c
--- sys/dev/hfa/fore_receive.c	Fri Aug 27 17:41:51 1999
+++ sys.new/dev/hfa/fore_receive.c	Mon Dec 18 10:29:16 2000
@@ -417,10 +417,13 @@
 		}
 
 		/*
 		 * It looks like we've got a valid PDU - count it quick!!
 		 */
+		mhead->m_pkthdr.rcvif = NULL;
+		mhead->m_pkthdr.csum_flags = 0;
+		mhead->m_pkthdr.aux   = NULL;
 		KB_PLENSET(mhead, pdulen);
 		fup->fu_pif.pif_ipdus++;
 		fup->fu_pif.pif_ibytes += pdulen;
 		vcp = fvp->fv_connvc->cvc_vcc;
 		vcp->vc_ipdus++;


>Release-Note:
>Audit-Trail:

From: Poul-Henning Kamp <phk@critter.freebsd.dk>
To: rh@ts7.matriplex.com
Cc: FreeBSD-gnats-submit@FreeBSD.ORG
Subject: Re: kern/23620: Fore PCA200E ATM driver problems with FreeBSD 4.1 
Date: Mon, 18 Dec 2000 22:21:30 +0100

 In message <200012181955.LAA00400@ts7.matriplex.com>, rh writes:
 >
 >>Number:         23620
 >>Category:       kern
 >>Synopsis:       Fore PCA200E ATM driver problems with FreeBSD 4.1
 
 Can I get you to submit a patch relative to -current ?
 
 --
 Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
 phk@FreeBSD.ORG         | TCP/IP since RFC 956
 FreeBSD committer       | BSD since 4.3-tahoe    
 Never attribute to malice what can adequately be explained by incompetence.
 
Responsible-Changed-From-To: freebsd-bugs->pirzyk 
Responsible-Changed-By: pirzyk 
Responsible-Changed-When: Thu May 31 14:36:44 PDT 2001 
Responsible-Changed-Why:  
I am one of the few interested in HARP ATM code working again. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=23620 
State-Changed-From-To: open->closed 
State-Changed-By: pirzyk 
State-Changed-When: Wed Jun 20 13:48:22 PDT 2001 
State-Changed-Why:  
Applied the patch.  Thanks 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=23620 
>Unformatted:
