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 0E169A04F0; Thu, 19 Dec 2019 13:47:22 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 325FB1BE9D; Thu, 19 Dec 2019 13:47:20 +0100 (CET) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 54D961BC25 for ; Thu, 19 Dec 2019 13:47:18 +0100 (CET) Received: from Internal Mail-Server by MTLPINE1 (envelope-from viacheslavo@mellanox.com) with ESMTPS (AES256-SHA encrypted); 19 Dec 2019 14:47:12 +0200 Received: from pegasus11.mtr.labs.mlnx (pegasus11.mtr.labs.mlnx [10.210.16.104]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id xBJClCgw018215; Thu, 19 Dec 2019 14:47:12 +0200 Received: from pegasus11.mtr.labs.mlnx (localhost [127.0.0.1]) by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7) with ESMTP id xBJClCDl028045; Thu, 19 Dec 2019 12:47:12 GMT Received: (from viacheslavo@localhost) by pegasus11.mtr.labs.mlnx (8.14.7/8.14.7/Submit) id xBJClBhu028044; Thu, 19 Dec 2019 12:47:11 GMT X-Authentication-Warning: pegasus11.mtr.labs.mlnx: viacheslavo set sender to viacheslavo@mellanox.com using -f From: Viacheslav Ovsiienko To: dev@dpdk.org Cc: thomas@monjalon.net, ferruh.yigit@intel.com, declan.doherty@intel.com, stable@dpdk.org Date: Thu, 19 Dec 2019 12:47:06 +0000 Message-Id: <1576759626-27977-1-git-send-email-viacheslavo@mellanox.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [PATCH] ethdev: fix switching domain allocation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The maximum amount of unique switching domain is supposed to be equal to RTE_MAX_ETHPORTS. The current implementation allows to allocate only RTE_MAX_ETHPORTS-1 domains. Fixes: ce9250406323 ("ethdev: add switch domain allocator") Cc: stable@dpdk.org Signed-off-by: Viacheslav Ovsiienko --- lib/librte_ethdev/rte_ethdev.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 6e9cb24..4c2312c 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5065,10 +5065,10 @@ enum rte_eth_switch_domain_state { *domain_id = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID; for (i = RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID + 1; - i < RTE_MAX_ETHPORTS; i++) { - if (rte_eth_switch_domains[i].state == + i <= RTE_MAX_ETHPORTS; i++) { + if (rte_eth_switch_domains[i - 1].state == RTE_ETH_SWITCH_DOMAIN_UNUSED) { - rte_eth_switch_domains[i].state = + rte_eth_switch_domains[i - 1].state = RTE_ETH_SWITCH_DOMAIN_ALLOCATED; *domain_id = i; return 0; @@ -5082,14 +5082,15 @@ enum rte_eth_switch_domain_state { rte_eth_switch_domain_free(uint16_t domain_id) { if (domain_id == RTE_ETH_DEV_SWITCH_DOMAIN_ID_INVALID || - domain_id >= RTE_MAX_ETHPORTS) + domain_id > RTE_MAX_ETHPORTS) return -EINVAL; - if (rte_eth_switch_domains[domain_id].state != + if (rte_eth_switch_domains[domain_id - 1].state != RTE_ETH_SWITCH_DOMAIN_ALLOCATED) return -EINVAL; - rte_eth_switch_domains[domain_id].state = RTE_ETH_SWITCH_DOMAIN_UNUSED; + rte_eth_switch_domains[domain_id - 1].state = + RTE_ETH_SWITCH_DOMAIN_UNUSED; return 0; } -- 1.8.3.1