[v3,15/23] net/failsafe: enable port detach on secondary process

Message ID 20180625071745.16810-16-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Headers
Series enable hotplug on multi-process |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Qi Zhang June 25, 2018, 7:17 a.m. UTC
  Previously, detach port on secondary process will mess primary
process and cause same device can't be attached again, by take
advantage of rte_eth_release_port_private, we can support this
with minor change.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/failsafe/failsafe.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
  

Comments

Matan Azrad June 27, 2018, 8:28 a.m. UTC | #1
Hi Qi

From: Qi Zhang
> Previously, detach port on secondary process will mess primary process and
> cause same device can't be attached again, by take advantage of
> rte_eth_release_port_private, we can support this with minor change.
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>

Failsafe doesn't support secondary process,
I don't think we need this adjustment for drivers which don't support secondary process.
 
> ---
>  drivers/net/failsafe/failsafe.c | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c index
> eafbb75df..c5e8651f6 100644
> --- a/drivers/net/failsafe/failsafe.c
> +++ b/drivers/net/failsafe/failsafe.c
> @@ -328,6 +328,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
>  		}
>  		/* TODO: request info from primary to set up Rx and Tx */
>  		eth_dev->dev_ops = &failsafe_ops;
> +		eth_dev->device = &vdev->device;
>  		rte_eth_dev_probing_finish(eth_dev);
>  		return 0;
>  	}
> @@ -338,10 +339,25 @@ rte_pmd_failsafe_probe(struct rte_vdev_device
> *vdev)  static int  rte_pmd_failsafe_remove(struct rte_vdev_device *vdev)  {
> +	struct rte_eth_dev *eth_dev;
>  	const char *name;
> 
>  	name = rte_vdev_device_name(vdev);
>  	INFO("Uninitializing " FAILSAFE_DRIVER_NAME " for %s", name);
> +
> +	eth_dev = rte_eth_dev_allocated(name);
> +	if (!eth_dev)
> +		return -ENODEV;
> +	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
> +		/* detach device on local pprocess only */
> +		if (strlen(rte_vdev_device_args(vdev)) == 0)
> +			return rte_eth_dev_release_port_private(eth_dev);
> +		/**
> +		 * else this is a private device for current process
> +		 * so continue with normal detach scenario.
> +		 */
> +	}
> +
>  	return fs_rte_eth_free(name);
>  }
> 
> --
> 2.13.6
  
Qi Zhang June 27, 2018, 8:34 a.m. UTC | #2
> -----Original Message-----
> From: Matan Azrad [mailto:matan@mellanox.com]
> Sent: Wednesday, June 27, 2018 4:29 PM
> To: Zhang, Qi Z <qi.z.zhang@intel.com>; Thomas Monjalon
> <thomas@monjalon.net>; Burakov, Anatoly <anatoly.burakov@intel.com>
> Cc: Ananyev, Konstantin <konstantin.ananyev@intel.com>; dev@dpdk.org;
> Richardson, Bruce <bruce.richardson@intel.com>; Yigit, Ferruh
> <ferruh.yigit@intel.com>; Shelton, Benjamin H
> <benjamin.h.shelton@intel.com>; Vangati, Narender
> <narender.vangati@intel.com>
> Subject: RE: [dpdk-dev] [PATCH v3 15/23] net/failsafe: enable port detach on
> secondary process
> 
> Hi Qi
> 
> From: Qi Zhang
> > Previously, detach port on secondary process will mess primary process
> > and cause same device can't be attached again, by take advantage of
> > rte_eth_release_port_private, we can support this with minor change.
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> 
> Failsafe doesn't support secondary process, I don't think we need this
> adjustment for drivers which don't support secondary process.

Sure, I can remove this, thanks for the information.

Regards
Qi

> 
> > ---
> >  drivers/net/failsafe/failsafe.c | 16 ++++++++++++++++
> >  1 file changed, 16 insertions(+)
> >
> > diff --git a/drivers/net/failsafe/failsafe.c
> > b/drivers/net/failsafe/failsafe.c index
> > eafbb75df..c5e8651f6 100644
> > --- a/drivers/net/failsafe/failsafe.c
> > +++ b/drivers/net/failsafe/failsafe.c
> > @@ -328,6 +328,7 @@ rte_pmd_failsafe_probe(struct rte_vdev_device
> *vdev)
> >  		}
> >  		/* TODO: request info from primary to set up Rx and Tx */
> >  		eth_dev->dev_ops = &failsafe_ops;
> > +		eth_dev->device = &vdev->device;
> >  		rte_eth_dev_probing_finish(eth_dev);
> >  		return 0;
> >  	}
> > @@ -338,10 +339,25 @@ rte_pmd_failsafe_probe(struct rte_vdev_device
> > *vdev)  static int  rte_pmd_failsafe_remove(struct rte_vdev_device
> > *vdev)  {
> > +	struct rte_eth_dev *eth_dev;
> >  	const char *name;
> >
> >  	name = rte_vdev_device_name(vdev);
> >  	INFO("Uninitializing " FAILSAFE_DRIVER_NAME " for %s", name);
> > +
> > +	eth_dev = rte_eth_dev_allocated(name);
> > +	if (!eth_dev)
> > +		return -ENODEV;
> > +	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
> > +		/* detach device on local pprocess only */
> > +		if (strlen(rte_vdev_device_args(vdev)) == 0)
> > +			return rte_eth_dev_release_port_private(eth_dev);
> > +		/**
> > +		 * else this is a private device for current process
> > +		 * so continue with normal detach scenario.
> > +		 */
> > +	}
> > +
> >  	return fs_rte_eth_free(name);
> >  }
> >
> > --
> > 2.13.6
  

Patch

diff --git a/drivers/net/failsafe/failsafe.c b/drivers/net/failsafe/failsafe.c
index eafbb75df..c5e8651f6 100644
--- a/drivers/net/failsafe/failsafe.c
+++ b/drivers/net/failsafe/failsafe.c
@@ -328,6 +328,7 @@  rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
 		}
 		/* TODO: request info from primary to set up Rx and Tx */
 		eth_dev->dev_ops = &failsafe_ops;
+		eth_dev->device = &vdev->device;
 		rte_eth_dev_probing_finish(eth_dev);
 		return 0;
 	}
@@ -338,10 +339,25 @@  rte_pmd_failsafe_probe(struct rte_vdev_device *vdev)
 static int
 rte_pmd_failsafe_remove(struct rte_vdev_device *vdev)
 {
+	struct rte_eth_dev *eth_dev;
 	const char *name;
 
 	name = rte_vdev_device_name(vdev);
 	INFO("Uninitializing " FAILSAFE_DRIVER_NAME " for %s", name);
+
+	eth_dev = rte_eth_dev_allocated(name);
+	if (!eth_dev)
+		return -ENODEV;
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		/* detach device on local pprocess only */
+		if (strlen(rte_vdev_device_args(vdev)) == 0)
+			return rte_eth_dev_release_port_private(eth_dev);
+		/**
+		 * else this is a private device for current process
+		 * so continue with normal detach scenario.
+		 */
+	}
+
 	return fs_rte_eth_free(name);
 }