From nobody@FreeBSD.org  Fri Sep  3 15:14:06 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 78A441065708
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  3 Sep 2010 15:14:06 +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 4D7968FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  3 Sep 2010 15:14:06 +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 o83FE6cj054553
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 3 Sep 2010 15:14:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o83FE5Dn054552;
	Fri, 3 Sep 2010 15:14:05 GMT
	(envelope-from nobody)
Message-Id: <201009031514.o83FE5Dn054552@www.freebsd.org>
Date: Fri, 3 Sep 2010 15:14:05 GMT
From: Andrew Boyer <aboyer@averesystems.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [ixgbe] Media type detection broken
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         150249
>Category:       kern
>Synopsis:       [ixgbe] Media type detection broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-net
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 03 15:20:03 UTC 2010
>Closed-Date:    
>Last-Modified:  Mon Sep 06 06:57:53 UTC 2010
>Originator:     Andrew Boyer
>Release:        7.1p3
>Organization:
Avere Systems
>Environment:
N/A
>Description:
Intel 82599 adapter cards can use either copper or optical modules.  Currently, no matter which type of connection is used, ifconfig will report a media type of 10Gbase-SR.

Several changes are required to fix this.

1) In ixgbe_attach(), pci_device_id IXGBE_DEV_ID_82599_SFP causes adapter->optics to be set to IFM_10G_SR.  This is incorrect.  The "optics" type can not be set until the media is actually detected.  (2) In our tree I added a switch statement at the end of ixgbe_handle_mod() to set the optics value based on the return value of hw->mac.ops.get_media_type().

That led me to discover that functions ixgbe_get_media_type_82598() and ixgbe_get_media_type_82599() have flaws:
3) In ixgbe_get_media_type_82598(), device_id IXGBE_DEV_ID_82598_DA_DUAL_PORT returns ixgbe_media_type_fiber, even though the DA card supports only copper.
4) In both, the initial test to detect if there is a copper PHY attached leaves out some possible values for copper PHYs:
    	ixgbe_phy_sfp_passive_tyco
	ixgbe_phy_sfp_passive_unknown
	ixgbe_phy_sfp_active_unknown

5) Once you fix this so that ixgbe_get_media_type_*() returns the correct value, you'll notice that ixgbe_identify_sfp_module_generic() stops working for copper cables.  This is because it tests for (mac.ops.get_media_type() != ixgbe_media_type_fiber) and returns an error.  In our internal tree I have commented out this check completely; the ID routine will fail gracefully if there isn't an SFP present, at least on all of our card types.

>How-To-Repeat:
Install an 82599 card and SFP+ copper cables.  Run 'ifconfig' and observe that the media type is listed as (10Gbase-SR <full-duplex>).
>Fix:
See suggestions in the Full Description.  I could put together a patch if it would help get this fixed in the tree, although a lot of it is in Intel common code (ixgbe_82598.c, ixgbe_82599.c, ixgbe_phy.c).

>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-net 
Responsible-Changed-By: vwe 
Responsible-Changed-When: Fri Sep 3 18:57:36 UTC 2010 
Responsible-Changed-Why:  

Over to maintainer(s). 

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