From nobody@FreeBSD.org  Wed Jun 10 17:35:05 2009
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 8DC8D1065675
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Jun 2009 17:35:05 +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 771108FC1D
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Jun 2009 17:35:05 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n5AHZ48R051444
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 10 Jun 2009 17:35:04 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n5AHZ4RI051443;
	Wed, 10 Jun 2009 17:35:04 GMT
	(envelope-from nobody)
Message-Id: <200906101735.n5AHZ4RI051443@www.freebsd.org>
Date: Wed, 10 Jun 2009 17:35:04 GMT
From: Tim Schwitalla <tim.schwitalla@gmx.net>
To: freebsd-gnats-submit@FreeBSD.org
Subject: no wol capability in fxp-driver for 82801-based chipset after upgrade to 7.2
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         135451
>Category:       kern
>Synopsis:       [fxp] no wol capability in fxp-driver for 82801-based chipset after upgrade to 7.2 [regression]
>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 Jun 10 17:40:01 UTC 2009
>Closed-Date:    Wed Nov 04 18:38:00 UTC 2009
>Last-Modified:  Wed Nov 04 18:38:00 UTC 2009
>Originator:     Tim Schwitalla
>Release:        7.2-RELEASE
>Organization:
>Environment:
FreeBSD evo.local 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May  1 08:49:13 UTC 2009     root@walker.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
after upgrading from FreeBSD 7.1 to 7.2 the computer doesn't wake up by receiving magic packets anymore. 
Setting up "legacy WOL" in the NIC's BIOS didn't solve the problem. Trying to set up WOL manually using
ifconfig doesn't help (the WOL flag doesn't show up either):

--
# ifconfig fxp0 wol
# ifconfig fxp0 
fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=8<VLAN_MTU>
	ether 00:08:02:11:36:86
--

Starting up the computer and shutting it down by pressing the power-switch before booting into FreeBSD lets the computer wake up by magic packets for the next time but once booting into FreeBSD it refuses again... 


dmesg-information about the NIC: 

--
fxp0: <Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet> port 0x1000-0x103f mem 0xfe200000-0xfe200fff irq 20 at device 8.0 on pci2
miibus0: <MII bus> on fxp0
inphy0: <i82562EM 10/100 media interface> PHY 1 on miibus0
inphy0:  10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto
fxp0: Ethernet address: 00:08:02:11:36:86
fxp0: [ITHREAD]
--
>How-To-Repeat:
- Boot into FreeBSD

- Optionally try:  
# ifconfig fxp0 wol

- Shut down: 
# halt -p 

- Try to wake up from a different machine using WOL.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Wed Jun 10 20:50:28 UTC 2009 
Responsible-Changed-Why:  
Over to maintainer(s). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=135451 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Fri Jun 12 07:32:18 UTC 2009 
State-Changed-Why:  
Would you try the following patch and let me know how it goes? 
http://people.freebsd.org/~yongari/fxp/fxp.ich.patch 

Also show me the output of "ifconfig fxp0", I'd like to know 
whether the patch also adds Rx checksum offloading support to ICH 
based controllers. 


Responsible-Changed-From-To: freebsd-net->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Fri Jun 12 07:32:18 UTC 2009 
Responsible-Changed-Why:  
Grab. 

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

From: Pyun YongHyeon <pyunyh@gmail.com>
To: Tim Schwitalla <tim.schwitalla@gmx.net>
Cc: yongari@FreeBSD.org, bug-followup@FreeBSD.org
Subject: Re: kern/135451: [fxp] no wol capability in fxp-driver for 82801-based chipset after upgrade to 7.2 [regression]
Date: Mon, 15 Jun 2009 20:13:49 +0900

 On Mon, Jun 15, 2009 at 12:31:19PM +0200, Tim Schwitalla wrote:
 > The patch works great. Thank you very much!! =)
 > 
 > 
 > Here's the output of ifconfig:
 > --
 > fxp0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu  
 > 1500
 > 	options=2009<RXCSUM,VLAN_MTU,WOL_MAGIC>
                      ^^^^^^          ^^^^^^^^^
 
 The patch also enabled Rx checksum offloading as well as WOL. You
 have no problem when receiving incoming packets, right?
 
 Thanks for testing!
