From nobody@FreeBSD.org  Tue May 10 18:28:59 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 00554106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 May 2011 18:28:59 +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 E4B3D8FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 May 2011 18:28:58 +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 p4AISv3e052728
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 10 May 2011 18:28:57 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p4AISvMD052727;
	Tue, 10 May 2011 18:28:57 GMT
	(envelope-from nobody)
Message-Id: <201105101828.p4AISvMD052727@red.freebsd.org>
Date: Tue, 10 May 2011 18:28:57 GMT
From: Ratko Gospodnetic <ratko@open.hr>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Atheros AR8132 connectivity problem to Gigabit switch
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         156935
>Category:       kern
>Synopsis:       [alc] Atheros AR8132 connectivity problem to Gigabit switch
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    yongari
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue May 10 18:30:09 UTC 2011
>Closed-Date:    Thu May 19 17:37:53 UTC 2011
>Last-Modified:  Thu May 19 17:37:53 UTC 2011
>Originator:     Ratko Gospodnetic
>Release:        8.0
>Organization:
ZI5 d.o.o. Zagreb Croatia
>Environment:
FreeBSD freenas.local 8.2-RELEASE-p1 FreeBSD 8.2-RELEASE-p1 #4: Sat Apr 30 10:39:46 PDT 2011     jpaetzel@servant.iXsystems.com:/usr/home/jpaetzel/freenas/obj.amd64/usr/home/jpaetzel/freenas/FreeBSD/src/sys/FREENAS.amd64  amd64
>Description:
When FreeNAS PC Atheros AR8132 NIC is connected to Planet 24 port Gigabit Internet switch (10/100/1000), FreeNAS could not be pinged and FreeNAS cannot see other computers on the same network.
pciconf -lv | grep -B3 network confirms that Atheros Network Card is recognized.

When same FreeNAS computer is connected to 8 port 10/100 Internet switch which is further connected to above mentioned Planet Gigabit switch everything works fine. FreeNAS can be pinged from other computers and managed through GUI interface.

When same PC is booted with Windows XP Pro and connected to Planet 24 port Gigabit Internet switch (10/100/1000) exactly like FreeNAS, everything works OK! PC could see other computers on LAN and could be pinged and accessed from other computers in the network.

>How-To-Repeat:
Always repeatable in the same environment.
>Fix:
Please see attached file: _ReadMe_02.03.txt

Patch attached with submission follows:

2011-05-10
_ReadMe_02.03.txt

************************************************************************************
TEMPORARY MANUAL SOLUTION FOR ATHEROS AR8132 PROBLEM ON FreeNAS v8.0
************************************************************************************

------------------------------------------------------------------------------------
Problem with FreeNAS Atheros AR8132 NIC PC when connected to 10/100/1000 Mbps switch.
PC and NIC are not recognised on LAN
Reason for problem is that (probably) "media autoselect" feature in AR8132 driver 
is notworking according to specification and switch does not recognize NIC.

With command mode change in NIC interface config from
	"media autoselect"
	to
	"media 100baseTX"
NIC is recognized and computer can communicate on LAN.

This is just temporary solution and it will not survive next boot!
For permanent solution:
	* comands must be added to boot stream so update for NIC config is automatic
	or
	* FreeBSD/FreeNAS OS driver for Atheros AR8132 should be updated
	or
	after connection is established with shell commmands correction Windows GUI
	should be used and option field for NIC set to "media 100baseTX" and
	corrections will stay after next boot but not survive next installation :))
------------------------------------------------------------------------------------
Atheros AR8132 Network interface card supports only 10/100 Mbps connections.
Complete list of supported options could be isted with "ifconfig -m alc0"
	supported media:
		media autoselect mediaopt flowcontrol
		media autoselect
		media 100baseTX mediaopt full-duplex,flowcontrol
		media 100baseTX mediaopt full-duplex
		media 100baseTX
		media 10baseT/UTP mediaopt full-duplex,flowcontrol
		media 10baseT/UTP mediaopt full-duplex
		media 10baseT/UTP
		media noned with ifconfig -m alc0
