From owner-freebsd-net@FreeBSD.ORG Wed Oct 22 10:45:34 2014 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 850053E9 for ; Wed, 22 Oct 2014 10:45:34 +0000 (UTC) Received: from mail.ipfw.ru (mail.ipfw.ru [IPv6:2a01:4f8:120:6141::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 48E37D65 for ; Wed, 22 Oct 2014 10:45:34 +0000 (UTC) Received: from [2a02:6b8:0:401:222:4dff:fe50:cd2f] (helo=ptichko.yndx.net) by mail.ipfw.ru with esmtpsa (TLSv1:DHE-RSA-AES128-SHA:128) (Exim 4.82 (FreeBSD)) (envelope-from ) id 1XgpQ3-000KsT-GS; Wed, 22 Oct 2014 10:29:15 +0400 Message-ID: <54478A59.10804@FreeBSD.org> Date: Wed, 22 Oct 2014 14:43:37 +0400 From: "Alexander V. Chernikov" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.1.2 MIME-Version: 1.0 To: eric Joyner Subject: ixgbe ifmedia handling Content-Type: multipart/mixed; boundary="------------010003070702060804070603" Cc: "freebsd-net@freebsd.org" X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Oct 2014 10:45:34 -0000 This is a multi-part message in MIME format. --------------010003070702060804070603 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit There is a problem with correct media reporting in ixgbe: ixgbe_setup_optics() is called only at ixgbe_attach(). This means that: 1) if SFP slot was empty at the attach() time, "media" part will be set to adapter->optics = IFM_ETHER | IFM_AUTO; e.g. after attaching SFP status will look like media: Ethernet autoselect (autoselect ) status: active 2) If SFP slot was not empty, ifmedia will not be updated. The former case may trigger problems in other places inside kernel relying for ifmedia to be set correctly. For example, ifmedia_baudrate() will return 0 for given active interface (and this breaks best LACP aggregator selection making lagg interface attach impossible until module unload or reboot. Attached patch seems to work for 82599 NIC, but I'm pretty sure that it needs more checks. (And I wonder if we have the same problems with if_ixl). While investigating this case/performing tests I've noticed the following: * code inside ixgbe_local_timer() probing SFP seems to be dead /* Check for pluggable optics */ if (adapter->sfp_probe) was always false (due to failure to detect/set IXGBE_ERR_SFP_NOT_PRESENT status?) * ixgbe_handle_mod() was triggered in 1/4 of cases: e.g. if you detach SFP witin 2-3 seconds after attach it will not trigger. Even if detaching SFP which was inserted half an hour ago (and link was UP) this interrupt does not always trigger. --------------010003070702060804070603 Content-Type: text/x-patch; name="ixgbe_media.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ixgbe_media.diff" Index: ixgbe.c =================================================================== --- ixgbe.c (revision 273327) +++ ixgbe.c (working copy) @@ -5341,7 +5341,17 @@ struct ixgbe_hw *hw = &adapter->hw; u32 autoneg; bool negotiate; + int err; + err = hw->phy.ops.identify_sfp(hw); + if (err == IXGBE_ERR_SFP_NOT_PRESENT) { + device_printf(adapter->dev, + "SFP+ module was detached.\n"); + } else { + ixgbe_setup_optics(adapter); + INIT_DEBUGOUT1("ixgbe_sfp_probe: flags: %X\n", adapter->optics); + } + autoneg = hw->phy.autoneg_advertised; if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiate); --------------010003070702060804070603--