From owner-svn-src-head@freebsd.org Thu Aug 24 22:56:23 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 693B0DE9BB6; Thu, 24 Aug 2017 22:56:23 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 3D4D26966A; Thu, 24 Aug 2017 22:56:23 +0000 (UTC) (envelope-from erj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7OMuMBM030693; Thu, 24 Aug 2017 22:56:22 GMT (envelope-from erj@FreeBSD.org) Received: (from erj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7OMuMGX030692; Thu, 24 Aug 2017 22:56:22 GMT (envelope-from erj@FreeBSD.org) Message-Id: <201708242256.v7OMuMGX030692@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: erj set sender to erj@FreeBSD.org using -f From: Eric Joyner Date: Thu, 24 Aug 2017 22:56:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r322865 - head/sys/dev/ixgbe X-SVN-Group: head X-SVN-Commit-Author: erj X-SVN-Commit-Paths: head/sys/dev/ixgbe X-SVN-Commit-Revision: 322865 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Aug 2017 22:56:23 -0000 Author: erj Date: Thu Aug 24 22:56:22 2017 New Revision: 322865 URL: https://svnweb.freebsd.org/changeset/base/322865 Log: ixv(4): Add more robust mailbox API negotiation The previous update to the driver to 3.2.12-k changed the VF's API version to 1.2, but did not let the VF fall back to 1.1 or 1.0 versions. So, this patch tries 1.2 first, then the older versions in succession if that fails. This should allow the VF driver to negotiate 1.1 and work with older PF drivers, such as the one used in Amazon's EC2 service. PR: 220872 Submitted by: Jeb Cramer MFC after: 1 week Sponsored by: Intel Corporation Modified: head/sys/dev/ixgbe/if_ixv.c Modified: head/sys/dev/ixgbe/if_ixv.c ============================================================================== --- head/sys/dev/ixgbe/if_ixv.c Thu Aug 24 22:33:42 2017 (r322864) +++ head/sys/dev/ixgbe/if_ixv.c Thu Aug 24 22:56:22 2017 (r322865) @@ -93,6 +93,7 @@ static int ixv_configure_interrupts(struct adapte static void ixv_free_pci_resources(struct adapter *); static void ixv_local_timer(void *); static void ixv_setup_interface(device_t, struct adapter *); +static int ixv_negotiate_api(struct adapter *); static void ixv_initialize_transmit_units(struct adapter *); static void ixv_initialize_receive_units(struct adapter *); @@ -384,11 +385,10 @@ ixv_attach(device_t dev) } /* Negotiate mailbox API version */ - error = ixgbevf_negotiate_api_version(hw, ixgbe_mbox_api_12); + error = ixv_negotiate_api(adapter); if (error) { - device_printf(dev, "MBX API 1.2 negotiation failed! Error %d\n", - error); - error = EIO; + device_printf(dev, + "Mailbox API negotiation failed during attach!\n"); goto err_out; } @@ -584,10 +584,12 @@ ixv_init_locked(struct adapter *adapter) /* Reset VF and renegotiate mailbox API version */ hw->mac.ops.reset_hw(hw); - error = ixgbevf_negotiate_api_version(hw, ixgbe_mbox_api_12); - if (error) - device_printf(dev, "MBX API 1.2 negotiation failed! Error %d\n", - error); + error = ixv_negotiate_api(adapter); + if (error) { + device_printf(dev, + "Mailbox API negotiation failed in init_locked!\n"); + return; + } ixv_initialize_transmit_units(adapter); @@ -873,6 +875,31 @@ ixv_media_change(struct ifnet *ifp) return (0); } /* ixv_media_change */ + + +/************************************************************************ + * ixv_negotiate_api + * + * Negotiate the Mailbox API with the PF; + * start with the most featured API first. + ************************************************************************/ +static int +ixv_negotiate_api(struct adapter *adapter) +{ + struct ixgbe_hw *hw = &adapter->hw; + int mbx_api[] = { ixgbe_mbox_api_11, + ixgbe_mbox_api_10, + ixgbe_mbox_api_unknown }; + int i = 0; + + while (mbx_api[i] != ixgbe_mbox_api_unknown) { + if (ixgbevf_negotiate_api_version(hw, mbx_api[i]) == 0) + return (0); + i++; + } + + return (EINVAL); +} /* ixv_negotiate_api */ /************************************************************************