------------------------------------------------------------------------------------

	0.	Boot FreeNAS v8.0
	1.	Connect PC with Atheros AR8132 NIC to Gigabit switch
	2.	LAN/switch connection is not active
		From Console Setup menu choose:
		7) Shell
	3.	Check NIC status with command where "alc0" is device name
			ifconfig -m alc0
			or for simplicity
			ifconfig -m
		Result of "ifconfig" command reports details about NIC status and configuration
	4.	Set NIC config atribute for media to 100baseTx, where "alc0" is device name
			ifconfig alc0 media 100baseTX 
	5.	Put NIC down
			ifconfig alc0 down
	6.	Put NIC Up and NIC interface is reset automaticaly
			ifconfig alc0 up
	7.	Check status with:
			ifconfig -m alc0
	8.	LED indicators on 10/100/1000 switch should confirm that NIS is connected and
		working in 100baseTX mode
	9.	LAN connection is active
	10.	Activate any Internet Browser on Windows PC connected to same LAN
	11.	Activate FreeNAS GUI by entering computer name (eg. freenas) or IP address (eg 192.168.1.100) into address field
	12.	Enter admin logon data (eg admin/freenas)
	13.	Open from main menu item "Interfaces"
	14.	From "Interfaces" submenu choose "View All Interfaces"
	15.	Click on Edit button for Atheros driven device with conectivity problem
	16.	Type "media 100baseTX" (without ") into "Options" field and click on "OK" button
	17.	NIC will be reconfigured and setup remembered
	18.	This change will survive boot but not next FreeNAS reinstall :)
------------------------------------------------------------------------------------
List of commands that should be executed for temporary correction:
ifconfig -m alc0
ifconfig alc0 media 100baseTX
ifconfig alc0 down
ifconfig alc0 up
ifconfig -m alc0
------------------------------------------------------------------------------------

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-wireless 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Tue May 10 19:30:45 UTC 2011 
Responsible-Changed-Why:  
reclassify. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156935 
Responsible-Changed-From-To: freebsd-wireless->yongari 
Responsible-Changed-By: yongari 
Responsible-Changed-When: Tue May 10 22:16:56 UTC 2011 
Responsible-Changed-Why:  
Grab. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=156935 
State-Changed-From-To: open->feedback 
State-Changed-By: yongari 
State-Changed-When: Tue May 10 22:28:25 UTC 2011 
State-Changed-Why:  
Could you try the patch at the following URL? The patch was 
generated against stable/8 and it would be applied to FreeNAS 8. 
http://people.freebsd.org/~yongari/alc/atphy.stable8.diff 

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

From: Warren Block <wblock@wonkity.com>
To: bug-followup@FreeBSD.org, ratko@open.hr
Cc:  
Subject: Re: kern/156935: [alc] Atheros AR8132 connectivity problem to Gigabit
 switch
