net/mlx5: allow multi probing

Message ID 1538553677-32010-1-git-send-email-ophirmu@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Shahaf Shuler
Headers
Series net/mlx5: allow multi probing |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK

Commit Message

Ophir Munk Oct. 3, 2018, 8:01 a.m. UTC
  Implement probing of a device multiple times, see [1].
Consecutive probing requests with a devargs string may contain
repetitive master and representors devices for which eth device should
be created. If an eth device already exists - silently ignore it.

[1]
Serie: ("eal: allow hotplug to skip an already probed device")
https://patches.dpdk.org/project/dpdk/list/?series=1580

Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
 drivers/net/mlx5/mlx5.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
  

Comments

Yongseok Koh Oct. 5, 2018, 1:41 a.m. UTC | #1
On Wed, Oct 03, 2018 at 01:01:23AM -0700, Ophir Munk wrote:
> Implement probing of a device multiple times, see [1].
> Consecutive probing requests with a devargs string may contain
> repetitive master and representors devices for which eth device should
> be created. If an eth device already exists - silently ignore it.
> 
> [1]
> Serie: ("eal: allow hotplug to skip an already probed device")

A typo? Series?

For the title, either 'multi-probing' or 'multiple probing'.
And I suggest

	net/mlx5: allow multiple probing for representor

And I have only nitpickings below ;-)

> https://patches.dpdk.org/project/dpdk/list/?series=1580
> 
> Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index b2b0aaa..16a8b9d 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -736,6 +736,7 @@
>  	struct ether_addr mac;
>  	char name[RTE_ETH_NAME_MAX_LEN];
>  	int own_domain_id = 0;
> +	uint16_t port_id;
>  	unsigned int i;
>  
>  	/* Determine if this port representor is supposed to be spawned. */
> @@ -758,6 +759,17 @@
>  			return NULL;
>  		}
>  	}
> +	/* Build device name */

Better to put a period (.), if it is a sentence.

> +	if (!switch_info->representor)
> +		rte_strlcpy(name, dpdk_dev->name, sizeof(name));
> +	else
> +		snprintf(name, sizeof(name), "%s_representor_%u",
> +			 dpdk_dev->name, switch_info->port_name);
> +	/* if dev (master or representor) is already spawned - return NULL */

How about,
	/* Check if the device is already spawned. */

"return NULL" is so obvious from the code.

