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 8CD241B1B9 for ; Thu, 7 Jun 2018 14:38:28 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Jun 2018 05:38:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,486,1520924400"; d="scan'208";a="62605530" Received: from dpdk51.sh.intel.com ([10.67.110.184]) by orsmga001.jf.intel.com with ESMTP; 07 Jun 2018 05:38:26 -0700 From: Qi Zhang To: thomas@monjalon.net, anatoly.burakov@intel.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: Thu, 7 Jun 2018 20:38:30 +0800 Message-Id: <20180607123849.14439-4-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180607123849.14439-1-qi.z.zhang@intel.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH 03/22] 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: Thu, 07 Jun 2018 12:38:29 -0000 Add driver API rte_eth_release_port_local 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 --- lib/librte_ethdev/rte_ethdev.c | 24 +++++++++++++++++++++--- lib/librte_ethdev/rte_ethdev_driver.h | 13 +++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index cd4bfd3c6..ec14adb91 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -359,6 +359,23 @@ rte_eth_dev_attach_secondary(const char *name) } int +rte_eth_dev_release_port_local(struct rte_eth_dev *eth_dev) +{ + if (eth_dev == NULL) + return -EINVAL; + + _rte_eth_dev_callback_process(eth_dev, RTE_ETH_EVENT_DESTROY, NULL); + + rte_spinlock_lock(&rte_eth_dev_shared_data->ownership_lock); + + eth_dev->state = RTE_ETH_DEV_UNUSED; + + rte_spinlock_unlock(&rte_eth_dev_shared_data->ownership_lock); + + return 0; +} + +int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev) { if (eth_dev == NULL) @@ -370,9 +387,10 @@ 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)); + if (eth_dev->state != RTE_ETH_DEV_UNUSED) { + 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..261335426 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_local(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. * -- 2.13.6