From patchwork Wed Nov 29 14:53:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Kulasek X-Patchwork-Id: 31754 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A439C3195; Wed, 29 Nov 2017 15:55:50 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 096832C55 for ; Wed, 29 Nov 2017 15:55:48 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Nov 2017 06:55:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,473,1505804400"; d="scan'208";a="8463411" Received: from unknown (HELO Sent) ([10.103.102.173]) by fmsmga001.fm.intel.com with SMTP; 29 Nov 2017 06:55:45 -0800 Received: by Sent (sSMTP sendmail emulation); Wed, 29 Nov 2017 15:53:59 +0100 From: Tomasz Kulasek To: dev@dpdk.org Cc: declan.doherty@intel.com Date: Wed, 29 Nov 2017 15:53:49 +0100 Message-Id: <20171129145349.43448-1-tomaszx.kulasek@intel.com> X-Mailer: git-send-email 2.12.3 Subject: [dpdk-dev] [PATCH] net/bonding: fix link status check 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Some devices needs more time to initialize and bring interface up. When link is down the link properties are not valid, e.g. link_speed is reported as 0 and this is not a valid speed for slave as well as for whole bonding. During NIC (and bonding) initialization there's concurrency between updating link status and adding slave to the bonding. This patch: - adds delay before configuring bonding (if link is down) to be sure that link status of new slave is valid, - propagates information about link status from first active slave instead of first slave at all, to be sure that link speed is valid. Fixes: 6abd94d72ab5 ("net/bonding: fix check slaves link properties") Signed-off-by: Tomasz Kulasek --- drivers/net/bonding/rte_eth_bond_8023ad_private.h | 1 + drivers/net/bonding/rte_eth_bond_api.c | 50 ++++++++++++++++------- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad_private.h b/drivers/net/bonding/rte_eth_bond_8023ad_private.h index 433c700..0a72beb 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad_private.h +++ b/drivers/net/bonding/rte_eth_bond_8023ad_private.h @@ -180,6 +180,7 @@ struct mode8023ad_private { rte_eth_bond_8023ad_ext_slowrx_fn slowrx_cb; uint8_t external_sm; + uint8_t slave_link_valid; struct rte_eth_link slave_link; /***< slave link properties */ diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index 980e636..6b65fac 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -33,6 +33,7 @@ #include +#include #include #include #include @@ -239,6 +240,7 @@ struct bond_dev_private *internals; struct rte_eth_link link_props; struct rte_eth_dev_info dev_info; + int retries = 10; bonded_eth_dev = &rte_eth_devices[bonded_port_id]; internals = bonded_eth_dev->data->dev_private; @@ -262,6 +264,20 @@ return -1; } + /* Some devices needs more time to initialize and bring interface up. + * While link status up is preferable we wait some time to be sure that + * link status of slave is valid. + */ + if (slave_eth_dev->data->dev_link.link_status == ETH_LINK_DOWN) { + rte_delay_ms(100); + rte_eth_link_get_nowait(slave_port_id, &link_props); + while ((link_props.link_status == ETH_LINK_DOWN) && (retries > 0)) { + rte_delay_ms(100); + rte_eth_link_get_nowait(slave_port_id, &link_props); + retries--; + } + } + slave_add(internals, slave_eth_dev); /* We need to store slaves reta_size to be able to synchronize RETA for all @@ -270,15 +286,16 @@ internals->slaves[internals->slave_count].reta_size = dev_info.reta_size; if (internals->slave_count < 1) { + + /* Reset link status information for bonded slaves (it will be taken + * from first active slave) */ + internals->mode4.slave_link_valid = 0; + /* if MAC is not user defined then use MAC of first slave add to * bonded device */ if (!internals->user_defined_mac) mac_address_set(bonded_eth_dev, slave_eth_dev->data->mac_addrs); - /* Inherit eth dev link properties from first slave */ - link_properties_set(bonded_eth_dev, - &(slave_eth_dev->data->dev_link)); - /* Make primary slave */ internals->primary_port = slave_port_id; internals->current_primary_port = slave_port_id; @@ -302,14 +319,6 @@ internals->tx_offload_capa &= dev_info.tx_offload_capa; internals->flow_type_rss_offloads &= dev_info.flow_type_rss_offloads; - if (link_properties_valid(bonded_eth_dev, - &slave_eth_dev->data->dev_link) != 0) { - RTE_BOND_LOG(ERR, "Invalid link properties for slave %d" - " in bonding mode %d", slave_port_id, - internals->mode); - return -1; - } - /* RETA size is GCD of all slaves RETA sizes, so, if all sizes will be * the power of 2, the lower one is GCD */ @@ -355,9 +364,22 @@ slave_port_id); if (find_slave_by_id(internals->active_slaves, - internals->active_slave_count, - slave_port_id) == internals->active_slave_count) + internals->active_slave_count, + slave_port_id) == internals->active_slave_count) { + if (internals->mode4.slave_link_valid == 0) { + internals->mode4.slave_link_valid = 1; + /* Inherit dev link properties from first active slave */ + link_properties_set(bonded_eth_dev, + &(slave_eth_dev->data->dev_link)); + } else if (link_properties_valid(bonded_eth_dev, + &slave_eth_dev->data->dev_link) != 0) { + RTE_BOND_LOG(ERR, "Invalid link properties for slave %d" + " in bonding mode %d", slave_port_id, + internals->mode); + return -1; + } activate_slave(bonded_eth_dev, slave_port_id); + } } }