patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Yuanhan Liu <yliu@fridaylinux.org>
To: Matan Azrad <matan@mellanox.com>
Cc: stable@dpdk.org
Subject: Re: [dpdk-stable] [PATCH] ethdev: fix port id allocation
Date: Sun, 11 Feb 2018 15:53:13 +0800	[thread overview]
Message-ID: <20180211075313.GL23970@yliu-mob> (raw)
In-Reply-To: <1518334822-18674-1-git-send-email-matan@mellanox.com>

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 <konstantin.ananyev@intel.com>
> Signed-off-by: Matan Azrad <matan@mellanox.com>
> Acked-by: Thomas Monjalon <thomas@monjalon.net>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> ---
> 
> 
> 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

      reply	other threads:[~2018-02-11  7:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-11  7:40 Matan Azrad
2018-02-11  7:53 ` Yuanhan Liu [this message]

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=20180211075313.GL23970@yliu-mob \
    --to=yliu@fridaylinux.org \
    --cc=matan@mellanox.com \
    --cc=stable@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).