DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic
@ 2019-08-05 14:44 kkanas
  2019-08-05 14:44 ` [dpdk-dev] [PATCH 2/2] net/bonding: fix " kkanas
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: kkanas @ 2019-08-05 14:44 UTC (permalink / raw)
  To: dev, david.marchand, Chas Williams; +Cc: Krzysztof Kanas, danielx.t.mrzyglod

From: Krzysztof Kanas <kkanas@marvell.com>

Bonding selection logic uses agg_bandwidth, agg_count indexed by port_id
but those arrays are 8 entries long.

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

Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index d764dad331ed..89a8ba3de963 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -670,8 +670,8 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 	struct port *agg, *port;
 	uint16_t slaves_count, new_agg_id, i, j = 0;
 	uint16_t *slaves;
-	uint64_t agg_bandwidth[8] = {0};
-	uint64_t agg_count[8] = {0};
+	uint64_t agg_bandwidth[RTE_MAX_ETHPORTS] = {0};
+	uint64_t agg_count[RTE_MAX_ETHPORTS] = {0};
 	uint16_t default_slave = 0;
 	uint8_t mode_count_id, mode_band_id;
 	struct rte_eth_link link_info;
-- 
2.21.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev]  [PATCH 2/2] net/bonding: fix selection logic
  2019-08-05 14:44 [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic kkanas
@ 2019-08-05 14:44 ` kkanas
  2019-10-08 14:34   ` Yigit, Ferruh
  2019-08-05 15:09 ` [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in " David Marchand
  2019-10-08 14:33 ` [dpdk-dev] " Yigit, Ferruh
  2 siblings, 1 reply; 12+ messages in thread
From: kkanas @ 2019-08-05 14:44 UTC (permalink / raw)
  To: dev, david.marchand, Chas Williams; +Cc: Krzysztof Kanas, danielx.t.mrzyglod

From: Krzysztof Kanas <kkanas@marvell.com>

Fix max_index to return uint16_t as it is valid slave_id type.

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>
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 89a8ba3de963..b923e69ef23a 100644
--- a/drivers/net/bonding/rte_eth_bond_8023ad.c
+++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
@@ -639,7 +639,7 @@ tx_machine(struct bond_dev_private *internals, uint16_t slave_id)
 	SM_FLAG_CLR(port, NTT);
 }
 
-static uint8_t
+static uint16_t
 max_index(uint64_t *a, int n)
 {
 	if (n <= 0)
@@ -673,8 +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;
-	uint8_t mode_count_id, mode_band_id;
 	struct rte_eth_link link_info;
+	uint16_t agg_new_idx = 0;
 
 	slaves = internals->active_slaves;
 	slaves_count = internals->active_slave_count;
@@ -687,9 +687,9 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 		if (agg->aggregator_port_id != slaves[i])
 			continue;
 
-		agg_count[agg->aggregator_port_id] += 1;
+		agg_count[i] += 1;
 		rte_eth_link_get_nowait(slaves[i], &link_info);
-		agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed;
+		agg_bandwidth[i] += link_info.link_speed;
 
 		/* Actors system ID is not checked since all slave device have the same
 		 * ID (MAC address). */
@@ -710,14 +710,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(
-				(uint64_t *)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(
-				(uint64_t *)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)
-- 
2.21.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic
  2019-08-05 14:44 [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic kkanas
  2019-08-05 14:44 ` [dpdk-dev] [PATCH 2/2] net/bonding: fix " kkanas
@ 2019-08-05 15:09 ` David Marchand
  2019-08-07  7:41   ` [dpdk-dev] [EXT] " Krzysztof Kanas
  2019-10-08 14:33 ` [dpdk-dev] " Yigit, Ferruh
  2 siblings, 1 reply; 12+ messages in thread
From: David Marchand @ 2019-08-05 15:09 UTC (permalink / raw)
  To: Krzysztof Kanas
  Cc: dev, Chas Williams, danielx.t.mrzyglod, Jerin Jacob Kollanukkaran

On Mon, Aug 5, 2019 at 4:46 PM <kkanas@marvell.com> wrote:
>
> From: Krzysztof Kanas <kkanas@marvell.com>
>
> Bonding selection logic uses agg_bandwidth, agg_count indexed by port_id
> but those arrays are 8 entries long.

Idem http://mails.dpdk.org/archives/dev/2019-July/140020.html

I did not get a reply from you.


-- 
David Marchand

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [EXT] Re: [PATCH 1/2] net/bonding: fix stack overflow in selection logic
  2019-08-05 15:09 ` [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in " David Marchand
@ 2019-08-07  7:41   ` Krzysztof Kanas
  0 siblings, 0 replies; 12+ messages in thread
From: Krzysztof Kanas @ 2019-08-07  7:41 UTC (permalink / raw)
  To: David Marchand
  Cc: Krzysztof Kanas, dev, Chas Williams, danielx.t.mrzyglod,
	Jerin Jacob Kollanukkaran

On 19-08-05 17:09, David Marchand wrote:
> External Email
> 
> ----------------------------------------------------------------------
> On Mon, Aug 5, 2019 at 4:46 PM <kkanas@marvell.com> wrote:
> >
> > From: Krzysztof Kanas <kkanas@marvell.com>
> >
> > Bonding selection logic uses agg_bandwidth, agg_count indexed by port_id
> > but those arrays are 8 entries long.
> 
> Idem http://mails.dpdk.org/archives/dev/2019-July/140020.html
> 
> I did not get a reply from you.
> 

Sorry I have look at mailing list and looked that discussion stooped at 
http://mails.dpdk.org/archives/dev/2019-March/127444.html
So I prepared fix for and wanted to reply to that thread with new 
patches.

Unfortunately I added '--reply-to' to git send-email command and not 
--in-reply-to as I should have done.
> 
> -- 
> David Marchand

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic
  2019-08-05 14:44 [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic kkanas
  2019-08-05 14:44 ` [dpdk-dev] [PATCH 2/2] net/bonding: fix " kkanas
  2019-08-05 15:09 ` [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in " David Marchand
@ 2019-10-08 14:33 ` Yigit, Ferruh
  2 siblings, 0 replies; 12+ messages in thread
From: Yigit, Ferruh @ 2019-10-08 14:33 UTC (permalink / raw)
  To: CAJFAV8yRusdA7A9TC9M+ZsaA_LZbV3_XdSsTDjd4+oEUBk6vAg, dev,
	david.marchand, Chas Williams
  Cc: Krzysztof Kanas, danielx.t.mrzyglod

On 8/5/2019 3:44 PM, kkanas@marvell.com wrote:
> From: Krzysztof Kanas <kkanas@marvell.com>
> 
> Bonding selection logic uses agg_bandwidth, agg_count indexed by port_id
> but those arrays are 8 entries long.
> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Cc: danielx.t.mrzyglod@intel.com
> 
> Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>

This is duplication of the an existing patch [1] which has been merged now,
rejecting this one.

[1] https://patchwork.dpdk.org/patch/51492/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH 2/2] net/bonding: fix selection logic
  2019-08-05 14:44 ` [dpdk-dev] [PATCH 2/2] net/bonding: fix " kkanas
@ 2019-10-08 14:34   ` Yigit, Ferruh
  2019-10-10  8:27     ` [dpdk-dev] [PATCH v2] " kkanas
  0 siblings, 1 reply; 12+ messages in thread
From: Yigit, Ferruh @ 2019-10-08 14:34 UTC (permalink / raw)
  To: CAJFAV8yRusdA7A9TC9M+ZsaA_LZbV3_XdSsTDjd4+oEUBk6vAg, dev,
	david.marchand, Chas Williams
  Cc: Krzysztof Kanas, danielx.t.mrzyglod

On 8/5/2019 3:44 PM, kkanas@marvell.com wrote:
> From: Krzysztof Kanas <kkanas@marvell.com>
> 
> Fix max_index to return uint16_t as it is valid slave_id type.
> 
> Arrays agg_count and agg_bandwidth should be indexed by slave_id not by
> aggregator port_id.

The port_id type has been fixed already with another patch [1] and it has been
merged, but this patch does more,
Can you please send a new version on top of latest next-net?

[1]
https://patches.dpdk.org/patch/51491/
Commit b15a8a91432b ("net/bonding: fix more incorrect slave id types")

> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Cc: danielx.t.mrzyglod@intel.com
> 
> Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>
> ---
>  drivers/net/bonding/rte_eth_bond_8023ad.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
> index 89a8ba3de963..b923e69ef23a 100644
> --- a/drivers/net/bonding/rte_eth_bond_8023ad.c
> +++ b/drivers/net/bonding/rte_eth_bond_8023ad.c
> @@ -639,7 +639,7 @@ tx_machine(struct bond_dev_private *internals, uint16_t slave_id)
>  	SM_FLAG_CLR(port, NTT);
>  }
>  
> -static uint8_t
> +static uint16_t
>  max_index(uint64_t *a, int n)
>  {
>  	if (n <= 0)
> @@ -673,8 +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;
> -	uint8_t mode_count_id, mode_band_id;
>  	struct rte_eth_link link_info;
> +	uint16_t agg_new_idx = 0;
>  
>  	slaves = internals->active_slaves;
>  	slaves_count = internals->active_slave_count;
> @@ -687,9 +687,9 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
>  		if (agg->aggregator_port_id != slaves[i])
>  			continue;
>  
> -		agg_count[agg->aggregator_port_id] += 1;
> +		agg_count[i] += 1;
>  		rte_eth_link_get_nowait(slaves[i], &link_info);
> -		agg_bandwidth[agg->aggregator_port_id] += link_info.link_speed;
> +		agg_bandwidth[i] += link_info.link_speed;
>  
>  		/* Actors system ID is not checked since all slave device have the same
>  		 * ID (MAC address). */
> @@ -710,14 +710,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(
> -				(uint64_t *)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(
> -				(uint64_t *)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)
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev]  [PATCH v2] net/bonding: fix selection logic
  2019-10-08 14:34   ` Yigit, Ferruh
@ 2019-10-10  8:27     ` kkanas
  2019-10-10 13:30       ` Chas Williams
  0 siblings, 1 reply; 12+ messages in thread
From: kkanas @ 2019-10-10  8:27 UTC (permalink / raw)
  To: dev, david.marchand, Chas Williams; +Cc: Krzysztof Kanas, danielx.t.mrzyglod

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>
---
 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..5b489b070b09 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). */
@@ -717,13 +716,13 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
 	}
 
 	switch (internals->mode4.agg_selection) {
+		agg_new_idx = max_index(agg_count, slaves_count);
+		new_agg_id = slaves[agg_new_idx];
 	case AGG_COUNT:
-		mode_count_id = max_index(agg_count, slaves_count);
-		new_agg_id = mode_count_id;
 		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)