Date: Wed, 11 May 2011 18:09:35 -0600 (MDT)

 Tested on an Acer Aspire One D250 running 8-stable.  Patch tested and 
 working with autoselect on both 10/100 and gigabit switches and with 
 cable disconnected and reconnected.

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/156935: commit references a PR
Date: Thu, 12 May 2011 17:11:41 +0000 (UTC)

 Author: yongari
 Date: Thu May 12 17:11:31 2011
 New Revision: 221817
 URL: http://svn.freebsd.org/changeset/base/221817
 
 Log:
   Explicitly clear 1000baseT control register for F1 PHY used in
   AR8132 FastEthernet controller. The PHY has no ability to
   establish a gigabit link. Previously only link parters which
   support down-shifting was able to establish link.
   This change should fix a long standing link establishment issue of
   AR8132.
   
   PR:		kern/156935
   MFC after:	1 week
 
 Modified:
   head/sys/dev/mii/atphy.c
 
 Modified: head/sys/dev/mii/atphy.c
 ==============================================================================
 --- head/sys/dev/mii/atphy.c	Thu May 12 17:02:56 2011	(r221816)
 +++ head/sys/dev/mii/atphy.c	Thu May 12 17:11:31 2011	(r221817)
 @@ -359,6 +359,18 @@ atphy_setmedia(struct mii_softc *sc, int
  	     (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
  		PHY_WRITE(sc, MII_100T2CR, GTCR_ADV_1000TFDX |
  		    GTCR_ADV_1000THDX);
 +	else if (sc->mii_mpd_model == MII_MODEL_xxATHEROS_F1) {
 +		/*
 +		 * AR8132 has 10/100 PHY and the PHY uses the same
 +		 * model number of F1 gigabit PHY.  The PHY has no
 +		 * ability to establish gigabit link so explicitly
 +		 * disable 1000baseT configuration for the PHY.
 +		 * Otherwise, there is a case that atphy(4) could
 +		 * not establish a link against gigabit link partner
 +		 * unless the link partner supports down-shifting.
 +		 */
 +		PHY_WRITE(sc, MII_100T2CR, 0);
 +	}
  	PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG);
  
  	return (EJUSTRETURN);
 _______________________________________________
 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: Thu May 12 19:58:52 UTC 2011 
State-Changed-Why:  
Patch committed to HEAD(r221817). 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: kern/156935: commit references a PR
Date: Thu, 19 May 2011 17:18:22 +0000 (UTC)

 Author: yongari
 Date: Thu May 19 17:18:13 2011
 New Revision: 222098
 URL: http://svn.freebsd.org/changeset/base/222098
 
 Log:
   MFC r221817:
     Explicitly clear 1000baseT control register for F1 PHY used in
     AR8132 FastEthernet controller. The PHY has no ability to
     establish a gigabit link. Previously only link parters which
     support down-shifting was able to establish link.
     This change should fix a long standing link establishment issue of
     AR8132.
   
     PR:	kern/156935
 
 Modified:
   stable/8/sys/dev/mii/atphy.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/mii/atphy.c
 ==============================================================================
 --- stable/8/sys/dev/mii/atphy.c	Thu May 19 15:18:35 2011	(r222097)
 +++ stable/8/sys/dev/mii/atphy.c	Thu May 19 17:18:13 2011	(r222098)
 @@ -384,6 +384,7 @@ atphy_anar(struct ifmedia_entry *ife)
  static int
  atphy_setmedia(struct mii_softc *sc, int media)
  {
 +	struct atphy_softc *asc;
  	uint16_t anar;
  
  	anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
 @@ -396,6 +397,20 @@ atphy_setmedia(struct mii_softc *sc, int
  	     (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
  		PHY_WRITE(sc, MII_100T2CR, GTCR_ADV_1000TFDX |
  		    GTCR_ADV_1000THDX);
 +	else {
 +		/*
 +		 * AR8132 has 10/100 PHY and the PHY uses the same
 +		 * model number of F1 gigabit PHY.  The PHY has no
 +		 * ability to establish gigabit link so explicitly
 +		 * disable 1000baseT configuration for the PHY.
 +		 * Otherwise, there is a case that atphy(4) could
 +		 * not establish a link against gigabit link partner
 +		 * unless the link partner supports down-shifting.
 +		 */
 +		asc = (struct atphy_softc *)sc;
 +		if (asc->mii_model == MII_MODEL_ATHEROS_F1)
 +			PHY_WRITE(sc, MII_100T2CR, 0);
 +	}
  	PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG);
  
  	return (EJUSTRETURN);
 _______________________________________________
 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/156935: commit references a PR
Date: Thu, 19 May 2011 17:20:28 +0000 (UTC)

 Author: yongari
 Date: Thu May 19 17:20:13 2011
 New Revision: 222099
 URL: http://svn.freebsd.org/changeset/base/222099
 
 Log:
   MFC r221817:
     Explicitly clear 1000baseT control register for F1 PHY used in
     AR8132 FastEthernet controller. The PHY has no ability to
     establish a gigabit link. Previously only link parters which
     support down-shifting was able to establish link.
     This change should fix a long standing link establishment issue of
     AR8132.
   
     PR:	kern/156935
 
 Modified:
   stable/7/sys/dev/mii/atphy.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/mii/atphy.c
 ==============================================================================
 --- stable/7/sys/dev/mii/atphy.c	Thu May 19 17:18:13 2011	(r222098)
 +++ stable/7/sys/dev/mii/atphy.c	Thu May 19 17:20:13 2011	(r222099)
 @@ -384,6 +384,7 @@ atphy_anar(struct ifmedia_entry *ife)
  static int
  atphy_setmedia(struct mii_softc *sc, int media)
  {
 +	struct atphy_softc *asc;
  	uint16_t anar;
  
  	anar = BMSR_MEDIA_TO_ANAR(sc->mii_capabilities) | ANAR_CSMA;
 @@ -396,6 +397,20 @@ atphy_setmedia(struct mii_softc *sc, int
  	     (EXTSR_1000TFDX | EXTSR_1000THDX)) != 0)
  		PHY_WRITE(sc, MII_100T2CR, GTCR_ADV_1000TFDX |
  		    GTCR_ADV_1000THDX);
 +	else {
 +		/*
 +		 * AR8132 has 10/100 PHY and the PHY uses the same
 +		 * model number of F1 gigabit PHY.  The PHY has no
 +		 * ability to establish gigabit link so explicitly
 +		 * disable 1000baseT configuration for the PHY.
 +		 * Otherwise, there is a case that atphy(4) could
 +		 * not establish a link against gigabit link partner
 +		 * unless the link partner supports down-shifting.
 +		 */
 +		asc = (struct atphy_softc *)sc;
 +		if (asc->mii_model == MII_MODEL_ATHEROS_F1)
 +			PHY_WRITE(sc, MII_100T2CR, 0);
 +	}
  	PHY_WRITE(sc, MII_BMCR, BMCR_RESET | BMCR_AUTOEN | BMCR_STARTNEG);
  
  	return (EJUSTRETURN);
 _______________________________________________
 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: Thu May 19 17:37:13 UTC 2011 
State-Changed-Why:  
MFC to both stable/8 and stable/7 complete. 
Thanks for reporting! 

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