From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-f169.google.com (mail-wr0-f169.google.com [209.85.128.169]) by dpdk.org (Postfix) with ESMTP id 44FE02C6B for ; Wed, 12 Apr 2017 10:22:06 +0200 (CEST) Received: by mail-wr0-f169.google.com with SMTP id z109so12370332wrb.1 for ; Wed, 12 Apr 2017 01:22:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t8TilDWCS09OJwq9nUT/SCm75z/AutZ2eZLuxJrEG48=; b=zMgKNCFskRa/mW4sPCHXaHCFA5z8xwIECPcMD5Rs4YIo8YrybNDrv4B60eQLUAtwbu L04k2INVjzAmxJpxlrfh2vWk4pgrXXS+d/joVMB7yT58kYzWNv4tBMRkcOo2BUkl8nVv J6jDgWCBxCzELGmaFO+H60Z919FtGafG9zpMfUXU6Plazp61Sgv64Rl3bMMJhB1fYIi4 jiogzDl+CU1T3pmZ6tYxyBTu04v96FYomtEIBZ8jCm9X4dexDRyOaDjFZse4J6brEQSz 7fOKJJOwVdYp4Tpur9HosQ9S2rfVK+n/MC86J1qV5gm6VaDxiIquT1JePkVadfeEMgUj CkZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=t8TilDWCS09OJwq9nUT/SCm75z/AutZ2eZLuxJrEG48=; b=ZPVgEcbkFABHqCQbtwiOhusxqqxTJemX1xX1DUcpocjbyhVQmuL1pBcT5rq6494cDB JbQH157aluCPSEGV1UIGWU/s2rE/M0/utgxOi5eiareaVZEvfKC2xKZtAi2Hjf7LDS6h 05B3qQo8ZSCSsJRW63o95LuCMGIcWtYvyzn+nrNtpaDAaSHpnf4ssh3xilC43SSQbnLE MsbhDWOEzA8lBI3nsfuaHF26LDS3G1heMJa0abBkvfj+MXn9BqhIeOkhTXogKDUmxZUu WoGkkEbcTjoShs3S8kXu305B+ji2c8HwRCMamBEZQr5f/g2XC7tJu31anSIAb11E5B5A wyeQ== X-Gm-Message-State: AN3rC/74/1WBJGUxkrwmhTGeD9kjS9SIjHHhPmgOALBe/k367zvv2XMGPsv4c2VE7i9hXy0T X-Received: by 10.223.169.210 with SMTP id b76mr1844950wrd.197.1491985325958; Wed, 12 Apr 2017 01:22:05 -0700 (PDT) Received: from medusa.dev.6wind.com. (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id r52sm3343626wrb.37.2017.04.12.01.22.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Apr 2017 01:22:05 -0700 (PDT) From: Laurent Hardy To: dev@dpdk.org, ferruh.yigit@intel.com, wei.dai@intel.com, olivier.matz@6wind.com Cc: helin.zhang@intel.com, konstantin.ananyev@intel.com Date: Wed, 12 Apr 2017 10:21:47 +0200 Message-Id: <20170412082147.19182-1-laurent.hardy@6wind.com> X-Mailer: git-send-email 2.9.0.6.ge850ee8 In-Reply-To: <58ECC85D.4010403@6wind.com> References: <58ECC85D.4010403@6wind.com> Subject: [dpdk-dev] [PATCH] net/ixgbe: ensure link status is updated X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Apr 2017 08:22:06 -0000 In case of fiber and link speed set to 1Gb at peer side (with autoneg or with defined speed), link status could be not properly updated at time cable is plugged-in. Indeed if cable was not plugged when device has been configured and started then link status will not be updated properly with new speed as no link setup will be triggered. To avoid this issue, IXGBE_FLAG_NEED_LINK_CONFIG is set to try a link setup each time link_update() is triggered and current link status is down. When cable is plugged-in, link setup will be performed via ixgbe_setup_link(). Signed-off-by: Laurent Hardy --- v1 -> v2: - rebase on top of head (change flag to 1<<4) - fix regression with copper links: only update link for fiber links v2 -> v3: - remove unnescessary check on speed mask if autoneg is false --- drivers/net/ixgbe/ixgbe_ethdev.c | 18 ++++++++++++++++++ drivers/net/ixgbe/ixgbe_ethdev.h | 1 + 2 files changed, 19 insertions(+) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 1462324..bd03e60 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -3516,8 +3516,12 @@ 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_UNKNOWN; + struct ixgbe_interrupt *intr = + IXGBE_DEV_PRIVATE_TO_INTR(dev->data->dev_private); int link_up; int diag; + u32 speed = 0; + bool autoneg = false; link.link_status = ETH_LINK_DOWN; link.link_speed = 0; @@ -3527,6 +3531,18 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) hw->mac.get_link_status = true; + if ((intr->flags & IXGBE_FLAG_NEED_LINK_CONFIG) && + hw->mac.ops.get_media_type(hw) == ixgbe_media_type_fiber) { + speed = hw->phy.autoneg_advertised; + if (!speed) { + ixgbe_get_link_capabilities(hw, &speed, &autoneg); + /* setup the highest link when no autoneg */ + if (!autoneg) + speed = IXGBE_LINK_SPEED_10GB_FULL; + } + ixgbe_setup_link(hw, speed, true); + } + /* check if it needs to wait to complete, if lsc interrupt is enabled */ if (wait_to_complete == 0 || dev->data->dev_conf.intr_conf.lsc != 0) diag = ixgbe_check_link(hw, &link_speed, &link_up, 0); @@ -3544,10 +3560,12 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) if (link_up == 0) { rte_ixgbe_dev_atomic_write_link_status(dev, &link); + intr->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; if (link.link_status == old.link_status) return -1; return 0; } + intr->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; link.link_status = ETH_LINK_UP; link.link_duplex = ETH_LINK_FULL_DUPLEX; diff --git a/drivers/net/ixgbe/ixgbe_ethdev.h b/drivers/net/ixgbe/ixgbe_ethdev.h index a32ba4d..a6e8c8a 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.h +++ b/drivers/net/ixgbe/ixgbe_ethdev.h @@ -45,6 +45,7 @@ #define IXGBE_FLAG_MAILBOX (uint32_t)(1 << 1) #define IXGBE_FLAG_PHY_INTERRUPT (uint32_t)(1 << 2) #define IXGBE_FLAG_MACSEC (uint32_t)(1 << 3) +#define IXGBE_FLAG_NEED_LINK_CONFIG (uint32_t)(1 << 4) /* * Defines that were not part of ixgbe_type.h as they are not used by the -- 2.1.4