[dpdk-dev] [PATCH v14 1/6] ethdev: add function to release port in secondary process

Zhang, Qi Z qi.z.zhang at intel.com
Wed Aug 15 02:17:20 CEST 2018


Thanks for the capture, will fix in v15.

> -----Original Message-----
> From: Andrew Rybchenko [mailto:arybchenko at solarflare.com]
> Sent: Sunday, August 12, 2018 7:05 PM
> To: Zhang, Qi Z <qi.z.zhang at intel.com>; thomas at monjalon.net;
> gaetan.rivet at 6wind.com; Burakov, Anatoly <anatoly.burakov at intel.com>
> Cc: Ananyev, Konstantin <konstantin.ananyev at intel.com>; dev at dpdk.org;
> Richardson, Bruce <bruce.richardson at intel.com>; Yigit, Ferruh
> <ferruh.yigit at intel.com>; Shelton, Benjamin H
> <benjamin.h.shelton at intel.com>; Vangati, Narender
> <narender.vangati at intel.com>
> Subject: Re: [dpdk-dev] [PATCH v14 1/6] ethdev: add function to release port
> in secondary process
> 
> On 10.08.2018 03:42, Qi Zhang wrote:
> > Add driver API rte_eth_release_port_secondary to support the case when
> > an ethdev need to be detached on a secondary process.
> > Local state is set to unused and shared data will not be reset so the
> > primary process can still use it.
> >
> > Signed-off-by: Qi Zhang <qi.z.zhang at intel.com>
> > ---
> >   lib/librte_ethdev/rte_ethdev.c           | 21
> ++++++++++++++++++---
> >   lib/librte_ethdev/rte_ethdev_driver.h    | 16 +++++++++++++++-
> >   lib/librte_ethdev/rte_ethdev_pci.h       |  9 +++++++--
> >   lib/librte_ethdev/rte_ethdev_version.map |  7 +++++++
> >   4 files changed, 47 insertions(+), 6 deletions(-)
> >
> > diff --git a/lib/librte_ethdev/rte_ethdev.c
> > b/lib/librte_ethdev/rte_ethdev.c index 4c3202505..c653bf5fa 100644
> > --- a/lib/librte_ethdev/rte_ethdev.c
> > +++ b/lib/librte_ethdev/rte_ethdev.c
> 
> <...>
> 
> > @@ -3532,10 +3544,13 @@ rte_eth_dev_destroy(struct rte_eth_dev
> *ethdev,
> >   			return ret;
> >   	}
> >
> > -	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> > -		rte_free(ethdev->data->dev_private);
> > +	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
> > +		return rte_eth_dev_release_port_secondary(ethdev);
> >
> > -	ethdev->data->dev_private = NULL;
> > +	if (ethdev->data->dev_private != NULL) {
> 
> The check is not necessary, rte_free() perfectly works with NULL.
> 
> > +		rte_free(ethdev->data->dev_private);
> > +		ethdev->data->dev_private = NULL;
> > +	}
> >
> >   	return rte_eth_dev_release_port(ethdev);
> >   }
> > diff --git a/lib/librte_ethdev/rte_ethdev_driver.h
> > b/lib/librte_ethdev/rte_ethdev_driver.h
> > index c6d9bc1a3..8fe82d2ab 100644
> > --- a/lib/librte_ethdev/rte_ethdev_driver.h
> > +++ b/lib/librte_ethdev/rte_ethdev_driver.h
> > @@ -61,7 +61,7 @@ struct rte_eth_dev
> *rte_eth_dev_attach_secondary(const char *name);
> >    * Release the specified ethdev port.
> >    *
> >    * @param eth_dev
> > - * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
> > + * Device to be detached.
> >    * @return
> >    *   - 0 on success, negative on error
> >    */
> > @@ -69,6 +69,20 @@ int rte_eth_dev_release_port(struct rte_eth_dev
> > *eth_dev);
> >
> >   /**
> >    * @internal
> > + * Release the specified ethdev port in the local process.
> > + * Only set ethdev state to unused, but not reset shared data since
> > + * it assume other processes is still using it. typically it is
> > + * called by a secondary process.
> > + *
> > + * @param eth_dev
> > + * Device to be detached.
> > + * @return
> > + *   - 0 on success, negative on error
> > + */
> > +int rte_eth_dev_release_port_secondary(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 f652596f4..c22022e4f 100644
> > --- a/lib/librte_ethdev/rte_ethdev_pci.h
> > +++ b/lib/librte_ethdev/rte_ethdev_pci.h
> > @@ -135,9 +135,14 @@ rte_eth_dev_pci_allocate(struct rte_pci_device
> *dev, size_t private_data_size)
> >   static inline void
> >   rte_eth_dev_pci_release(struct rte_eth_dev *eth_dev)
> >   {@@ -359,6 +359,18 @@ rte_eth_dev_attach_secondary(const char
> *name)
> >   }
> >
> >   int
> > +rte_eth_dev_release_port_secondary(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)
> >
> >
> > -	if (rte_eal_process_type() == RTE_PROC_PRIMARY)
> > -		rte_free(eth_dev->data->dev_private);
> > +	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
> > +		eth_dev->device = NULL;
> > +		eth_dev->intr_handle = NULL;
> > +		rte_eth_dev_release_port_secondary(eth_dev);
> 
> Is return missing here. Below comment pretends that it is primary process
> code.
> 
> > +	}
> >
> > +	/* primary process */
> > +	rte_free(eth_dev->data->dev_private);
> >   	eth_dev->data->dev_private = NULL;
> >
> >   	/*
> > diff --git a/lib/librte_ethdev/rte_ethdev_version.map
> > b/lib/librte_ethdev/rte_ethdev_version.map
> > index 38f117f01..acc407f86 100644
> > --- a/lib/librte_ethdev/rte_ethdev_version.map
> > +++ b/lib/librte_ethdev/rte_ethdev_version.map
> > @@ -220,6 +220,13 @@ DPDK_18.08 {
> >
> >   } DPDK_18.05;
> >
> > +DPDK_18.11 {
> > +	global:
> > +
> > +	rte_eth_dev_release_port_secondary;
> > +
> > +} DPDK_18.08;
> > +
> >   EXPERIMENTAL {
> >   	global:
> >



More information about the dev mailing list