From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 383D9A0096 for ; Wed, 5 Jun 2019 11:43:49 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 189CD1B9CE; Wed, 5 Jun 2019 11:43:48 +0200 (CEST) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 797401B9AD for ; Wed, 5 Jun 2019 11:43:46 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Jun 2019 02:43:45 -0700 X-ExtLoop1: 1 Received: from npg-dpdk-virtio-tbie-2.sh.intel.com ([10.67.104.151]) by orsmga006.jf.intel.com with ESMTP; 05 Jun 2019 02:43:44 -0700 From: Tiwei Bie To: maxime.coquelin@redhat.com, zhihong.wang@intel.com, dev@dpdk.org Date: Wed, 5 Jun 2019 17:42:32 +0800 Message-Id: <20190605094232.16840-1-tiwei.bie@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/vhost: release port upon close 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Set RTE_ETH_DEV_CLOSE_REMOVE upon probe so all the private resources for the port can be freed by rte_eth_dev_close(). Signed-off-by: Tiwei Bie --- drivers/net/vhost/rte_eth_vhost.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/net/vhost/rte_eth_vhost.c b/drivers/net/vhost/rte_eth_vhost.c index 774774b94..0b61e37a1 100644 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -1005,6 +1005,9 @@ eth_dev_close(struct rte_eth_dev *dev) rte_free(internal); dev->data->dev_private = NULL; + + rte_free(vring_states[dev->data->port_id]); + vring_states[dev->data->port_id] = NULL; } static int @@ -1261,7 +1264,7 @@ eth_dev_vhost_create(struct rte_vdev_device *dev, char *iface_name, internal->max_queues = queues; internal->vid = -1; data->dev_link = pmd_link; - data->dev_flags = RTE_ETH_DEV_INTR_LSC; + data->dev_flags = RTE_ETH_DEV_INTR_LSC | RTE_ETH_DEV_CLOSE_REMOVE; eth_dev->dev_ops = &ops; @@ -1442,16 +1445,13 @@ rte_pmd_vhost_remove(struct rte_vdev_device *dev) /* find an ethdev entry */ eth_dev = rte_eth_dev_allocated(name); if (eth_dev == NULL) - return -ENODEV; + return 0; if (rte_eal_process_type() != RTE_PROC_PRIMARY) return rte_eth_dev_release_port(eth_dev); eth_dev_close(eth_dev); - rte_free(vring_states[eth_dev->data->port_id]); - vring_states[eth_dev->data->port_id] = NULL; - rte_eth_dev_release_port(eth_dev); return 0; -- 2.17.1