From patchwork Thu Feb 14 19:11:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chas Williams <3chas3@gmail.com> X-Patchwork-Id: 50329 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 4790C1B49C; Thu, 14 Feb 2019 20:11:19 +0100 (CET) Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by dpdk.org (Postfix) with ESMTP id 32FCC1B486; Thu, 14 Feb 2019 20:11:18 +0100 (CET) Received: by mail-qt1-f193.google.com with SMTP id n32so8101998qte.11; Thu, 14 Feb 2019 11:11: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=ZkYdjsFKR1g8HuWCGOxLLmpHzJt40K1+k/ZQrTZtljo=; b=daCWi+0Tx3gbl7SCnBGZOAcc6iQiLAsZco2fPzewBR1UhmH7/WvTArn+TNm4hehf5G f15tYGmqnIKciHc0yE+kqlSCmJEV92l5IliSdFQXasrZ/HaXP9zNXugMl9/UPDU3u9Em 1cBGWtW9b6aojGO8h0GZ+EARCfuIYe9KUOBsRzvVpEKxBmaGpgIwfFmShMV8RD6fPGay c5W0QQU0xzO2FsWnZkka6ELIg79mn1MCmjfy8KFiH6XuSHM9/iG8gzABAotqT5oKzJXZ 8PzGLUrdBJESwpBPSlp813bSENFO1Hv8ih7JxFawIVvLvQQmgMsZRErSXZz63jt8u4Du PtPQ== 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=ZkYdjsFKR1g8HuWCGOxLLmpHzJt40K1+k/ZQrTZtljo=; b=UwXIEBOrUg1u9VzB18rp4z20rxYZKele3ZiU5TGiuWlLAnn3WzIeVCEx0kyk9oFnzi CDQStaOm3nYrHsv+IHEnOl5nwcKCmITOKMFYUMqhdy00sUI+b2iwxCDcoBQ6TGseT+SI ZhKXlBmdvin8WYjxytIdiaptjB99yiFIoItKteemosjcQSJFcd3QnSYhOpRg6jTWewyG IESPHm8zqN2f10EMMfdhD1eGU8hTPi4/D2CiSBfZwgyRmPdpGSOneER0kMkwcGBqvf4n WuAtc+IhU8REdbwXNnksTy8n7kN0Ks0Jeikg3WthPgzpb8rqof1T6pf8NcdS1PB3nXfq xR3Q== X-Gm-Message-State: AHQUAuaZI0klBdMwIeEhyth7Z8GCdHyZEukhUswdJhUbQrzHSzRw4uS8 7lTRl/CNjksk9jnKChe6JdHbWIQK X-Google-Smtp-Source: AHgI3IbhuMgBF06ji0NaPaMR7+7DqAohftcR4qDdB/4vbetCtVdJul26X3qzYIPJiTNX+r6cqYHqNQ== X-Received: by 2002:a0c:bec3:: with SMTP id f3mr4294403qvj.127.1550171477527; Thu, 14 Feb 2019 11:11:17 -0800 (PST) Received: from monolith.fios-router.home (pool-96-255-82-34.washdc.fios.verizon.net. [96.255.82.34]) by smtp.gmail.com with ESMTPSA id c202sm2197710qkb.19.2019.02.14.11.11.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Feb 2019 11:11:16 -0800 (PST) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: Chas Williams , stable@dpdk.org Date: Thu, 14 Feb 2019 14:11:12 -0500 Message-Id: <20190214191112.31018-1-3chas3@gmail.com> X-Mailer: git-send-email 2.17.2 Subject: [dpdk-dev] [PATCH] net/bonding: fix invalid link status 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" From: Chas Williams Copying the link properties of the first slave added may copy an invalid link status. The speed and duplex of the slave may not be known at this time. Delay setting the properties until the first slave reports as link up. Note that we are still ignoring an error from link_properties_valid. For some bonding modes, 802.3ad, we should not activate the slave if it does not have matching link properties. Fixes: a45b288ef21a ("bond: support link status polling") Cc: stable@dpdk.org Signed-off-by: Chas Williams --- drivers/net/bonding/rte_eth_bond_api.c | 4 --- drivers/net/bonding/rte_eth_bond_pmd.c | 31 +++++++++++++--------- drivers/net/bonding/rte_eth_bond_private.h | 7 ----- 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index e5e146540..57ef2f001 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -484,10 +484,6 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) } } - /* 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; diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 61e731a8f..c4a2b955c 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -1449,7 +1449,7 @@ bond_ethdev_tx_burst_broadcast(void *queue, struct rte_mbuf **bufs, return max_nb_of_tx_pkts; } -void +static void link_properties_set(struct rte_eth_dev *ethdev, struct rte_eth_link *slave_link) { struct bond_dev_private *bond_ctx = ethdev->data->dev_private; @@ -1474,7 +1474,7 @@ link_properties_set(struct rte_eth_dev *ethdev, struct rte_eth_link *slave_link) } } -int +static int link_properties_valid(struct rte_eth_dev *ethdev, struct rte_eth_link *slave_link) { @@ -2693,16 +2693,6 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, if (active_pos < internals->active_slave_count) goto link_update; - /* if no active slave ports then set this port to be primary port */ - if (internals->active_slave_count < 1) { - /* If first active slave, then change link status */ - bonded_eth_dev->data->dev_link.link_status = ETH_LINK_UP; - internals->current_primary_port = port_id; - lsc_flag = 1; - - mac_address_slaves_update(bonded_eth_dev); - } - /* check link state properties if bonded link is up*/ if (bonded_eth_dev->data->dev_link.link_status == ETH_LINK_UP) { if (link_properties_valid(bonded_eth_dev, &link) != 0) @@ -2714,9 +2704,24 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, link_properties_set(bonded_eth_dev, &link); } + /* If no active slave ports then set this port to be + * the primary port. + */ + if (internals->active_slave_count < 1) { + /* If first active slave, then change link status */ + bonded_eth_dev->data->dev_link.link_status = + ETH_LINK_UP; + internals->current_primary_port = port_id; + lsc_flag = 1; + + mac_address_slaves_update(bonded_eth_dev); + } + activate_slave(bonded_eth_dev, port_id); - /* If user has defined the primary port then default to using it */ + /* If the user has defined the primary port then default to + * using it. + */ if (internals->user_defined_primary_port && internals->primary_port == port_id) bond_ethdev_primary_set(internals, port_id); diff --git a/drivers/net/bonding/rte_eth_bond_private.h b/drivers/net/bonding/rte_eth_bond_private.h index 3ea5d686b..032ffed02 100644 --- a/drivers/net/bonding/rte_eth_bond_private.h +++ b/drivers/net/bonding/rte_eth_bond_private.h @@ -222,13 +222,6 @@ deactivate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id); void activate_slave(struct rte_eth_dev *eth_dev, uint16_t port_id); -void -link_properties_set(struct rte_eth_dev *bonded_eth_dev, - struct rte_eth_link *slave_dev_link); -int -link_properties_valid(struct rte_eth_dev *bonded_eth_dev, - struct rte_eth_link *slave_dev_link); - int mac_address_set(struct rte_eth_dev *eth_dev, struct ether_addr *new_mac_addr);