From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by dpdk.org (Postfix) with ESMTP id 652051B338 for ; Sun, 11 Feb 2018 08:53:18 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id E0E6020D2B; Sun, 11 Feb 2018 02:53:17 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute1.internal (MEProxy); Sun, 11 Feb 2018 02:53:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fridaylinux.org; h=cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=U0DiMf0C+tm8gswsp/XSYid93cJ0V96PrdomzyT5nR4=; b=N04x87eC VxoyKsUnxMDA1vRzA9GUIu8/DKh4LomCRG1qZIVSN9AH9FaEEchtPEJVvC+DpvvQ 6vWMz/dfYuoRuK0jbYBH7PxQj55VFRZVHFveTST7O4TzzpeGkJyUwXfGYV5kdDmm PsTkDoUPEQveGgeRbayc3oVdFVnCt2hl3oPgDyD7RIC2zwpI1cfeDas5oRzm8hUl WhQcUQfW+DxPVO6UoVkZrp0UDVMc9P3SJL62kwHHRvuy6emaGp7tahy2FmEenLES YZd4x1y+/C2fSvv8V7t6T6HTC71nUQemCxlGpsa1r2zZpWWxLdXw4FMO/H4rvBY8 4JdT8H+YOVeyqw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=U0DiMf0C+tm8gswsp/XSYid93cJ0V 96PrdomzyT5nR4=; b=RMFqTJfQL2+1sTcQL5UkLi5Mgaj+HYdjnhDcRmzat+eu5 FV0NmPCn15uc7mvZFv1CfRNMCQCZnuDlO6I1A+xy4BSkTw5C2qUkugv7YVj30lNF QMTrfrjX/MmXIIxaK6flPoZrAKnayI6eQyYhf5t4bQY1vRZNcjIUVC2WaCkLAeqs sHHvw2jmnFw6/sEyIv03+gFh4CqT0ydTHdvsQIgf2OmWd+qgNedgKZDQSfgwOWxF QSJQmBG/EQhfJrWl1RSiXJLr4L/nlpeob3ejtbUxz65MvDIHFVkR60pySnSVmjJx qEttWpcj1aivU98jek+XkZb2FkVmtNSgmTmO+5Cew== X-ME-Sender: Received: from yliu-mob (unknown [115.150.101.1]) by mail.messagingengine.com (Postfix) with ESMTPA id 01A73246D5; Sun, 11 Feb 2018 02:53:16 -0500 (EST) Date: Sun, 11 Feb 2018 15:53:13 +0800 From: Yuanhan Liu To: Matan Azrad Cc: stable@dpdk.org Message-ID: <20180211075313.GL23970@yliu-mob> References: <1518334822-18674-1-git-send-email-matan@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1518334822-18674-1-git-send-email-matan@mellanox.com> User-Agent: Mutt/1.5.24 (2015-08-30) Subject: Re: [dpdk-stable] [PATCH] ethdev: fix port id allocation X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Feb 2018 07:53:18 -0000 On Sun, Feb 11, 2018 at 07:40:22AM +0000, Matan Azrad wrote: > [ backported from upstream commit 8ee892a2385c50427c03db5cef1789babceb5999 ] Applied to dpdk-stable/17.11. Thanks. --yliu > > rte_eth_dev_find_free_port() found a free port by state checking. > The state field are in local process memory, so other DPDK processes > may get the same port ID because their local states may be different. > > Replace the state checking by the ethdev port name checking, > so, if the name is an empty string the port ID will be detected as > unused. > > Fixes: d948f596fee2 ("ethdev: fix port data mismatched in multiple process model") > > Suggested-by: Konstantin Ananyev > Signed-off-by: Matan Azrad > Acked-by: Thomas Monjalon > Acked-by: Konstantin Ananyev > --- > > > Backported this commit for LTS release 17.11.1. > Please let me know for any issue with this commit, will be happy to help. > > lib/librte_ether/rte_ethdev.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > index 9dcb0d2..4d23bc1 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -192,8 +192,12 @@ struct rte_eth_dev * > unsigned i; > > for (i = 0; i < RTE_MAX_ETHPORTS; i++) { > - if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED) > + /* Using shared name field to find a free port. */ > + if (rte_eth_dev_data[i].name[0] == '\0') { > + RTE_ASSERT(rte_eth_devices[i].state == > + RTE_ETH_DEV_UNUSED); > return i; > + } > } > return RTE_MAX_ETHPORTS; > } > @@ -218,15 +222,15 @@ struct rte_eth_dev * > uint16_t port_id; > struct rte_eth_dev *eth_dev; > > + if (rte_eth_dev_data == NULL) > + rte_eth_dev_data_alloc(); > + > port_id = rte_eth_dev_find_free_port(); > if (port_id == RTE_MAX_ETHPORTS) { > RTE_PMD_DEBUG_TRACE("Reached maximum number of Ethernet ports\n"); > return NULL; > } > > - if (rte_eth_dev_data == NULL) > - rte_eth_dev_data_alloc(); > - > if (rte_eth_dev_allocated(name) != NULL) { > RTE_PMD_DEBUG_TRACE("Ethernet Device with name %s already allocated!\n", > name); > -- > 1.8.3.1