[dpdk-dev,v2,09/12] ethdev: support attach vdev in secondary process

Message ID 1506606959-76230-10-git-send-email-jianfeng.tan@intel.com (mailing list archive)
State Superseded, archived
Headers

Checks

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

Commit Message

Jianfeng Tan Sept. 28, 2017, 1:55 p.m. UTC
  When vdev driver requests an ethdev entry in secondary process,
we will identify the correct entry in rte_eth_dev_data array
and return the correct entry in the rte_eth_devices arrays.

Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
---
 lib/librte_ether/rte_ethdev_vdev.h | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)
  

Comments

Jan Blunck Oct. 5, 2017, 2:26 p.m. UTC | #1
On Thu, Sep 28, 2017 at 3:55 PM, Jianfeng Tan <jianfeng.tan@intel.com> wrote:
> When vdev driver requests an ethdev entry in secondary process,
> we will identify the correct entry in rte_eth_dev_data array
> and return the correct entry in the rte_eth_devices arrays.
>
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  lib/librte_ether/rte_ethdev_vdev.h | 26 +++++++++++++++-----------
>  1 file changed, 15 insertions(+), 11 deletions(-)
>
> diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
> index 4d2c3e2..460749b 100644
> --- a/lib/librte_ether/rte_ethdev_vdev.h
> +++ b/lib/librte_ether/rte_ethdev_vdev.h
> @@ -58,25 +58,29 @@ rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
>         struct rte_eth_dev *eth_dev;
>         const char *name = rte_vdev_device_name(dev);
>
> -       eth_dev = rte_eth_dev_allocate(name);
> -       if (!eth_dev)
> -               return NULL;
> -
> -       if (private_data_size) {
> -               eth_dev->data->dev_private = rte_zmalloc_socket(name,
> -                       private_data_size, RTE_CACHE_LINE_SIZE,
> -                       dev->device.numa_node);
> -               if (!eth_dev->data->dev_private) {
> -                       rte_eth_dev_release_port(eth_dev);
> +       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
> +               eth_dev = rte_eth_dev_allocate(name);
> +               if (!eth_dev)
>                         return NULL;
> +
> +               if (private_data_size) {
> +                       eth_dev->data->dev_private = rte_zmalloc_socket(name,
> +                                       private_data_size, RTE_CACHE_LINE_SIZE,
> +                                       dev->device.numa_node);
> +                       if (!eth_dev->data->dev_private) {
> +                               rte_eth_dev_release_port(eth_dev);
> +                               return NULL;
> +                       }
>                 }
> +       } else {
> +               eth_dev = rte_eth_dev_attach_secondary(name);

I don't see the point why the secondary process should call
rte_eth_vdev_allocate() in the first place. The driver needs to setup
the IPC anyway so it should just call rte_eth_dev_attach_secondary()
instead.


>         }
>
>         eth_dev->device = &dev->device;
>         eth_dev->intr_handle = NULL;
> -
>         eth_dev->data->kdrv = RTE_KDRV_NONE;
>         eth_dev->data->numa_node = dev->device.numa_node;
> +
>         return eth_dev;
>  }
>
> --
> 2.7.4
>
  
Jianfeng Tan Oct. 9, 2017, 12:56 a.m. UTC | #2
Hi Jan,

> -----Original Message-----

> From: jblunck@gmail.com [mailto:jblunck@gmail.com] On Behalf Of Jan

> Blunck

> Sent: Thursday, October 5, 2017 10:27 PM

> To: Tan, Jianfeng

> Cc: dev; Richardson, Bruce; Ananyev, Konstantin; De Lara Guarch, Pablo;

> Thomas Monjalon; yliu@fridaylinux.org; Maxime Coquelin; Tetsuya Mukawa;

> Yigit, Ferruh

> Subject: Re: [dpdk-dev] [PATCH v2 09/12] ethdev: support attach vdev in

> secondary process

> 

> On Thu, Sep 28, 2017 at 3:55 PM, Jianfeng Tan <jianfeng.tan@intel.com>

> wrote:

> > When vdev driver requests an ethdev entry in secondary process,

> > we will identify the correct entry in rte_eth_dev_data array

