From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9FAC0A2EEB for ; Tue, 10 Sep 2019 10:26:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 531EE1ED6B; Tue, 10 Sep 2019 10:26:30 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 010E71EC22 for ; Tue, 10 Sep 2019 10:26:20 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us2.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id C5CB51C0068; Tue, 10 Sep 2019 08:26:19 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 10 Sep 2019 01:26:16 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Tue, 10 Sep 2019 01:26:16 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x8A8QFU6002226; Tue, 10 Sep 2019 09:26:15 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 0B1CD1613D2; Tue, 10 Sep 2019 09:26:15 +0100 (BST) From: Andrew Rybchenko To: Chas Williams CC: , Igor Romanov Date: Tue, 10 Sep 2019 09:25:44 +0100 Message-ID: <1568103959-25572-5-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568103959-25572-1-git-send-email-arybchenko@solarflare.com> References: <1568103959-25572-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24898.005 X-TM-AS-Result: No-3.263600-4.000000-10 X-TMASE-MatchedRID: 1e4GURu5ZSnDOgXZFRFV83CO70QAsBdCWw/S0HB7eoNjLp8Cm8vwF2dC uMvHMJPkGWRGldniBlVw5T4Iaj538mJZXQNDzktSDDB/0m4/XMTqobkz1A0A7VeIuu+Gkot8auP Bry+3W1EzlETC5jrcQoL7JbSyOvcew+noLBygYTgFxov+3JYvY6izFDHVmY+juqWf6Nh7tmEYAR BTx8mGnXA1rXsS2KwWpM0DuMZdHThqpXWtxrBsQSQ7ls378/zHA76tPJIOKsWnMb4m7aAqt/N+o A4oIb1dGayYH7HN0cQGQylveAJ0foF4KlUH7HJ6ngIgpj8eDcAZ1CdBJOsoY8RB0bsfrpPIcSqb xBgG0w4dp3EGyknOe4fo+FzzAvMHGz0UHwxBT90jb4ddzb6Mmck+pYzE0OROtMSv1prjUULbZG6 BvIk2Wl8/9cUrr/tcPgbCb+jU1TuTdSRXlCnjBIjjlF305EnAWUm8SESyzd/NBqGt1DPvvA== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--3.263600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24898.005 X-MDID: 1568103980-otnQuYoFf4yY Subject: [dpdk-dev] [PATCH 04/18] net/bonding: check status of getting link info 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: Igor Romanov The return value of rte_eth_link_get() and rte_eth_link_get_nowait() was changed from void to int. Update the usage of the functions according to the new return type. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- drivers/net/bonding/rte_eth_bond_8023ad.c | 24 +++++++--- drivers/net/bonding/rte_eth_bond_api.c | 19 ++++++-- drivers/net/bonding/rte_eth_bond_pmd.c | 55 ++++++++++++++++++++--- 3 files changed, 83 insertions(+), 15 deletions(-) diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c index e64fb6e41..e50d946eb 100644 --- a/drivers/net/bonding/rte_eth_bond_8023ad.c +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c @@ -675,6 +675,7 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id) uint16_t default_slave = 0; uint8_t mode_count_id, mode_band_id; struct rte_eth_link link_info; + int ret; slaves = internals->active_slaves; slaves_count = internals->active_slave_count; @@ -687,8 +688,14 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id) if (agg->aggregator_port_id != slaves[i]) continue; + ret = rte_eth_link_get_nowait(slaves[i], &link_info); + if (ret < 0) { + RTE_BOND_LOG(ERR, + "Slave (port %u) link get failed: %s\n", + slaves[i], rte_strerror(-ret)); + continue; + } agg_count[agg->aggregator_port_id] += 1; - rte_eth_link_get_nowait(slaves[i], &link_info); agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed; /* Actors system ID is not checked since all slave device have the same @@ -821,18 +828,25 @@ bond_mode_8023ad_periodic_cb(void *arg) /* Update link status on each port */ for (i = 0; i < internals->active_slave_count; i++) { uint16_t key; + int ret; slave_id = internals->active_slaves[i]; - rte_eth_link_get_nowait(slave_id, &link_info); - rte_eth_macaddr_get(slave_id, &slave_addr); + ret = rte_eth_link_get_nowait(slave_id, &link_info); + if (ret < 0) { + RTE_BOND_LOG(ERR, + "Slave (port %u) link get failed: %s\n", + slave_id, rte_strerror(-ret)); + } - if (link_info.link_status != 0) { + if (ret >= 0 && link_info.link_status != 0) { key = link_speed_key(link_info.link_speed) << 1; if (link_info.link_duplex == ETH_LINK_FULL_DUPLEX) key |= BOND_LINK_FULL_DUPLEX_KEY; - } else + } else { key = 0; + } + rte_eth_macaddr_get(slave_id, &slave_addr); port = &bond_mode_8023ad_ports[slave_id]; key = rte_cpu_to_be_16(key); diff --git a/drivers/net/bonding/rte_eth_bond_api.c b/drivers/net/bonding/rte_eth_bond_api.c index e2e27e9f2..2cef88720 100644 --- a/drivers/net/bonding/rte_eth_bond_api.c +++ b/drivers/net/bonding/rte_eth_bond_api.c @@ -557,9 +557,6 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) } } - /* Add slave details to bonded device */ - slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE; - /* Update all slave devices MACs */ mac_address_slaves_update(bonded_eth_dev); @@ -571,7 +568,18 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) /* If bonded device is started then we can add the slave to our active * slave array */ if (bonded_eth_dev->data->dev_started) { - rte_eth_link_get_nowait(slave_port_id, &link_props); + ret = rte_eth_link_get_nowait(slave_port_id, &link_props); + if (ret < 0) { + rte_eth_dev_callback_unregister(slave_port_id, + RTE_ETH_EVENT_INTR_LSC, + bond_ethdev_lsc_event_callback, + &bonded_eth_dev->data->port_id); + internals->slave_count--; + RTE_BOND_LOG(ERR, + "Slave (port %u) link get failed: %s\n", + slave_port_id, rte_strerror(-ret)); + return -1; + } if (link_props.link_status == ETH_LINK_UP) { if (internals->active_slave_count == 0 && @@ -581,6 +589,9 @@ __eth_bond_slave_add_lock_free(uint16_t bonded_port_id, uint16_t slave_port_id) } } + /* Add slave details to bonded device */ + slave_eth_dev->data->dev_flags |= RTE_ETH_DEV_BONDED_SLAVE; + slave_vlan_filter_set(bonded_port_id, slave_port_id); return 0; diff --git a/drivers/net/bonding/rte_eth_bond_pmd.c b/drivers/net/bonding/rte_eth_bond_pmd.c index 9316f93f7..a2d13d95c 100644 --- a/drivers/net/bonding/rte_eth_bond_pmd.c +++ b/drivers/net/bonding/rte_eth_bond_pmd.c @@ -846,8 +846,14 @@ bandwidth_left(uint16_t port_id, uint64_t load, uint8_t update_idx, struct bwg_slave *bwg_slave) { struct rte_eth_link link_status; + int ret; - rte_eth_link_get_nowait(port_id, &link_status); + ret = rte_eth_link_get_nowait(port_id, &link_status); + if (ret < 0) { + RTE_BOND_LOG(ERR, "Slave (port %u) link get failed: %s", + port_id, rte_strerror(-ret)); + return; + } uint64_t link_bwg = link_status.link_speed * 1000000ULL / 8; if (link_bwg == 0) return; @@ -2363,7 +2369,9 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete) struct bond_dev_private *bond_ctx; struct rte_eth_link slave_link; + bool one_link_update_succeeded; uint32_t idx; + int ret; bond_ctx = ethdev->data->dev_private; @@ -2396,7 +2404,17 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete) * greater than this are attempted */ for (idx = 0; idx < bond_ctx->active_slave_count; idx++) { - link_update(bond_ctx->active_slaves[idx], &slave_link); + ret = link_update(bond_ctx->active_slaves[idx], + &slave_link); + if (ret < 0) { + ethdev->data->dev_link.link_speed = + ETH_SPEED_NUM_NONE; + RTE_BOND_LOG(ERR, + "Slave (port %u) link get failed: %s", + bond_ctx->active_slaves[idx], + rte_strerror(-ret)); + return 0; + } if (slave_link.link_speed < ethdev->data->dev_link.link_speed) @@ -2406,7 +2424,13 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete) break; case BONDING_MODE_ACTIVE_BACKUP: /* Current primary slave */ - link_update(bond_ctx->current_primary_port, &slave_link); + ret = link_update(bond_ctx->current_primary_port, &slave_link); + if (ret < 0) { + RTE_BOND_LOG(ERR, "Slave (port %u) link get failed: %s", + bond_ctx->current_primary_port, + rte_strerror(-ret)); + return 0; + } ethdev->data->dev_link.link_speed = slave_link.link_speed; break; @@ -2426,13 +2450,28 @@ bond_ethdev_link_update(struct rte_eth_dev *ethdev, int wait_to_complete) * of all the slaves */ ethdev->data->dev_link.link_speed = ETH_SPEED_NUM_NONE; + one_link_update_succeeded = false; for (idx = 0; idx < bond_ctx->active_slave_count; idx++) { - link_update(bond_ctx->active_slaves[idx], &slave_link); + ret = link_update(bond_ctx->active_slaves[idx], + &slave_link); + if (ret < 0) { + RTE_BOND_LOG(ERR, + "Slave (port %u) link get failed: %s", + bond_ctx->active_slaves[idx], + rte_strerror(-ret)); + continue; + } + one_link_update_succeeded = true; ethdev->data->dev_link.link_speed += slave_link.link_speed; } + + if (!one_link_update_succeeded) { + RTE_BOND_LOG(ERR, "All slaves link get failed"); + return 0; + } } @@ -2734,6 +2773,7 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, struct bond_dev_private *internals; struct rte_eth_link link; int rc = -1; + int ret; uint8_t lsc_flag = 0; int valid_slave = 0; @@ -2774,8 +2814,11 @@ bond_ethdev_lsc_event_callback(uint16_t port_id, enum rte_eth_event_type type, active_pos = find_slave_by_id(internals->active_slaves, internals->active_slave_count, port_id); - rte_eth_link_get_nowait(port_id, &link); - if (link.link_status) { + ret = rte_eth_link_get_nowait(port_id, &link); + if (ret < 0) + RTE_BOND_LOG(ERR, "Slave (port %u) link get failed", port_id); + + if (ret == 0 && link.link_status) { if (active_pos < internals->active_slave_count) goto link_update; -- 2.17.1