-- 
2.21.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v2] net/bonding: fix selection logic
  2019-10-10  8:27     ` [dpdk-dev] [PATCH v2] " kkanas
@ 2019-10-10 13:30       ` Chas Williams
  2019-10-11  6:34         ` [dpdk-dev] [PATCH v3] " kkanas
  0 siblings, 1 reply; 12+ messages in thread
From: Chas Williams @ 2019-10-10 13:30 UTC (permalink / raw)
  To: kkanas, dev, david.marchand, Chas Williams; +Cc: danielx.t.mrzyglod



On 10/10/19 4:27 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>
> ---
>   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..5b489b070b09 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). */
> @@ -717,13 +716,13 @@ selection_logic(struct bond_dev_private *internals, uint16_t slave_id)
>   	}
>   
>   	switch (internals->mode4.agg_selection) {
> +		agg_new_idx = max_index(agg_count, slaves_count);
> +		new_agg_id = slaves[agg_new_idx];
>   	case AGG_COUNT:
> -		mode_count_id = max_index(agg_count, slaves_count);
> -		new_agg_id = mode_count_id;


This change doesn't look right. Did you really want to do this, put the 
code outside of the case statement?

>   		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)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev]  [PATCH v3] net/bonding: fix selection logic
  2019-10-10 13:30       ` Chas Williams