State-Changed-From-To: feedback->analyzed 
State-Changed-By: yongari 
State-Changed-When: Tue Jun 16 07:18:53 UTC 2009 
State-Changed-Why:  
Submitter confirms that patch fixes the WOL issue. I'll commit it 
when I get more feeback for larger patchset posted to CURRENT ML. 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/135451: commit references a PR
Date: Sun, 21 Jun 2009 07:34:23 +0000 (UTC)

 Author: yongari
 Date: Sun Jun 21 07:34:12 2009
 New Revision: 194574
 URL: http://svn.freebsd.org/changeset/base/194574
 
 Log:
   For ICH based fxp(4) controllers treat them as 82559 compatibles.
   To detect which controller is ICH based one, add a new member
   variable ich to struct fxp_ident and move the struct to
   if_fxpvar.h. Since I've faked controller revision, don't allow
   microcode loading for ICH based controllers.
   With this change all ICH based controllers will have WOL and Rx
   checksum offload capability.
   
   PR:		kern/135451
   Tested by:	Alexey Shuvaev ( shuvaev <> physik dot uni-wuerzburg dot de ),
   		pluknet ( pluknet <> gmail dot com ),
   		Gary Jennejohn ( gary.jennejohn <> freenet dot de )
 
 Modified:
   head/sys/dev/fxp/if_fxp.c
   head/sys/dev/fxp/if_fxpvar.h
 
 Modified: head/sys/dev/fxp/if_fxp.c
 ==============================================================================
 --- head/sys/dev/fxp/if_fxp.c	Sun Jun 21 07:17:49 2009	(r194573)
 +++ head/sys/dev/fxp/if_fxp.c	Sun Jun 21 07:34:12 2009	(r194574)
 @@ -140,12 +140,6 @@ static u_char fxp_cb_config_template[] =
  	0x5	/* 21 */
  };
  
 -struct fxp_ident {
 -	uint16_t	devid;
 -	int16_t		revid;		/* -1 matches anything */
 -	char 		*name;
 -};
 -
  /*
   * Claim various Intel PCI device identifiers for this driver.  The
   * sub-vendor and sub-device field are extensively used to identify
 @@ -153,52 +147,52 @@ struct fxp_ident {
   * them.
   */
  static struct fxp_ident fxp_ident_table[] = {
 -    { 0x1029,	-1,	"Intel 82559 PCI/CardBus Pro/100" },
 -    { 0x1030,	-1,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1031,	-1,	"Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 -    { 0x1032,	-1,	"Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 -    { 0x1033,	-1,	"Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 -    { 0x1034,	-1,	"Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 -    { 0x1035,	-1,	"Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 -    { 0x1036,	-1,	"Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 -    { 0x1037,	-1,	"Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 -    { 0x1038,	-1,	"Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 -    { 0x1039,	-1,	"Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 -    { 0x103A,	-1,	"Intel 82801DB (ICH4) Pro/100 Ethernet" },
 -    { 0x103B,	-1,	"Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 -    { 0x103C,	-1,	"Intel 82801DB (ICH4) Pro/100 Ethernet" },
 -    { 0x103D,	-1,	"Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 -    { 0x103E,	-1,	"Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 -    { 0x1050,	-1,	"Intel 82801BA (D865) Pro/100 VE Ethernet" },
 -    { 0x1051,	-1,	"Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
 -    { 0x1059,	-1,	"Intel 82551QM Pro/100 M Mobile Connection" },
 -    { 0x1064,	-1,	"Intel 82562EZ (ICH6)" },
 -    { 0x1065,	-1,	"Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
 -    { 0x1068,	-1,	"Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
 -    { 0x1069,	-1,	"Intel 82562EM/EX/GX Pro/100 Ethernet" },
 -    { 0x1091,	-1,	"Intel 82562GX Pro/100 Ethernet" },
 -    { 0x1092,	-1,	"Intel Pro/100 VE Network Connection" },
 -    { 0x1093,	-1,	"Intel Pro/100 VM Network Connection" },
 -    { 0x1094,	-1,	"Intel Pro/100 946GZ (ICH7) Network Connection" },
 -    { 0x1209,	-1,	"Intel 82559ER Embedded 10/100 Ethernet" },
 -    { 0x1229,	0x01,	"Intel 82557 Pro/100 Ethernet" },
 -    { 0x1229,	0x02,	"Intel 82557 Pro/100 Ethernet" },
 -    { 0x1229,	0x03,	"Intel 82557 Pro/100 Ethernet" },
 -    { 0x1229,	0x04,	"Intel 82558 Pro/100 Ethernet" },
 -    { 0x1229,	0x05,	"Intel 82558 Pro/100 Ethernet" },
 -    { 0x1229,	0x06,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1229,	0x07,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1229,	0x08,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1229,	0x09,	"Intel 82559ER Pro/100 Ethernet" },
 -    { 0x1229,	0x0c,	"Intel 82550 Pro/100 Ethernet" },
 -    { 0x1229,	0x0d,	"Intel 82550 Pro/100 Ethernet" },
 -    { 0x1229,	0x0e,	"Intel 82550 Pro/100 Ethernet" },
 -    { 0x1229,	0x0f,	"Intel 82551 Pro/100 Ethernet" },
 -    { 0x1229,	0x10,	"Intel 82551 Pro/100 Ethernet" },
 -    { 0x1229,	-1,	"Intel 82557/8/9 Pro/100 Ethernet" },
 -    { 0x2449,	-1,	"Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
 -    { 0x27dc,	-1,	"Intel 82801GB (ICH7) 10/100 Ethernet" },
 -    { 0,	-1,	NULL },
 +    { 0x1029,	-1,	0, "Intel 82559 PCI/CardBus Pro/100" },
 +    { 0x1030,	-1,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1031,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 +    { 0x1032,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 +    { 0x1033,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 +    { 0x1034,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 +    { 0x1035,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 +    { 0x1036,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 +    { 0x1037,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 +    { 0x1038,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 +    { 0x1039,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 +    { 0x103A,	-1,	4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
 +    { 0x103B,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 +    { 0x103C,	-1,	4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
 +    { 0x103D,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 +    { 0x103E,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 +    { 0x1050,	-1,	5, "Intel 82801BA (D865) Pro/100 VE Ethernet" },
 +    { 0x1051,	-1,	5, "Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
 +    { 0x1059,	-1,	0, "Intel 82551QM Pro/100 M Mobile Connection" },
 +    { 0x1064,	-1,	6, "Intel 82562EZ (ICH6)" },
 +    { 0x1065,	-1,	6, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
 +    { 0x1068,	-1,	6, "Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
 +    { 0x1069,	-1,	6, "Intel 82562EM/EX/GX Pro/100 Ethernet" },
 +    { 0x1091,	-1,	7, "Intel 82562GX Pro/100 Ethernet" },
 +    { 0x1092,	-1,	7, "Intel Pro/100 VE Network Connection" },
 +    { 0x1093,	-1,	7, "Intel Pro/100 VM Network Connection" },
 +    { 0x1094,	-1,	7, "Intel Pro/100 946GZ (ICH7) Network Connection" },
 +    { 0x1209,	-1,	0, "Intel 82559ER Embedded 10/100 Ethernet" },
 +    { 0x1229,	0x01,	0, "Intel 82557 Pro/100 Ethernet" },
 +    { 0x1229,	0x02,	0, "Intel 82557 Pro/100 Ethernet" },
 +    { 0x1229,	0x03,	0, "Intel 82557 Pro/100 Ethernet" },
 +    { 0x1229,	0x04,	0, "Intel 82558 Pro/100 Ethernet" },
 +    { 0x1229,	0x05,	0, "Intel 82558 Pro/100 Ethernet" },
 +    { 0x1229,	0x06,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1229,	0x07,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1229,	0x08,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1229,	0x09,	0, "Intel 82559ER Pro/100 Ethernet" },
 +    { 0x1229,	0x0c,	0, "Intel 82550 Pro/100 Ethernet" },
 +    { 0x1229,	0x0d,	0, "Intel 82550 Pro/100 Ethernet" },
 +    { 0x1229,	0x0e,	0, "Intel 82550 Pro/100 Ethernet" },
 +    { 0x1229,	0x0f,	0, "Intel 82551 Pro/100 Ethernet" },
 +    { 0x1229,	0x10,	0, "Intel 82551 Pro/100 Ethernet" },
 +    { 0x1229,	-1,	0, "Intel 82557/8/9 Pro/100 Ethernet" },
 +    { 0x2449,	-1,	2, "Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
 +    { 0x27dc,	-1,	7, "Intel 82801GB (ICH7) 10/100 Ethernet" },
 +    { 0,	-1,	0, NULL },
  };
  
  #ifdef FXP_IP_CSUM_WAR
 @@ -214,6 +208,7 @@ static int		fxp_shutdown(device_t dev);
  static int		fxp_suspend(device_t dev);
  static int		fxp_resume(device_t dev);
  
 +static struct fxp_ident	*fxp_find_ident(device_t dev);
  static void		fxp_intr(void *xsc);
  static void		fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp,
  			    struct mbuf *m, uint16_t status, int pos);
 @@ -360,11 +355,8 @@ fxp_dma_wait(struct fxp_softc *sc, volat
  		device_printf(sc->dev, "DMA timeout\n");
  }
  
 -/*
 - * Return identification string if this device is ours.
 - */
 -static int
 -fxp_probe(device_t dev)
 +static struct fxp_ident *
 +fxp_find_ident(device_t dev)
  {
  	uint16_t devid;
  	uint8_t revid;
 @@ -376,11 +368,26 @@ fxp_probe(device_t dev)
  		for (ident = fxp_ident_table; ident->name != NULL; ident++) {
  			if (ident->devid == devid &&
  			    (ident->revid == revid || ident->revid == -1)) {
 -				device_set_desc(dev, ident->name);
 -				return (BUS_PROBE_DEFAULT);
 +				return (ident);
  			}
  		}
  	}
 +	return (NULL);
 +}
 +
 +/*
 + * Return identification string if this device is ours.
 + */
 +static int
 +fxp_probe(device_t dev)
 +{
 +	struct fxp_ident *ident;
 +
 +	ident = fxp_find_ident(dev);
 +	if (ident != NULL) {
 +		device_set_desc(dev, ident->name);
 +		return (BUS_PROBE_DEFAULT);
 +	}
  	return (ENXIO);
  }
  
 @@ -483,11 +490,17 @@ fxp_attach(device_t dev)
  	/*
  	 * Find out the chip revision; lump all 82557 revs together.
  	 */
 -	fxp_read_eeprom(sc, &data, 5, 1);
 -	if ((data >> 8) == 1)
 -		sc->revision = FXP_REV_82557;
 -	else
 -		sc->revision = pci_get_revid(dev);
 +	sc->ident = fxp_find_ident(dev);
 +	if (sc->ident->ich > 0) {
 +		/* Assume ICH controllers are 82559. */
 +		sc->revision = FXP_REV_82559_A0;
 +	} else {
 +		fxp_read_eeprom(sc, &data, 5, 1);
 +		if ((data >> 8) == 1)
 +			sc->revision = FXP_REV_82557;
 +		else
 +			sc->revision = pci_get_revid(dev);
 +	}
  
  	/*
  	 * Check availability of WOL. 82559ER does not support WOL.
 @@ -560,9 +573,8 @@ fxp_attach(device_t dev)
  	 *
  	 * See Intel 82801BA/82801BAM Specification Update, Errata #30.
  	 */
 -	i = pci_get_device(dev);
 -	if (i == 0x2449 || (i > 0x1030 && i < 0x1039) ||
 -	    sc->revision >= FXP_REV_82559_A0) {
 +	if ((sc->ident->ich >= 2 && sc->ident->ich <= 3) ||
 +	    (sc->ident->ich == 0 && sc->revision >= FXP_REV_82559_A0)) {
  		fxp_read_eeprom(sc, &data, 10, 1);
  		if (data & 0x02) {			/* STB enable */
  			uint16_t cksum;
 @@ -2246,9 +2258,13 @@ fxp_init_body(struct fxp_softc *sc)
  
  	/*
  	 * Attempt to load microcode if requested.
 +	 * For ICH based controllers do not load microcode.
  	 */
 -	if (ifp->if_flags & IFF_LINK0 && (sc->flags & FXP_FLAG_UCODE) == 0)
 -		fxp_load_ucode(sc);
 +	if (sc->ident->ich == 0) {
 +		if (ifp->if_flags & IFF_LINK0 &&
 +		    (sc->flags & FXP_FLAG_UCODE) == 0)
 +			fxp_load_ucode(sc);
 +	}
  
  	/*
  	 * Set IFF_ALLMULTI status. It's needed in configure action
 
 Modified: head/sys/dev/fxp/if_fxpvar.h
 ==============================================================================
 --- head/sys/dev/fxp/if_fxpvar.h	Sun Jun 21 07:17:49 2009	(r194573)
 +++ head/sys/dev/fxp/if_fxpvar.h	Sun Jun 21 07:34:12 2009	(r194574)
 @@ -142,6 +142,13 @@ struct fxp_desc_list {
  	bus_dma_tag_t rx_tag;
  };
  
 +struct fxp_ident {
 +	uint16_t	devid;
 +	int16_t		revid;		/* -1 matches anything */
 +	uint8_t		ich;
 +	char 		*name;
 +};
 +
  /*
   * NOTE: Elements are ordered for optimal cacheline behavior, and NOT
   *	 for functional grouping.
 @@ -151,6 +158,7 @@ struct fxp_softc {
  	struct resource	*fxp_res[2];	/* I/O and IRQ resources */
  	struct resource_spec *fxp_spec;	/* the resource spec we used */
  	void *ih;			/* interrupt handler cookie */
 +	struct fxp_ident *ident;
  	struct mtx sc_mtx;
  	bus_dma_tag_t fxp_txmtag;	/* bus DMA tag for Tx mbufs */
  	bus_dma_tag_t fxp_rxmtag;	/* bus DMA tag for Rx mbufs */
 _______________________________________________
 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: analyzed->patched 
State-Changed-By: yongari 
State-Changed-When: Sun Jun 21 08:00:08 UTC 2009 
State-Changed-Why:  
Patch committed to HEAD. Thanks for testing! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/135451: commit references a PR
Date: Wed,  4 Nov 2009 18:23:13 +0000 (UTC)

 Author: yongari
 Date: Wed Nov  4 18:22:59 2009
 New Revision: 198918
 URL: http://svn.freebsd.org/changeset/base/198918
 
 Log:
   MFC r194574:
     For ICH based fxp(4) controllers treat them as 82559 compatibles.
     To detect which controller is ICH based one, add a new member
     variable ich to struct fxp_ident and move the struct to
     if_fxpvar.h. Since I've faked controller revision, don't allow
     microcode loading for ICH based controllers.
     With this change all ICH based controllers will have WOL and Rx
     checksum offload capability.
   
     PR:		kern/135451
     Tested by:	Alexey Shuvaev ( shuvaev <> physik dot uni-wuerzburg dot de ),
   		pluknet ( pluknet <> gmail dot com ),
   		Gary Jennejohn ( gary.jennejohn <> freenet dot de )
 
 Modified:
   stable/7/sys/dev/fxp/if_fxp.c
   stable/7/sys/dev/fxp/if_fxpvar.h
 Directory Properties:
   stable/7/sys/   (props changed)
   stable/7/sys/contrib/pf/   (props changed)
 
 Modified: stable/7/sys/dev/fxp/if_fxp.c
 ==============================================================================
 --- stable/7/sys/dev/fxp/if_fxp.c	Wed Nov  4 18:20:31 2009	(r198917)
 +++ stable/7/sys/dev/fxp/if_fxp.c	Wed Nov  4 18:22:59 2009	(r198918)
 @@ -140,12 +140,6 @@ static u_char fxp_cb_config_template[] =
  	0x5	/* 21 */
  };
  
 -struct fxp_ident {
 -	uint16_t	devid;
 -	int16_t		revid;		/* -1 matches anything */
 -	char 		*name;
 -};
 -
  /*
   * Claim various Intel PCI device identifiers for this driver.  The
   * sub-vendor and sub-device field are extensively used to identify
 @@ -153,52 +147,52 @@ struct fxp_ident {
   * them.
   */
  static struct fxp_ident fxp_ident_table[] = {
 -    { 0x1029,	-1,	"Intel 82559 PCI/CardBus Pro/100" },
 -    { 0x1030,	-1,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1031,	-1,	"Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 -    { 0x1032,	-1,	"Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 -    { 0x1033,	-1,	"Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 -    { 0x1034,	-1,	"Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 -    { 0x1035,	-1,	"Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 -    { 0x1036,	-1,	"Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 -    { 0x1037,	-1,	"Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 -    { 0x1038,	-1,	"Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 -    { 0x1039,	-1,	"Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 -    { 0x103A,	-1,	"Intel 82801DB (ICH4) Pro/100 Ethernet" },
 -    { 0x103B,	-1,	"Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 -    { 0x103C,	-1,	"Intel 82801DB (ICH4) Pro/100 Ethernet" },
 -    { 0x103D,	-1,	"Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 -    { 0x103E,	-1,	"Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 -    { 0x1050,	-1,	"Intel 82801BA (D865) Pro/100 VE Ethernet" },
 -    { 0x1051,	-1,	"Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
 -    { 0x1059,	-1,	"Intel 82551QM Pro/100 M Mobile Connection" },
 -    { 0x1064,	-1,	"Intel 82562EZ (ICH6)" },
 -    { 0x1065,	-1,	"Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
 -    { 0x1068,	-1,	"Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
 -    { 0x1069,	-1,	"Intel 82562EM/EX/GX Pro/100 Ethernet" },
 -    { 0x1091,	-1,	"Intel 82562GX Pro/100 Ethernet" },
 -    { 0x1092,	-1,	"Intel Pro/100 VE Network Connection" },
 -    { 0x1093,	-1,	"Intel Pro/100 VM Network Connection" },
 -    { 0x1094,	-1,	"Intel Pro/100 946GZ (ICH7) Network Connection" },
 -    { 0x1209,	-1,	"Intel 82559ER Embedded 10/100 Ethernet" },
 -    { 0x1229,	0x01,	"Intel 82557 Pro/100 Ethernet" },
 -    { 0x1229,	0x02,	"Intel 82557 Pro/100 Ethernet" },
 -    { 0x1229,	0x03,	"Intel 82557 Pro/100 Ethernet" },
 -    { 0x1229,	0x04,	"Intel 82558 Pro/100 Ethernet" },
 -    { 0x1229,	0x05,	"Intel 82558 Pro/100 Ethernet" },
 -    { 0x1229,	0x06,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1229,	0x07,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1229,	0x08,	"Intel 82559 Pro/100 Ethernet" },
 -    { 0x1229,	0x09,	"Intel 82559ER Pro/100 Ethernet" },
 -    { 0x1229,	0x0c,	"Intel 82550 Pro/100 Ethernet" },
 -    { 0x1229,	0x0d,	"Intel 82550 Pro/100 Ethernet" },
 -    { 0x1229,	0x0e,	"Intel 82550 Pro/100 Ethernet" },
 -    { 0x1229,	0x0f,	"Intel 82551 Pro/100 Ethernet" },
 -    { 0x1229,	0x10,	"Intel 82551 Pro/100 Ethernet" },
 -    { 0x1229,	-1,	"Intel 82557/8/9 Pro/100 Ethernet" },
 -    { 0x2449,	-1,	"Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
 -    { 0x27dc,	-1,	"Intel 82801GB (ICH7) 10/100 Ethernet" },
 -    { 0,	-1,	NULL },
 +    { 0x1029,	-1,	0, "Intel 82559 PCI/CardBus Pro/100" },
 +    { 0x1030,	-1,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1031,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 +    { 0x1032,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VE Ethernet" },
 +    { 0x1033,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 +    { 0x1034,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 +    { 0x1035,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 +    { 0x1036,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 +    { 0x1037,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 Ethernet" },
 +    { 0x1038,	-1,	3, "Intel 82801CAM (ICH3) Pro/100 VM Ethernet" },
 +    { 0x1039,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 +    { 0x103A,	-1,	4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
 +    { 0x103B,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 +    { 0x103C,	-1,	4, "Intel 82801DB (ICH4) Pro/100 Ethernet" },
 +    { 0x103D,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VE Ethernet" },
 +    { 0x103E,	-1,	4, "Intel 82801DB (ICH4) Pro/100 VM Ethernet" },
 +    { 0x1050,	-1,	5, "Intel 82801BA (D865) Pro/100 VE Ethernet" },
 +    { 0x1051,	-1,	5, "Intel 82562ET (ICH5/ICH5R) Pro/100 VE Ethernet" },
 +    { 0x1059,	-1,	0, "Intel 82551QM Pro/100 M Mobile Connection" },
 +    { 0x1064,	-1,	6, "Intel 82562EZ (ICH6)" },
 +    { 0x1065,	-1,	6, "Intel 82562ET/EZ/GT/GZ PRO/100 VE Ethernet" },
 +    { 0x1068,	-1,	6, "Intel 82801FBM (ICH6-M) Pro/100 VE Ethernet" },
 +    { 0x1069,	-1,	6, "Intel 82562EM/EX/GX Pro/100 Ethernet" },
 +    { 0x1091,	-1,	7, "Intel 82562GX Pro/100 Ethernet" },
 +    { 0x1092,	-1,	7, "Intel Pro/100 VE Network Connection" },
 +    { 0x1093,	-1,	7, "Intel Pro/100 VM Network Connection" },
 +    { 0x1094,	-1,	7, "Intel Pro/100 946GZ (ICH7) Network Connection" },
 +    { 0x1209,	-1,	0, "Intel 82559ER Embedded 10/100 Ethernet" },
 +    { 0x1229,	0x01,	0, "Intel 82557 Pro/100 Ethernet" },
 +    { 0x1229,	0x02,	0, "Intel 82557 Pro/100 Ethernet" },
 +    { 0x1229,	0x03,	0, "Intel 82557 Pro/100 Ethernet" },
 +    { 0x1229,	0x04,	0, "Intel 82558 Pro/100 Ethernet" },
 +    { 0x1229,	0x05,	0, "Intel 82558 Pro/100 Ethernet" },
 +    { 0x1229,	0x06,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1229,	0x07,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1229,	0x08,	0, "Intel 82559 Pro/100 Ethernet" },
 +    { 0x1229,	0x09,	0, "Intel 82559ER Pro/100 Ethernet" },
 +    { 0x1229,	0x0c,	0, "Intel 82550 Pro/100 Ethernet" },
 +    { 0x1229,	0x0d,	0, "Intel 82550 Pro/100 Ethernet" },
 +    { 0x1229,	0x0e,	0, "Intel 82550 Pro/100 Ethernet" },
 +    { 0x1229,	0x0f,	0, "Intel 82551 Pro/100 Ethernet" },
 +    { 0x1229,	0x10,	0, "Intel 82551 Pro/100 Ethernet" },
 +    { 0x1229,	-1,	0, "Intel 82557/8/9 Pro/100 Ethernet" },
 +    { 0x2449,	-1,	2, "Intel 82801BA/CAM (ICH2/3) Pro/100 Ethernet" },
 +    { 0x27dc,	-1,	7, "Intel 82801GB (ICH7) 10/100 Ethernet" },
 +    { 0,	-1,	0, NULL },
  };
  
  #ifdef FXP_IP_CSUM_WAR
 @@ -214,6 +208,7 @@ static int		fxp_shutdown(device_t dev);
  static int		fxp_suspend(device_t dev);
  static int		fxp_resume(device_t dev);
  
 +static struct fxp_ident	*fxp_find_ident(device_t dev);
  static void		fxp_intr(void *xsc);
  static void		fxp_rxcsum(struct fxp_softc *sc, struct ifnet *ifp,
  			    struct mbuf *m, uint16_t status, int pos);
 @@ -361,11 +356,8 @@ fxp_dma_wait(struct fxp_softc *sc, volat
  		device_printf(sc->dev, "DMA timeout\n");
  }
  
 -/*
 - * Return identification string if this device is ours.
 - */
 -static int
 -fxp_probe(device_t dev)
 +static struct fxp_ident *
 +fxp_find_ident(device_t dev)
  {
  	uint16_t devid;
  	uint8_t revid;
 @@ -377,11 +369,26 @@ fxp_probe(device_t dev)
  		for (ident = fxp_ident_table; ident->name != NULL; ident++) {
  			if (ident->devid == devid &&
  			    (ident->revid == revid || ident->revid == -1)) {
 -				device_set_desc(dev, ident->name);
 -				return (BUS_PROBE_DEFAULT);
 +				return (ident);
  			}
  		}
  	}
 +	return (NULL);
 +}
 +
 +/*
 + * Return identification string if this device is ours.
 + */
 +static int
 +fxp_probe(device_t dev)
 +{
 +	struct fxp_ident *ident;
 +
 +	ident = fxp_find_ident(dev);
 +	if (ident != NULL) {
 +		device_set_desc(dev, ident->name);
 +		return (BUS_PROBE_DEFAULT);
 +	}
  	return (ENXIO);
  }
  
 @@ -484,11 +491,17 @@ fxp_attach(device_t dev)
  	/*
  	 * Find out the chip revision; lump all 82557 revs together.
  	 */
 -	fxp_read_eeprom(sc, &data, 5, 1);
 -	if ((data >> 8) == 1)
 -		sc->revision = FXP_REV_82557;
 -	else
 -		sc->revision = pci_get_revid(dev);
 +	sc->ident = fxp_find_ident(dev);
 +	if (sc->ident->ich > 0) {
 +		/* Assume ICH controllers are 82559. */
 +		sc->revision = FXP_REV_82559_A0;
 +	} else {
 +		fxp_read_eeprom(sc, &data, 5, 1);
 +		if ((data >> 8) == 1)
 +			sc->revision = FXP_REV_82557;
 +		else
 +			sc->revision = pci_get_revid(dev);
 +	}
  
  	/*
  	 * Check availability of WOL. 82559ER does not support WOL.
 @@ -561,9 +574,8 @@ fxp_attach(device_t dev)
  	 *
  	 * See Intel 82801BA/82801BAM Specification Update, Errata #30.
  	 */
 -	i = pci_get_device(dev);
 -	if (i == 0x2449 || (i > 0x1030 && i < 0x1039) ||
 -	    sc->revision >= FXP_REV_82559_A0) {
 +	if ((sc->ident->ich >= 2 && sc->ident->ich <= 3) ||
 +	    (sc->ident->ich == 0 && sc->revision >= FXP_REV_82559_A0)) {
  		fxp_read_eeprom(sc, &data, 10, 1);
  		if (data & 0x02) {			/* STB enable */
  			uint16_t cksum;
 @@ -2240,9 +2252,13 @@ fxp_init_body(struct fxp_softc *sc)
  
  	/*
  	 * Attempt to load microcode if requested.
 +	 * For ICH based controllers do not load microcode.
  	 */
 -	if (ifp->if_flags & IFF_LINK0 && (sc->flags & FXP_FLAG_UCODE) == 0)
 -		fxp_load_ucode(sc);
 +	if (sc->ident->ich == 0) {
 +		if (ifp->if_flags & IFF_LINK0 &&
 +		    (sc->flags & FXP_FLAG_UCODE) == 0)
 +			fxp_load_ucode(sc);
 +	}
  
  	/*
  	 * Set IFF_ALLMULTI status. It's needed in configure action
 
 Modified: stable/7/sys/dev/fxp/if_fxpvar.h
 ==============================================================================
 --- stable/7/sys/dev/fxp/if_fxpvar.h	Wed Nov  4 18:20:31 2009	(r198917)
 +++ stable/7/sys/dev/fxp/if_fxpvar.h	Wed Nov  4 18:22:59 2009	(r198918)
 @@ -142,6 +142,13 @@ struct fxp_desc_list {
  	bus_dma_tag_t rx_tag;
  };
  
 +struct fxp_ident {
 +	uint16_t	devid;
 +	int16_t		revid;		/* -1 matches anything */
 +	uint8_t		ich;
 +	char 		*name;
 +};
 +
  /*
   * NOTE: Elements are ordered for optimal cacheline behavior, and NOT
   *	 for functional grouping.
 @@ -151,6 +158,7 @@ struct fxp_softc {
  	struct resource	*fxp_res[2];	/* I/O and IRQ resources */
  	struct resource_spec *fxp_spec;	/* the resource spec we used */
  	void *ih;			/* interrupt handler cookie */
 +	struct fxp_ident *ident;
  	struct mtx sc_mtx;
  	bus_dma_tag_t fxp_txmtag;	/* bus DMA tag for Tx mbufs */
  	bus_dma_tag_t fxp_rxmtag;	/* bus DMA tag for Rx mbufs */
 _______________________________________________
 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 Nov 4 18:37:15 UTC 2009 
State-Changed-Why:  
MFC done. 

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