net/bonding: check status of getting link info
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 <igor.romanov@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
This commit is contained in:
parent
e661a08ba9
commit
fc1134c792
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2685,6 +2724,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;
|
||||
@ -2725,8 +2765,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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user