@ 2019-10-11  6:34         ` kkanas
  2019-10-11 15:38           ` Chas Williams
  0 siblings, 1 reply; 12+ messages in thread
From: kkanas @ 2019-10-11  6:34 UTC (permalink / raw)
  To: dev, david.marchand, ferruh.yigit, Chas Williams
  Cc: Krzysztof Kanas, danielx.t.mrzyglod

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)
-- 
2.21.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v3] net/bonding: fix selection logic
  2019-10-11  6:34         ` [dpdk-dev] [PATCH v3] " kkanas
@ 2019-10-11 15:38           ` Chas Williams
  2019-11-13  8:22             ` [dpdk-dev] [PATCH v4] " kkanas
  0 siblings, 1 reply; 12+ messages in thread
From: Chas Williams @ 2019-10-11 15:38 UTC (permalink / raw)
  To: kkanas, dev, david.marchand, ferruh.yigit, Chas Williams
  Cc: danielx.t.mrzyglod

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)
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [dpdk-dev]  [PATCH v4] net/bonding: fix selection logic
  2019-10-11 15:38           ` Chas Williams
@ 2019-11-13  8:22             ` kkanas
  2019-11-15 15:56               ` Ferruh Yigit
  0 siblings, 1 reply; 12+ messages in thread
From: kkanas @ 2019-11-13  8:22 UTC (permalink / raw)
  To: dev, david.marchand, ferruh.yigit, Chas Williams
  Cc: Krzysztof Kanas, danielx.t.mrzyglod

