From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-qk0-f194.google.com (mail-qk0-f194.google.com [209.85.220.194]) by dpdk.org (Postfix) with ESMTP id C4B4F1B88A for ; Sat, 10 Feb 2018 00:14:18 +0100 (CET) Received: by mail-qk0-f194.google.com with SMTP id c185so4576855qkg.9 for ; Fri, 09 Feb 2018 15:14:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=i2YgOIdlsZEzGO9JEOsio93mkcjk9O1hajI2dsVk87c=; b=nFn4wRPajQuJEg7kRWRPeT9x29iLOoV96A8bN7w0PBwEqPEvf8T2jNZFIp5Roq6Rc0 n4U5dYRc5MHNzgMDJ1ecQ5Tove239Uea55RAot2RfDST6UIKE+VazGdUpgF8loXNvA4e bHi8xLD+FESys7kOkSLwq7CMjdXdZlwe09wvv+o+kt76jHhUA/LctyfnyHlb4D0lbtdr Gj64/ApgL8SIsnA0A4uJFgKn7SVzurGxSTQsoKcFborV0slYJN+QQXaf3WTqLB/tY3Ct IMraYgj1w5rtB5ZTalrJPMPyorgVf3iLlsWrMDriu+0FLEBKHl3ZM7Lz4AxHCRqTtjIn G5xg== 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; bh=i2YgOIdlsZEzGO9JEOsio93mkcjk9O1hajI2dsVk87c=; b=hmpjzSE/Mf/L/SnSR+oZ6XLkhs7ULYRurGGK9AlWHO6I3EEXpzsvgDhenj4xXprppN uwWrdRVbf0u6jRyr5Goqu8l1S9Hw+G6couPK036Ck2HA7V00UeeavEEoGIcOhHftoAep x1FSs+33Dj8A4yxWT+1i8eOcWeSSZx3+iD691wxCZk33X20CtVKpSo4KgWsEb2vrBMzQ cAu4EIvYNJIYfAHpAGZilJIKO9QU1OlSxaTjvUniUOQ6NMXfyEp8mO4vPkrq1k8TZdkV O3K6ZUZklt6D5czCxymlU8v8OkQRZXMWXNOmfmm6wuG+KQFtcHZUOzn/W0mWRL30M6CI INWQ== X-Gm-Message-State: APf1xPDCMl6Lp1j91QQZoJrMd63T3dUyoZZV1qcjpboQl2pvz5rRN877 zqgsxvl/YZ0DuIF1bpn6JCkvpg== X-Google-Smtp-Source: AH8x227qVIvCc1mjXDAepHrCWz7FlwabdzfZU6FKcTNJPFbGHTOQx+zqe1zEBrU90asKp+e3Dm2r5A== X-Received: by 10.55.73.140 with SMTP id w134mr6718398qka.215.1518218058010; Fri, 09 Feb 2018 15:14:18 -0800 (PST) Received: from monolith.home (pool-173-79-224-159.washdc.fios.verizon.net. [173.79.224.159]) by smtp.gmail.com with ESMTPSA id p90sm2192331qtd.58.2018.02.09.15.14.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 09 Feb 2018 15:14:17 -0800 (PST) From: Chas Williams <3chas3@gmail.com> To: stable@dpdk.org Cc: Liang-Min Larry Wang Date: Fri, 9 Feb 2018 18:14:12 -0500 Message-Id: <20180209231412.2081-1-3chas3@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [dpdk-stable] [PATCH][16.11] net/ixgbe: improve link state check on VF X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Feb 2018 23:14:19 -0000 From: Liang-Min Larry Wang [ backported from upstream commit dc66e5fd01b9565b392833167c792cc6df9bc64c ] In current implementation, when checking VF link state, PF state is checked too, although the function has a parameter to tell if PF state checking is needed. But in some scenario, user may not care about the PF state. This patch enables the unused parameter to only check the VF link state. Signed-off-by: Liang-Min Larry Wang Acked-by: Wenzhuo Lu --- drivers/net/ixgbe/ixgbe_ethdev.c | 133 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 129 insertions(+), 4 deletions(-) diff --git a/drivers/net/ixgbe/ixgbe_ethdev.c b/drivers/net/ixgbe/ixgbe_ethdev.c index 80ee5f0..2dc69ff 100644 --- a/drivers/net/ixgbe/ixgbe_ethdev.c +++ b/drivers/net/ixgbe/ixgbe_ethdev.c @@ -252,6 +252,8 @@ static int eth_ixgbevf_dev_init(struct rte_eth_dev *eth_dev); static int eth_ixgbevf_dev_uninit(struct rte_eth_dev *eth_dev); static int ixgbevf_dev_configure(struct rte_eth_dev *dev); static int ixgbevf_dev_start(struct rte_eth_dev *dev); +static int ixgbevf_dev_link_update(struct rte_eth_dev *dev, + int wait_to_complete); static void ixgbevf_dev_stop(struct rte_eth_dev *dev); static void ixgbevf_dev_close(struct rte_eth_dev *dev); static void ixgbevf_intr_disable(struct ixgbe_hw *hw); @@ -622,7 +624,7 @@ static const struct eth_dev_ops ixgbevf_eth_dev_ops = { .dev_configure = ixgbevf_dev_configure, .dev_start = ixgbevf_dev_start, .dev_stop = ixgbevf_dev_stop, - .link_update = ixgbe_dev_link_update, + .link_update = ixgbevf_dev_link_update, .stats_get = ixgbevf_dev_stats_get, .xstats_get = ixgbevf_dev_xstats_get, .stats_reset = ixgbevf_dev_stats_reset, @@ -3219,15 +3221,123 @@ ixgbevf_dev_info_get(struct rte_eth_dev *dev, dev_info->tx_desc_lim = tx_desc_lim; } +static int +ixgbevf_check_link(struct ixgbe_hw *hw, ixgbe_link_speed *speed, + int *link_up, int wait_to_complete) +{ + /** + * for a quick link status checking, wait_to_compelet == 0, + * skip PF link status checking + */ + bool no_pflink_check = wait_to_complete == 0; + struct ixgbe_mbx_info *mbx = &hw->mbx; + struct ixgbe_mac_info *mac = &hw->mac; + uint32_t links_reg, in_msg; + int ret_val = 0; + + /* If we were hit with a reset drop the link */ + if (!mbx->ops.check_for_rst(hw, 0) || !mbx->timeout) + mac->get_link_status = true; + + if (!mac->get_link_status) + goto out; + + /* if link status is down no point in checking to see if pf is up */ + links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); + if (!(links_reg & IXGBE_LINKS_UP)) + goto out; + + /* for SFP+ modules and DA cables on 82599 it can take up to 500usecs + * before the link status is correct + */ + if (mac->type == ixgbe_mac_82599_vf) { + int i; + + for (i = 0; i < 5; i++) { + rte_delay_us(100); + links_reg = IXGBE_READ_REG(hw, IXGBE_VFLINKS); + + if (!(links_reg & IXGBE_LINKS_UP)) + goto out; + } + } + + switch (links_reg & IXGBE_LINKS_SPEED_82599) { + case IXGBE_LINKS_SPEED_10G_82599: + *speed = IXGBE_LINK_SPEED_10GB_FULL; + if (hw->mac.type >= ixgbe_mac_X550) { + if (links_reg & IXGBE_LINKS_SPEED_NON_STD) + *speed = IXGBE_LINK_SPEED_2_5GB_FULL; + } + break; + case IXGBE_LINKS_SPEED_1G_82599: + *speed = IXGBE_LINK_SPEED_1GB_FULL; + break; + case IXGBE_LINKS_SPEED_100_82599: + *speed = IXGBE_LINK_SPEED_100_FULL; + if (hw->mac.type == ixgbe_mac_X550) { + if (links_reg & IXGBE_LINKS_SPEED_NON_STD) + *speed = IXGBE_LINK_SPEED_5GB_FULL; + } + break; + case IXGBE_LINKS_SPEED_10_X550EM_A: + *speed = IXGBE_LINK_SPEED_UNKNOWN; + /* Since Reserved in older MAC's */ + if (hw->mac.type >= ixgbe_mac_X550) + *speed = IXGBE_LINK_SPEED_10_FULL; + break; + default: + *speed = IXGBE_LINK_SPEED_UNKNOWN; + } + + if (no_pflink_check) { + if (*speed == IXGBE_LINK_SPEED_UNKNOWN) + mac->get_link_status = true; + else + mac->get_link_status = false; + + goto out; + } + /* if the read failed it could just be a mailbox collision, best wait + * until we are called again and don't report an error + */ + if (mbx->ops.read(hw, &in_msg, 1, 0)) + goto out; + + if (!(in_msg & IXGBE_VT_MSGTYPE_CTS)) { + /* msg is not CTS and is NACK we must have lost CTS status */ + if (in_msg & IXGBE_VT_MSGTYPE_NACK) + ret_val = -1; + goto out; + } + + /* the pf is talking, if we timed out in the past we reinit */ + if (!mbx->timeout) { + ret_val = -1; + goto out; + } + + /* if we passed all the tests above then the link is up and we no + * longer need to check for link + */ + mac->get_link_status = false; + +out: + *link_up = !mac->get_link_status; + return ret_val; +} + /* return 0 means link status changed, -1 means not changed */ static int -ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) +ixgbe_dev_link_update_share(struct rte_eth_dev *dev, + int wait_to_complete, int vf) { 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; int link_up; int diag; + int wait = 1; link.link_status = ETH_LINK_DOWN; link.link_speed = 0; @@ -3240,9 +3350,12 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) /* 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); + wait = 0; + + if (vf) + diag = ixgbevf_check_link(hw, &link_speed, &link_up, wait); else - diag = ixgbe_check_link(hw, &link_speed, &link_up, 1); + diag = ixgbe_check_link(hw, &link_speed, &link_up, wait); if (diag != 0) { link.link_speed = ETH_SPEED_NUM_100M; @@ -3289,6 +3402,18 @@ ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) return 0; } +static int +ixgbe_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) +{ + return ixgbe_dev_link_update_share(dev, wait_to_complete, 0); +} + +static int +ixgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete) +{ + return ixgbe_dev_link_update_share(dev, wait_to_complete, 1); +} + static void ixgbe_dev_promiscuous_enable(struct rte_eth_dev *dev) { -- 2.9.5