[v3] net/bonding: fix selection logic
diff mbox series

Message ID 20191011063456.19637-1-kkanas@marvell.com
State New
Delegated to: Ferruh Yigit
Headers show
Series
  • [v3] net/bonding: fix selection logic
Related show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-compilation success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Krzysztof Kanas Oct. 11, 2019, 6:34 a.m. UTC
From: Krzysztof Kanas <kkanas@marvell.com>

Arrays agg_count and agg_bandwidth should be indexed by slave_id not by
aggregator port_id.

Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
Cc: danielx.t.mrzyglod@intel.com

Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>
---
v3:
 * fix incorrect reabse
v2:
 * rebase patch to latest master

 drivers/net/bonding/rte_eth_bond_8023ad.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
--

Comments

Chas Williams Oct. 11, 2019, 3:38 p.m. UTC | #1
This looks better. While reviewing this I noticed that a few lines:

         case AGG_STABLE:
                 if (default_slave == slaves_count)
                         new_agg_id = slave_id;  <<<<<<<<<<<<<<<<<
                 else
                         new_agg_id = slaves[default_slave];
                 break;
         default:
                 if (default_slave == slaves_count)
                         new_agg_id = slave_id;	<<<<<<<<<<<<<
                 else
                         new_agg_id = slaves[default_slave];
                 break;
         }

I don't think the new_agg_id should be the slave_id directly but rather
slaves[slave_id]. Would you mind fixing that as well here if that is
the case?

On 10/11/19 2:34 AM, kkanas@marvell.com wrote:
> From: Krzysztof Kanas <kkanas@marvell.com>
> 
> Arrays agg_count and agg_bandwidth should be indexed by slave_id not by
> aggregator port_id.
> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Cc: danielx.t.mrzyglod@intel.com
> 
> Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>
> ---
> v3:
>   * fix incorrect reabse
> v2:
>   * rebase patch to latest master
> 
>   drivers/net/bonding/rte_eth_bond_8023ad.c | 15 +++++++--------
>   1 file changed, 7 insertions(+), 8 deletions(-)
> --
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 7d8da2b318f5..698311e15c31 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -673,9 +673,8 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
>   	uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
>   	uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
>   	uint16_t default_slave = 0;
> -	uint16_t mode_count_id;
> -	uint16_t mode_band_id;
>   	struct rte_eth_link link_info;
> +	uint16_t agg_new_idx = 0;
>   	int ret;
>   
>   	slaves = internals->active_slaves;
> @@ -696,8 +695,8 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
>   				slaves[i], rte_strerror(-ret));
>   			continue;
>   		}
> -		agg_count[agg->aggregator_port_id] += 1;
> -		agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed;
> +		agg_count[i] += 1;
> +		agg_bandwidth[i] += link_info.link_speed;
>   
>   		/* Actors system ID is not checked since all slave device have the same
>   		 * ID (MAC address). */
> @@ -718,12 +717,12 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
>   
>   	switch (internals->mode4.agg_selection) {
>   	case AGG_COUNT:
> -		mode_count_id = max_index(agg_count, slaves_count);
> -		new_agg_id = mode_count_id;
> +		agg_new_idx = max_index(agg_count, slaves_count);
> +		new_agg_id = slaves[agg_new_idx];
>   		break;
>   	case AGG_BANDWIDTH:
> -		mode_band_id = max_index(agg_bandwidth, slaves_count);
> -		new_agg_id = mode_band_id;
> +		agg_new_idx = max_index(agg_bandwidth, slaves_count);
> +		new_agg_id = slaves[agg_new_idx];
>   		break;
>   	case AGG_STABLE:
>   		if (default_slave == slaves_count)
>

Patch
diff mbox series

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7d8da2b318f5..698311e15c31 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -673,9 +673,8 @@  selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 	uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
 	uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
 	uint16_t default_slave = 0;
-	uint16_t mode_count_id;
-	uint16_t mode_band_id;
 	struct rte_eth_link link_info;
+	uint16_t agg_new_idx = 0;
 	int ret;
 
 	slaves = internals->active_slaves;
@@ -696,8 +695,8 @@  selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 				slaves[i], rte_strerror(-ret));
 			continue;
 		}
-		agg_count[agg->aggregator_port_id] += 1;
-		agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed;
+		agg_count[i] += 1;
+		agg_bandwidth[i] += link_info.link_speed;
 
 		/* Actors system ID is not checked since all slave device have the same
 		 * ID (MAC address). */
@@ -718,12 +717,12 @@  selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 
 	switch (internals->mode4.agg_selection) {
 	case AGG_COUNT:
-		mode_count_id = max_index(agg_count, slaves_count);
-		new_agg_id = mode_count_id;
+		agg_new_idx = max_index(agg_count, slaves_count);
+		new_agg_id = slaves[agg_new_idx];
 		break;
 	case AGG_BANDWIDTH:
-		mode_band_id = max_index(agg_bandwidth, slaves_count);
-		new_agg_id = mode_band_id;
+		agg_new_idx = max_index(agg_bandwidth, slaves_count);
+		new_agg_id = slaves[agg_new_idx];
 		break;
 	case AGG_STABLE:
 		if (default_slave == slaves_count)