DPDK patches and discussions
 help / color / mirror / Atom feed
From: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
To: dev@dpdk.org
Cc: thomas@monjalon.net, ferruh.yigit@intel.com,
	declan.doherty@intel.com, stable@dpdk.org
Subject: [dpdk-dev] [PATCH] ethdev: fix switching domain allocation
Date: Thu, 19 Dec 2019 12:47:06 +0000	[thread overview]
Message-ID: <1576759626-27977-1-git-send-email-viacheslavo@mellanox.com> (raw)

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 <viacheslavo@mellanox.com>
---
 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


             reply	other threads:[~2019-12-19 12:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-19 12:47 Viacheslav Ovsiienko [this message]
2020-01-14 15:32 ` Ferruh Yigit
2020-01-15  8:50   ` Slava Ovsiienko
2020-01-15 12:39     ` Ferruh Yigit
2020-01-16 16:19 ` [dpdk-dev] [PATCH v2] " Viacheslav Ovsiienko
2020-01-16 19:38   ` Ferruh Yigit
2020-01-17 13:20     ` [dpdk-dev] [dpdk-stable] " Ferruh Yigit

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=1576759626-27977-1-git-send-email-viacheslavo@mellanox.com \
    --to=viacheslavo@mellanox.com \
    --cc=declan.doherty@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    /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).