[v7,01/19] ethdev: add function to release port in local process

Message ID 20180628125708.39610-2-qi.z.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
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 28, 2018, 12:56 p.m. UTC
  Add driver API rte_eth_release_port_private to support the
requirement that an ethdev only be released on secondary process,
so only local state be set to unused , share data will not be
reset so primary process can still use it.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
Acked-by: Remy Horton <remy.horton@intel.com>
---
 lib/librte_ethdev/rte_ethdev.c        | 13 ++++++++++++-
 lib/librte_ethdev/rte_ethdev_driver.h | 13 +++++++++++++
 lib/librte_ethdev/rte_ethdev_pci.h    |  3 +++
 3 files changed, 28 insertions(+), 1 deletion(-)
  

Comments

Andrew Rybchenko June 28, 2018, 2:34 p.m. UTC | #1
On 06/28/2018 03:56 PM, Qi Zhang wrote:
> Add driver API rte_eth_release_port_private to support the
> requirement that an ethdev only be released on secondary process,
> so only local state be set to unused , share data will not be

Extra space before comma above.

> reset so primary process can still use it.
>
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> Acked-by: Remy Horton <remy.horton@intel.com>
> ---
>   lib/librte_ethdev/rte_ethdev.c        | 13 ++++++++++++-
>   lib/librte_ethdev/rte_ethdev_driver.h | 13 +++++++++++++
>   lib/librte_ethdev/rte_ethdev_pci.h    |  3 +++
>   3 files changed, 28 insertions(+), 1 deletion(-)
>
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index a9977df97..2353fc921 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c

<...>

> @@ -371,7 +383,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
>   	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
>   
>   	eth_dev->state = RTE_ETH_DEV_UNUSED;
> -
>   	memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
>   
>   	rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);

Just a nit: above looks like unrelated change.

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
  
Qi Zhang June 28, 2018, 11:55 p.m. UTC | #2
From: Andrew Rybchenko [mailto:arybchenko@solarflare.com]
Sent: Thursday, June 28, 2018 10:34 PM
To: Zhang, Qi Z <qi.z.zhang@intel.com>; 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 v7 01/19] ethdev: add function to release port in local process

On 06/28/2018 03:56 PM, Qi Zhang wrote:

Add driver API rte_eth_release_port_private to support the

requirement that an ethdev only be released on secondary process,

so only local state be set to unused , share data will not be

Extra space before comma above.



reset so primary process can still use it.



Signed-off-by: Qi Zhang <qi.z.zhang@intel.com><mailto:qi.z.zhang@intel.com>

Acked-by: Remy Horton <remy.horton@intel.com><mailto:remy.horton@intel.com>

---

 lib/librte_ethdev/rte_ethdev.c        | 13 ++++++++++++-

 lib/librte_ethdev/rte_ethdev_driver.h | 13 +++++++++++++

 lib/librte_ethdev/rte_ethdev_pci.h    |  3 +++

 3 files changed, 28 insertions(+), 1 deletion(-)



diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c

index a9977df97..2353fc921 100644

--- a/lib/librte_ethdev/rte_ethdev.c

+++ b/lib/librte_ethdev/rte_ethdev.c

<...>



@@ -371,7 +383,6 @@ rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)

        rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);



        eth_dev->state = RTE_ETH_DEV_UNUSED;

-

        memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));



        rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);

Just a nit: above looks like unrelated change.

Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com><mailto:arybchenko@solarflare.com>

will fix both issue in v8.
Thanks,
Qi
  

Patch

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index a9977df97..2353fc921 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -359,6 +359,18 @@  rte_eth_dev_attach_secondary(const char *name)
 }
 
 int
+rte_eth_dev_release_port_private(struct rte_eth_dev *eth_dev)
+{
+	if (eth_dev == NULL)
+		return -EINVAL;
+
+	_rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL);
+	eth_dev->state = RTE_ETH_DEV_UNUSED;
+
+	return 0;
+}
+
+int
 rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 {
 	if (eth_dev == NULL)
@@ -371,7 +383,6 @@  rte_eth_dev_release_port(struct rte_eth_dev *eth_dev)
 	rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock);
 
 	eth_dev->state = RTE_ETH_DEV_UNUSED;
-
 	memset(eth_dev->data, 0, sizeof(struct rte_eth_dev_data));
 
 	rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock);
diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h
index c9c825e3f..49c27223d 100644
--- a/lib/librte_ethdev/rte_ethdev_driver.h
+++ b/lib/librte_ethdev/rte_ethdev_driver.h
@@ -70,6 +70,19 @@  int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
 
 /**
  * @internal
+ * Release the specified ethdev port in local process, only set to ethdev
+ * state to unused, but not reset share data since it assume other process
+ * is still using it, typically it is called by secondary process.
+ *
+ * @param eth_dev
+ * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
+ * @return
+ *   - 0 on success, negative on error
+ */
+int rte_eth_dev_release_port_private(struct rte_eth_dev *eth_dev);
+
+/**
+ * @internal
  * Release device queues and clear its configuration to force the user
  * application to reconfigure it. It is for internal use only.
  *
diff --git a/lib/librte_ethdev/rte_ethdev_pci.h b/lib/librte_ethdev/rte_ethdev_pci.h
index 2cfd37274..eeb944146 100644
--- a/lib/librte_ethdev/rte_ethdev_pci.h
+++ b/lib/librte_ethdev/rte_ethdev_pci.h
@@ -197,6 +197,9 @@  rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev,
 	if (!eth_dev)
 		return -ENODEV;
 
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+		return rte_eth_dev_release_port_private(eth_dev);
+
 	if (dev_uninit) {
 		ret = dev_uninit(eth_dev);
 		if (ret)