From: Krzysztof Kanas <kkanas@marvell.com>

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

The new_agg_id should be chosen as slave_id from slaves table in
different selection modes.

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

Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>
---
v4:
 * add fix for new_agg_id in AGG_COUNT and AGG_STABLE agg_selection
v3:
 * fix incorrect reabse
v2:
 * rebase patch to latest maste
---
 drivers/net/bonding/rte_eth_bond_8023ad.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/drivers/net/bonding/rte_eth_bond_8023ad.c b/drivers/net/bonding/rte_eth_bond_8023ad.c
index 7d8da2b318f5..19e2e880a808 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,22 +717,22 @@ 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)
-			new_agg_id = slave_id;
+			new_agg_id = slaves[slave_id];
 		else
 			new_agg_id = slaves[default_slave];
 		break;
 	default:
 		if (default_slave == slaves_count)
-			new_agg_id = slave_id;
+			new_agg_id = slaves[slave_id];
 		else
 			new_agg_id = slaves[default_slave];
 		break;
-- 
2.21.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [dpdk-dev] [PATCH v4] net/bonding: fix selection logic
  2019-11-13  8:22             ` [dpdk-dev] [PATCH v4] " kkanas
@ 2019-11-15 15:56               ` Ferruh Yigit
  0 siblings, 0 replies; 12+ messages in thread
From: Ferruh Yigit @ 2019-11-15 15:56 UTC (permalink / raw)
  To: kkanas, dev, david.marchand, ferruh.yigit, Chas Williams
  Cc: danielx.t.mrzyglod

On 11/13/2019 8:22 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.
> 
> The new_agg_id should be chosen as slave_id from slaves table in
> different selection modes.
> 
> Fixes: 6d72657ce379 ("net/bonding: add other aggregator modes")
> Cc: danielx.t.mrzyglod@intel.com
> 
> Signed-off-by: Krzysztof Kanas <kkanas@marvell.com>

Adding Chas' implied ack, since the change request from him, please let me know
if this is wrong:

Acked-by: Chas Williams <chas3@att.com>

Acked-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied to dpdk-next-net/master, thanks

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2019-11-15 15:56 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 14:44 [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in selection logic kkanas
2019-08-05 14:44 ` [dpdk-dev] [PATCH 2/2] net/bonding: fix " kkanas
2019-10-08 14:34   ` Yigit, Ferruh
2019-10-10  8:27     ` [dpdk-dev] [PATCH v2] " kkanas
2019-10-10 13:30       ` Chas Williams
2019-10-11  6:34         ` [dpdk-dev] [PATCH v3] " kkanas
2019-10-11 15:38           ` Chas Williams
2019-11-13  8:22             ` [dpdk-dev] [PATCH v4] " kkanas
2019-11-15 15:56               ` Ferruh Yigit
2019-08-05 15:09 ` [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in " David Marchand
2019-08-07  7:41   ` [dpdk-dev] [EXT] " Krzysztof Kanas
2019-10-08 14:33 ` [dpdk-dev] " Yigit, Ferruh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).