DPDK patches and discussions
 help / color / mirror / Atom feed
From: <kkanas@marvell.com>
To: <dev@dpdk.org>, <david.marchand@redhat.com>,
	Chas Williams <chas3@att.com>
Cc: Krzysztof Kanas <kkanas@marvell.com>, <danielx.t.mrzyglod@intel.com>
Subject: [dpdk-dev]  [PATCH 2/2] net/bonding: fix selection logic
Date: Mon, 5 Aug 2019 16:44:54 +0200	[thread overview]
Message-ID: <20190805144454.10496-2-kkanas@marvell.com> (raw)
In-Reply-To: <20190805144454.10496-1-kkanas@marvell.com>

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


  reply	other threads:[~2019-08-05 14:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-05 14:44 [dpdk-dev] [PATCH 1/2] net/bonding: fix stack overflow in " kkanas
2019-08-05 14:44 ` kkanas [this message]
2019-10-08 14:34   ` [dpdk-dev] [PATCH 2/2] net/bonding: fix " 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190805144454.10496-2-kkanas@marvell.com \
    --to=kkanas@marvell.com \
    --cc=CAJFAV8yRusdA7A9TC9M+ZsaA_LZbV3_XdSsTDjd4+oEUBk6vAg@mail.gmail.com \
    --cc=chas3@att.com \
    --cc=danielx.t.mrzyglod@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).