From reinierk@r4-ams-xl0.band-x.nl  Tue May 29 08:49:07 2001
Return-Path: <reinierk@r4-ams-xl0.band-x.nl>
Received: from r4-ams-xl0.band-x.nl (r4-ams-vlan3.band-x.nl [217.8.96.218])
	by hub.freebsd.org (Postfix) with ESMTP id 7A1DE37B423
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 29 May 2001 08:49:06 -0700 (PDT)
	(envelope-from reinierk@r4-ams-xl0.band-x.nl)
Received: (from reinierk@localhost)
	by r4-ams-xl0.band-x.nl (8.11.3/8.11.3) id f4TFmUu01311;
	Tue, 29 May 2001 17:48:30 +0200 (CEST)
	(envelope-from reinierk)
Message-Id: <200105291548.f4TFmUu01311@r4-ams-xl0.band-x.nl>
Date: Tue, 29 May 2001 17:48:30 +0200 (CEST)
From: reinier.kleipool@band-x.nl
Reply-To: reinier.kleipool@band-x.nl
To: FreeBSD-gnats-submit@freebsd.org
Cc: joop.feenstra@band-x.nl
Subject: Patch for if_xl.c to fix vlan packets dropping
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         27742
>Category:       kern
>Synopsis:       if_xl.c drops 802.1q vlan packets
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    wpaul
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 29 08:50:01 PDT 2001
>Closed-Date:    Thu May 31 15:10:44 PDT 2001
>Last-Modified:  Thu May 31 15:11:49 PDT 2001
>Originator:     Reinier Kleipool
>Release:        FreeBSD 4.3-RELEASE i386
>Organization:
Band-X Benelux
>Environment:
System: FreeBSD r4-ams.band-x.nl 4.3-RELEASE FreeBSD 4.3-RELEASE #4: Tue May 29 11:44:27 CEST 2001 root@r4-ams.band-x.nl:/usr/src/sys/compile/ASUS i386

>Description:
The 3C905X driver (/sys/pci/if_xl.c) does not allow reception of ethernet frames larger than 1518 bytes.
When the xl interface is used as a 802.1q trunk line it looses packets.
This patch configures the NIC to receive XL_PACKETS_SIZE (defined in /sys/pci/if_reg.h). Defaults to 1540.
>How-To-Repeat:
Connect a xl0 interface of FreeBSD to a Cisco Catalyst.
Configure the Catalyst port to trunking mode.
Configure a FreeBSD kernel with "pseudo-device vlan 4".
Configure a vlan interface with a parent i/f of xl0.
Try pinging something on the Catalyst VLAN with a packet size of 1500.
Both the Cat and FreeBSD will add 802.1q ethernetheader fields to the frames.
The incoming frames will be dropped by the driver. 
>Fix:
Patch if_xl.c to write the value of XL_PACKET_SIZE to the MaxPktSize register so
the NIC will accept frames up to that size.
Patch if_xlreg.h to change to XL_PACKETS_SIZE to 1540 and
add a #define for the MaxPktSize register of the nic.
See following two diffs:

r4-ams> diff -crN /sys/pci/if_xl.c /sys/pci/if_xl.c.orig
*** /sys/pci/if_xl.c	Tue May 29 11:15:36 2001
--- /sys/pci/if_xl.c.orig	Tue May 29 10:39:39 2001
***************
*** 2593,2601 ****
  	else
  		CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_COAX_STOP);
  
- 	/* increase packet size to allow reception of 802.1q or ISL packets */
- 	 if (sc->xl_type == XL_TYPE_905B) 
- 		CSR_WRITE_2(sc, XL_W3_MAXPKTSIZE, XL_PACKET_SIZE);
  	/* Clear out the stats counters. */
  	CSR_WRITE_2(sc, XL_COMMAND, XL_CMD_STATS_DISABLE);
  	sc->xl_stats_no_timeout = 1;
--- 2593,2598 ----


r4-ams> diff -crN /sys/pci/if_xlreg.h /sys/pci/if_xlreg.h.orig

*** /sys/pci/if_xlreg.h	Tue May 29 11:44:02 2001
--- /sys/pci/if_xlreg.h.orig	Tue May 29 10:39:54 2001
***************
*** 80,86 ****
  #define XL_CAPS_100MBPS		0x1000
  #define XL_CAPS_PWRMGMT		0x2000
  
! #define XL_PACKET_SIZE 1540
  	
  /*
   * Register layouts.
--- 80,86 ----
  #define XL_CAPS_100MBPS		0x1000
  #define XL_CAPS_PWRMGMT		0x2000
  
! #define XL_PACKET_SIZE 1536
  	
  /*
   * Register layouts.
***************
*** 252,258 ****
   * Window 3 (fifo management)
   */
  #define XL_W3_INTERNAL_CFG	0x00
- #define XL_W3_MAXPKTSIZE	0x04    /* 3c905B only */
  #define XL_W3_RESET_OPT		0x08
  #define XL_W3_FREE_TX		0x0C
  #define XL_W3_FREE_RX		0x0A
--- 252,257 ----
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->wpaul 
Responsible-Changed-By: yar 
Responsible-Changed-When: Thu May 31 00:25:53 PDT 2001 
Responsible-Changed-Why:  
Over to the maintainer. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=27742 
State-Changed-From-To: open->closed 
State-Changed-By: wpaul 
State-Changed-When: Thu May 31 15:10:44 PDT 2001 
State-Changed-Why:  
Patch applied to both -current and -stable. There is a way to make this 
work for the pre-cyclone cards as well, but it's not as clean and direct 
as your approach. For now, this will do. 

-Bill 

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