> > and return the correct entry in the rte_eth_devices arrays.

> >

> > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>

> > ---

> >  lib/librte_ether/rte_ethdev_vdev.h | 26 +++++++++++++++-----------

> >  1 file changed, 15 insertions(+), 11 deletions(-)

> >

> > diff --git a/lib/librte_ether/rte_ethdev_vdev.h

> b/lib/librte_ether/rte_ethdev_vdev.h

> > index 4d2c3e2..460749b 100644

> > --- a/lib/librte_ether/rte_ethdev_vdev.h

> > +++ b/lib/librte_ether/rte_ethdev_vdev.h

> > @@ -58,25 +58,29 @@ rte_eth_vdev_allocate(struct rte_vdev_device

> *dev, size_t private_data_size)

> >         struct rte_eth_dev *eth_dev;

> >         const char *name = rte_vdev_device_name(dev);

> >

> > -       eth_dev = rte_eth_dev_allocate(name);

> > -       if (!eth_dev)

> > -               return NULL;

> > -

> > -       if (private_data_size) {

> > -               eth_dev->data->dev_private = rte_zmalloc_socket(name,

> > -                       private_data_size, RTE_CACHE_LINE_SIZE,

> > -                       dev->device.numa_node);

> > -               if (!eth_dev->data->dev_private) {

> > -                       rte_eth_dev_release_port(eth_dev);

> > +       if (rte_eal_process_type() == RTE_PROC_PRIMARY) {

> > +               eth_dev = rte_eth_dev_allocate(name);

> > +               if (!eth_dev)

> >                         return NULL;

> > +

> > +               if (private_data_size) {

> > +                       eth_dev->data->dev_private = rte_zmalloc_socket(name,

> > +                                       private_data_size, RTE_CACHE_LINE_SIZE,

> > +                                       dev->device.numa_node);

> > +                       if (!eth_dev->data->dev_private) {

> > +                               rte_eth_dev_release_port(eth_dev);

> > +                               return NULL;

> > +                       }

> >                 }

> > +       } else {

> > +               eth_dev = rte_eth_dev_attach_secondary(name);

> 

> I don't see the point why the secondary process should call

> rte_eth_vdev_allocate() in the first place. The driver needs to setup

> the IPC anyway so it should just call rte_eth_dev_attach_secondary()

> instead.

	
Hmm... make sense. Will fix it in the next version.

Thanks for the input.

Thanks,
Jianfeng
  

Patch

diff --git a/lib/librte_ether/rte_ethdev_vdev.h b/lib/librte_ether/rte_ethdev_vdev.h
index 4d2c3e2..460749b 100644
--- a/lib/librte_ether/rte_ethdev_vdev.h
+++ b/lib/librte_ether/rte_ethdev_vdev.h
@@ -58,25 +58,29 @@  rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
 	struct rte_eth_dev *eth_dev;
 	const char *name = rte_vdev_device_name(dev);
 
-	eth_dev = rte_eth_dev_allocate(name);
-	if (!eth_dev)
-		return NULL;
-
-	if (private_data_size) {
-		eth_dev->data->dev_private = rte_zmalloc_socket(name,
-			private_data_size, RTE_CACHE_LINE_SIZE,
-			dev->device.numa_node);
-		if (!eth_dev->data->dev_private) {
-			rte_eth_dev_release_port(eth_dev);
+	if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+		eth_dev = rte_eth_dev_allocate(name);
+		if (!eth_dev)
 			return NULL;
+
+		if (private_data_size) {
+			eth_dev->data->dev_private = rte_zmalloc_socket(name,
+					private_data_size, RTE_CACHE_LINE_SIZE,
+					dev->device.numa_node);
+			if (!eth_dev->data->dev_private) {
+				rte_eth_dev_release_port(eth_dev);
+				return NULL;
+			}
 		}
+	} else {
+		eth_dev = rte_eth_dev_attach_secondary(name);
 	}
 
 	eth_dev->device = &dev->device;
 	eth_dev->intr_handle = NULL;
-
 	eth_dev->data->kdrv = RTE_KDRV_NONE;
 	eth_dev->data->numa_node = dev->device.numa_node;
+
 	return eth_dev;
 }