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 4A818A00E6 for ; Mon, 5 Aug 2019 16:46:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 793E81BDF1; Mon, 5 Aug 2019 16:46:10 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 96CE41B9CD for ; Mon, 5 Aug 2019 16:46:08 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x75EjTJo011357; Mon, 5 Aug 2019 07:46:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : reply-to : mime-version : content-transfer-encoding : content-type; s=pfpt0818; bh=mYLwC9V07fKJbU+nUGwAoqUfjufPF1NpKVEe803M7cg=; b=Tyv0pynp3DvXX6JOiUYL9j/glWvFwCSADpi6bXZiDcPUsfieJrc+UQAJezZHH0E8xnZ+ vkWcNKTUnJRfUlGOVsFIRNY0XK2ZXPjCugzc1J4vIAkQeR/VAJuDGv4HXSpNyANzzkXo +lVrFHY3wUO4n6UL96Ud18aGTpIF7rRWz+ZJAlEUxvRdMrM/UmAppOW14M/PiyiycI/2 Dy+JXqLbdwxL8JBbKPfJbeEilY1MQUC9/IKsRb9lJP38IXZYlAd5k/2lYB+8v/NG42Al nLyW7ZU6NLcsyrfa9YQ1wmKMXo84KVZ6kei/xGRLMjCORYwzytZGrN4LVHgWVomC5aRf 5w== Received: from sc-exch01.marvell.com ([199.233.58.181]) by mx0a-0016f401.pphosted.com with ESMTP id 2u57mqy9k1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 05 Aug 2019 07:46:05 -0700 Received: from SC-EXCH01.marvell.com (10.93.176.81) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 5 Aug 2019 07:46:04 -0700 Received: from maili.marvell.com (10.93.176.43) by SC-EXCH01.marvell.com (10.93.176.81) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Mon, 5 Aug 2019 07:46:04 -0700 Received: from kk-box-0.marvell.com (unknown [10.95.130.77]) by maili.marvell.com (Postfix) with ESMTP id 759B43F703F; Mon, 5 Aug 2019 07:46:02 -0700 (PDT) From: To: , , Chas Williams CC: Krzysztof Kanas , Date: Mon, 5 Aug 2019 16:44:54 +0200 Message-ID: <20190805144454.10496-2-kkanas@marvell.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190805144454.10496-1-kkanas@marvell.com> References: <20190805144454.10496-1-kkanas@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:5.22.84,1.0.8 definitions=2019-08-05_07:2019-07-31,2019-08-05 signatures=0 Subject: [dpdk-dev] [PATCH 2/2] net/bonding: fix selection logic X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: CAJFAV8yRusdA7A9TC9M+ZsaA_LZbV3_XdSsTDjd4+oEUBk6vAg@mail.gmail.com 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: Krzysztof Kanas 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 --- 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