From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 706431B42D for ; Wed, 11 Jul 2018 11:27:06 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (uk.solarflare.com [193.34.186.16]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1-us3.ppe-hosted.com (Proofpoint Essentials ESMTP Server) with ESMTPS id F3113B40056; Wed, 11 Jul 2018 09:27:04 +0000 (UTC) Received: from [192.168.1.16] (85.187.13.33) by ukex01.SolarFlarecom.com (10.17.10.4) with Microsoft SMTP Server (TLS) id 15.0.1044.25; Wed, 11 Jul 2018 10:26:57 +0100 To: Qi Zhang , , CC: , , , , , References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180711030917.181098-1-qi.z.zhang@intel.com> <20180711030917.181098-2-qi.z.zhang@intel.com> From: Andrew Rybchenko Message-ID: <0a0c7b4a-3f7d-8b5e-3e76-8b631edd1997@solarflare.com> Date: Wed, 11 Jul 2018 12:26:51 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180711030917.181098-2-qi.z.zhang@intel.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [85.187.13.33] X-ClientProxiedBy: ocex03.SolarFlarecom.com (10.20.40.36) To ukex01.SolarFlarecom.com (10.17.10.4) X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.100.1062-23960.003 X-TM-AS-Result: No--12.478800-0.000000-31 X-TM-AS-User-Approved-Sender: Yes X-TM-AS-User-Blocked-Sender: No X-MDID: 1531301225-6b8YHwi07Hkn Subject: Re: [dpdk-dev] [PATCH v11 01/19] ethdev: add function to release port in local process X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Jul 2018 09:27:06 -0000 On 11.07.2018 06:08, Qi Zhang wrote: > Add driver API rte_eth_release_port_private 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 > Reviewed-by: Andrew Rybchenko > Acked-by: Remy Horton > --- > lib/librte_ethdev/rte_ethdev.c | 12 ++++++++++++ > lib/librte_ethdev/rte_ethdev_driver.h | 16 +++++++++++++++- > lib/librte_ethdev/rte_ethdev_pci.h | 8 ++++++++ > 3 files changed, 35 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c > index a9977df97..52a97694c 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) > diff --git a/lib/librte_ethdev/rte_ethdev_driver.h b/lib/librte_ethdev/rte_ethdev_driver.h > index c9c825e3f..269586d88 100644 > --- a/lib/librte_ethdev/rte_ethdev_driver.h > +++ b/lib/librte_ethdev/rte_ethdev_driver.h > @@ -62,7 +62,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 > */ > @@ -70,6 +70,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_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..a46d9e182 100644 > --- a/lib/librte_ethdev/rte_ethdev_pci.h > +++ b/lib/librte_ethdev/rte_ethdev_pci.h > @@ -197,6 +197,14 @@ rte_eth_dev_pci_generic_remove(struct rte_pci_device *pci_dev, > if (!eth_dev) > return -ENODEV; > > + /** > + * PCI device can only be globally detached directly by a > + * primary process. In secondary process, we only need to > + * release port. > + */ > + if (rte_eal_process_type() != RTE_PROC_PRIMARY) > + return rte_eth_dev_release_port_private(eth_dev); I've realized that some uninit functions which will not be called anymore in secondary processes have check for process type and handling of secondary process case. It makes code inconsistent and should be fixed. > + > if (dev_uninit) { > ret = dev_uninit(eth_dev); > if (ret)