> +	if (rte_eth_dev_get_port_by_name(name, &port_id) == 0) {
> +		rte_errno = EBUSY;

Semantically, shouldn't it be EEXIST and add the condition in probe()?

> +		return NULL;
> +	}
>  	/* Prepare shared data between primary and secondary process. */
>  	mlx5_prepare_shared_data();
>  	errno = 0;
> @@ -864,11 +876,6 @@
>  		DEBUG("ibv_query_device_ex() failed");
>  		goto error;
>  	}
> -	if (!switch_info->representor)
> -		rte_strlcpy(name, dpdk_dev->name, sizeof(name));
> -	else
> -		snprintf(name, sizeof(name), "%s_representor_%u",
> -			 dpdk_dev->name, switch_info->port_name);
>  	DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
>  	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
>  		eth_dev = rte_eth_dev_attach_secondary(name);
> @@ -1298,9 +1305,6 @@ struct mlx5_dev_spawn_data {
>  	assert(pci_drv == &mlx5_driver);
>  	errno = 0;
>  
> -	if (rte_dev_is_probed(&pci_dev->device))
> -		return -EEXIST;
> -
>  	ibv_list = mlx5_glue->get_device_list(&ret);
>  	if (!ibv_list) {
>  		rte_errno = errno ? errno : ENOSYS;
> @@ -1412,7 +1416,7 @@ struct mlx5_dev_spawn_data {
>  		if (!list[i].eth_dev) {
>  			if (rte_errno != EBUSY)

I meant this to be,
			if (rte_errno != EBUSY && rte_errno != EEXIST)


Thanks,
Yongseok

>  				break;
> -			/* Device is disabled, ignore it. */
> +			/* Device is disabled or already spawned. Ignore it. */
>  			continue;
>  		}
>  		restore = list[i].eth_dev->data->dev_flags;
> -- 
> 1.8.3.1
>
  
Ophir Munk Oct. 5, 2018, 11:20 a.m. UTC | #2
v2 sent

> -----Original Message-----
> From: Yongseok Koh
> Sent: Friday, October 05, 2018 4:42 AM
> To: Ophir Munk <ophirmu@mellanox.com>
> Cc: dev@dpdk.org; Asaf Penso <asafp@mellanox.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Thomas Monjalon <thomas@monjalon.net>;
> Olga Shern <olgas@mellanox.com>
> Subject: Re: [PATCH] net/mlx5: allow multi probing
> 
> On Wed, Oct 03, 2018 at 01:01:23AM -0700, Ophir Munk wrote:
> > Implement probing of a device multiple times, see [1].
> > Consecutive probing requests with a devargs string may contain
> > repetitive master and representors devices for which eth device should
> > be created. If an eth device already exists - silently ignore it.
> >
> > [1]
> > Serie: ("eal: allow hotplug to skip an already probed device")
> 
> A typo? Series?
> 
> For the title, either 'multi-probing' or 'multiple probing'.
> And I suggest
> 
> 	net/mlx5: allow multiple probing for representor
> 
> And I have only nitpickings below ;-)
> 
> > https://patches.dpdk.org/project/dpdk/list/?series=1580
> >
> > Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
> > ---
> >  drivers/net/mlx5/mlx5.c | 22 +++++++++++++---------
> >  1 file changed, 13 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index
> > b2b0aaa..16a8b9d 100644
> > --- a/drivers/net/mlx5/mlx5.c
> > +++ b/drivers/net/mlx5/mlx5.c
> > @@ -736,6 +736,7 @@
> >  	struct ether_addr mac;
> >  	char name[RTE_ETH_NAME_MAX_LEN];
> >  	int own_domain_id = 0;
> > +	uint16_t port_id;
> >  	unsigned int i;
> >
> >  	/* Determine if this port representor is supposed to be spawned. */
> > @@ -758,6 +759,17 @@
> >  			return NULL;
> >  		}
> >  	}
> > +	/* Build device name */
> 
> Better to put a period (.), if it is a sentence.
> 
> > +	if (!switch_info->representor)
> > +		rte_strlcpy(name, dpdk_dev->name, sizeof(name));
> > +	else
> > +		snprintf(name, sizeof(name), "%s_representor_%u",
> > +			 dpdk_dev->name, switch_info->port_name);
> > +	/* if dev (master or representor) is already spawned - return NULL
> > +*/
> 
> How about,
> 	/* Check if the device is already spawned. */
> 
> "return NULL" is so obvious from the code.
> 
> > +	if (rte_eth_dev_get_port_by_name(name, &port_id) == 0) {
> > +		rte_errno = EBUSY;
> 
> Semantically, shouldn't it be EEXIST and add the condition in probe()?
> 
> > +		return NULL;
> > +	}
> >  	/* Prepare shared data between primary and secondary process. */
> >  	mlx5_prepare_shared_data();
> >  	errno = 0;
> > @@ -864,11 +876,6 @@
> >  		DEBUG("ibv_query_device_ex() failed");
> >  		goto error;
> >  	}
> > -	if (!switch_info->representor)
> > -		rte_strlcpy(name, dpdk_dev->name, sizeof(name));
> > -	else
> > -		snprintf(name, sizeof(name), "%s_representor_%u",
> > -			 dpdk_dev->name, switch_info->port_name);
> >  	DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
> >  	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
> >  		eth_dev = rte_eth_dev_attach_secondary(name);
> > @@ -1298,9 +1305,6 @@ struct mlx5_dev_spawn_data {
> >  	assert(pci_drv == &mlx5_driver);
> >  	errno = 0;
> >
> > -	if (rte_dev_is_probed(&pci_dev->device))
> > -		return -EEXIST;
> > -
> >  	ibv_list = mlx5_glue->get_device_list(&ret);
> >  	if (!ibv_list) {
> >  		rte_errno = errno ? errno : ENOSYS; @@ -1412,7 +1416,7
> @@ struct
> > mlx5_dev_spawn_data {
> >  		if (!list[i].eth_dev) {
> >  			if (rte_errno != EBUSY)
> 
> I meant this to be,
> 			if (rte_errno != EBUSY && rte_errno != EEXIST)
> 
> 
> Thanks,
> Yongseok
> 
> >  				break;
> > -			/* Device is disabled, ignore it. */
> > +			/* Device is disabled or already spawned. Ignore it.
> */
> >  			continue;
> >  		}
> >  		restore = list[i].eth_dev->data->dev_flags;
> > --
> > 1.8.3.1
> >
  

Patch

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index b2b0aaa..16a8b9d 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -736,6 +736,7 @@ 
 	struct ether_addr mac;
 	char name[RTE_ETH_NAME_MAX_LEN];
 	int own_domain_id = 0;
+	uint16_t port_id;
 	unsigned int i;
 
 	/* Determine if this port representor is supposed to be spawned. */
@@ -758,6 +759,17 @@ 
 			return NULL;
 		}
 	}
+	/* Build device name */
+	if (!switch_info->representor)
+		rte_strlcpy(name, dpdk_dev->name, sizeof(name));
+	else
+		snprintf(name, sizeof(name), "%s_representor_%u",
+			 dpdk_dev->name, switch_info->port_name);
+	/* if dev (master or representor) is already spawned - return NULL */
+	if (rte_eth_dev_get_port_by_name(name, &port_id) == 0) {
+		rte_errno = EBUSY;
+		return NULL;
+	}
 	/* Prepare shared data between primary and secondary process. */
 	mlx5_prepare_shared_data();
 	errno = 0;
@@ -864,11 +876,6 @@ 
 		DEBUG("ibv_query_device_ex() failed");
 		goto error;
 	}
-	if (!switch_info->representor)
-		rte_strlcpy(name, dpdk_dev->name, sizeof(name));
-	else
-		snprintf(name, sizeof(name), "%s_representor_%u",
-			 dpdk_dev->name, switch_info->port_name);
 	DRV_LOG(DEBUG, "naming Ethernet device \"%s\"", name);
 	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
 		eth_dev = rte_eth_dev_attach_secondary(name);
@@ -1298,9 +1305,6 @@  struct mlx5_dev_spawn_data {
 	assert(pci_drv == &mlx5_driver);
 	errno = 0;
 
-	if (rte_dev_is_probed(&pci_dev->device))
-		return -EEXIST;
-
 	ibv_list = mlx5_glue->get_device_list(&ret);
 	if (!ibv_list) {
 		rte_errno = errno ? errno : ENOSYS;
@@ -1412,7 +1416,7 @@  struct mlx5_dev_spawn_data {
 		if (!list[i].eth_dev) {
 			if (rte_errno != EBUSY)
 				break;
-			/* Device is disabled, ignore it. */
+			/* Device is disabled or already spawned. Ignore it. */
 			continue;
 		}
 		restore = list[i].eth_dev->data->dev_flags;