From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 37FC218F for ; Thu, 18 Dec 2014 19:04:24 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 18 Dec 2014 09:54:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,691,1406617200"; d="scan'208";a="501066275" Received: from bnemeth-mobl.ger.corp.intel.com (HELO bn-ivy12.localdomain) ([172.22.195.65]) by orsmga003.jf.intel.com with ESMTP; 18 Dec 2014 09:50:13 -0800 From: Balazs Nemeth To: dev@dpdk.org Date: Thu, 18 Dec 2014 17:56:36 +0000 Message-Id: <1418925396-14206-1-git-send-email-balazs.nemeth@intel.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1418822554-1493-1-git-send-email-balazs.nemeth@intel.com> References: <1418822554-1493-1-git-send-email-balazs.nemeth@intel.com> Cc: Balazs Nemeth Subject: [dpdk-dev] [PATCH v2] ixgbe_vf: Fix getting link state X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Dec 2014 18:04:24 -0000 This patch fixes checking the link state of a virtual function. If the state has already been checked, it does not need to be checked again. Previously, get_link_status in the ixgbe_hw struct was used to track if the information had already been retrieved, but this field was always set to false (signifying that the information was up-to-date). The problem was introduced by commit 8ef32003 which was part of a patch set to update the ixgbe portion of the PMD. This patch does not break consistency with the ixgbevf driver. Instead, it fixes the problem at the level of DPDK. Applications that rely on the reported link speed could fail without this patch. The qos_sched example application provided with DPDK did not run when virtual functions were used. The output for this example application is shown below: EAL: Error - exiting with code: 1 Cause: Unable to config sched subport 0, err=-2 The problem and the effect of the patch can been seen by running the l2fwd example application using the following command: sudo ./build/l2fwd -c 0x3 -n 4 -- -p 0x3 -T 0 Before the patch has been applied (with both links up): ... Checking link statusdone Port 0 Link Up - speed 100 Mbps - half-duplex Port 1 Link Up - speed 100 Mbps - half-duplex L2FWD: entering main loop on lcore 1 ... After the patch has been applied (with both links up): ... Checking link statusdone Port 0 Link Up - speed 10000 Mbps - full-duplex Port 1 Link Up - speed 10000 Mbps - full-duplex L2FWD: entering main loop on lcore 1 ... Before the patch has been applied (with link 0 down, link 1 up): ... Checking link statusdone Port 0 Link Up - speed 100 Mbps - half-duplex Port 1 Link Up - speed 100 Mbps - half-duplex L2FWD: entering main loop on lcore 1 ... After the patch has been applied (with link 0 down, link 1 up): ... Checking link status............................................................ ..............................done Port 0 Link Down Port 1 Link Up - speed 10000 Mbps - full-duplex ... Signed-off-by: Balazs Nemeth --- changes v2: * Include more elaborate explanation of the problem in the commit message * Fix the issue at the level of DPDK not touching ixgbe driver code lib/librte_pmd_ixgbe/ixgbe_ethdev.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c index 9401916..22227e6 100644 --- a/lib/librte_pmd_ixgbe/ixgbe_ethdev.c +++ b/lib/librte_pmd_ixgbe/ixgbe_ethdev.c @@ -1469,6 +1469,7 @@ ixgbe_dev_start(struct rte_eth_dev *dev) if (status != 0) return -1; hw->mac.ops.start_hw(hw); + hw->mac.get_link_status = true; /* configure PF module if SRIOV enabled */ ixgbe_pf_host_configure(dev); @@ -2064,7 +2065,7 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) { struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(dev->data->dev_private); struct rte_eth_link link, old; - ixgbe_link_speed link_speed; + ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; int link_up; int diag; @@ -2088,6 +2089,12 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) return 0; } + if (link_speed == IXGBE_LINK_SPEED_UNKNOWN && + !hw->mac.get_link_status) { + memcpy(&link, &old, sizeof(link)); + return -1; + } + if (link_up == 0) { rte_ixgbe_dev_atomic_write_link_status(dev, &link); if (link.link_status == old.link_status) @@ -2926,6 +2933,7 @@ ixgbevf_dev_start(struct rte_eth_dev *dev) PMD_INIT_FUNC_TRACE(); hw->mac.ops.reset_hw(hw); + hw->mac.get_link_status = true; /* negotiate mailbox API version to use with the PF. */ ixgbevf_negotiate_api(hw); -- 2.1.3