From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 0F21D1B11C for ; Fri, 28 Sep 2018 06:22:52 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2018 21:22:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,313,1534834800"; d="scan'208";a="266654779" Received: from dpdk51.sh.intel.com ([10.67.110.190]) by fmsmga005.fm.intel.com with ESMTP; 27 Sep 2018 21:22:28 -0700 From: Qi Zhang To: thomas@monjalon.net, gaetan.rivet@6wind.com, anatoly.burakov@intel.com, arybchenko@solarflare.com Cc: konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, benjamin.h.shelton@intel.com, narender.vangati@intel.com, Qi Zhang Date: Fri, 28 Sep 2018 12:23:21 +0800 Message-Id: <20180928042326.50471-2-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180928042326.50471-1-qi.z.zhang@intel.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180928042326.50471-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v16 1/6] ethdev: add function to release port in secondary 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: Fri, 28 Sep 2018 04:22:53 -0000 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 --- lib/librte_ethdev/rte_ethdev.c | 17 +++++++++++++++-- lib/librte_ethdev/rte_ethdev_driver.h | 16 +++++++++++++++- lib/librte_ethdev/rte_ethdev_pci.h | 10 ++++++++-- lib/librte_ethdev/rte_ethdev_version.map | 7 +++++++ 4 files changed, 45 insertions(+), 5 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index aa7730ce2..c58b1c6ed 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -360,6 +360,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) @@ -3540,9 +3552,10 @@ 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); + 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 f158462a0..ca31b5777 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..70d2d2503 100644 --- a/lib/librte_ethdev/rte_ethdev_pci.h +++ b/lib/librte_ethdev/rte_ethdev_pci.h @@ -135,9 +135,15 @@ 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) { - 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); + return; + } + /* 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: -- 2.13.6