DPDK patches and discussions
 help / color / mirror / Atom feed
From: Xiaolong Ye <xiaolong.ye@intel.com>
To: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>,
	Thomas Monjalon <thomas@monjalon.net>
Cc: Xiaolong Ye <xiaolong.ye@intel.com>
Subject: [dpdk-dev] [PATCH v1 1/2] net/af_xdp: remove resources when port is closed
Date: Fri, 26 Apr 2019 13:09:11 +0800	[thread overview]
Message-ID: <20190426050912.109813-2-xiaolong.ye@intel.com> (raw)
Message-ID: <20190426050911.3UbH-QOx__mxB0ZNKF6ma7XURAZtzqnA0Rrtd1QteOs@z> (raw)
In-Reply-To: <20190426050912.109813-1-xiaolong.ye@intel.com>

Since 18.11, it is suggested that driver should release all its private
resources at the dev_close routine. So all resources previously released
in remove routine are now released at the dev_close routine, and the
dev_close routine will be called in driver remove routine in order to
support removing a device without closing its ports.

Above behavior changes are supported by setting RTE_ETH_DEV_CLOSE_REMOVE
flag during probe stage.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 41 +++++++++++++----------------
 1 file changed, 19 insertions(+), 22 deletions(-)

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index acf9ad605..a12551cbf 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -426,6 +426,19 @@ remove_xdp_program(struct pmd_internals *internals)
 			XDP_FLAGS_UPDATE_IF_NOEXIST);
 }
 
+static void
+xdp_umem_destroy(struct xsk_umem_info *umem)
+{
+	rte_memzone_free(umem->mz);
+	umem->mz = NULL;
+
+	rte_ring_free(umem->buf_ring);
+	umem->buf_ring = NULL;
+
+	rte_free(umem);
+	umem = NULL;
+}
+
 static void
 eth_dev_close(struct rte_eth_dev *dev)
 {
@@ -444,6 +457,9 @@ eth_dev_close(struct rte_eth_dev *dev)
 	}
 
 	(void)xsk_umem__delete(internals->umem->umem);
+
+	xdp_umem_destroy(internals->umem);
+
 	remove_xdp_program(internals);
 }
 
@@ -459,19 +475,6 @@ eth_link_update(struct rte_eth_dev *dev __rte_unused,
 	return 0;
 }
 
-static void
-xdp_umem_destroy(struct xsk_umem_info *umem)
-{
-	rte_memzone_free(umem->mz);
-	umem->mz = NULL;
-
-	rte_ring_free(umem->buf_ring);
-	umem->buf_ring = NULL;
-
-	rte_free(umem);
-	umem = NULL;
-}
-
 static struct
 xsk_umem_info *xdp_umem_configure(struct pmd_internals *internals)
 {
@@ -856,6 +859,8 @@ init_internals(struct rte_vdev_device *dev,
 	eth_dev->dev_ops = &ops;
 	eth_dev->rx_pkt_burst = eth_af_xdp_rx;
 	eth_dev->tx_pkt_burst = eth_af_xdp_tx;
+	/* Let rte_eth_dev_close() release the port resources. */
+	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
 
 	return eth_dev;
 
@@ -923,7 +928,6 @@ static int
 rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
 {
 	struct rte_eth_dev *eth_dev = NULL;
-	struct pmd_internals *internals;
 
 	AF_XDP_LOG(INFO, "Removing AF_XDP ethdev on numa socket %u\n",
 		rte_socket_id());
@@ -936,14 +940,7 @@ rte_pmd_af_xdp_remove(struct rte_vdev_device *dev)
 	if (eth_dev == NULL)
 		return -1;
 
-	internals = eth_dev->data->dev_private;
-
-	rte_ring_free(internals->umem->buf_ring);
-	rte_memzone_free(internals->umem->mz);
-	rte_free(internals->umem);
-
-	rte_eth_dev_release_port(eth_dev);
-
+	eth_dev_close(eth_dev);
 
 	return 0;
 }
-- 
2.17.1


  parent reply	other threads:[~2019-04-26  5:15 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-26  5:09 [dpdk-dev] [PATCH v1 0/2] support RTE_ETH_DEV_CLOSE_REMOVE flag for AF_XDP Xiaolong Ye
2019-04-26  5:09 ` Xiaolong Ye
2019-04-26  5:09 ` Xiaolong Ye [this message]
2019-04-26  5:09   ` [dpdk-dev] [PATCH v1 1/2] net/af_xdp: remove resources when port is closed Xiaolong Ye
2019-04-29 17:00   ` Ferruh Yigit
2019-04-29 17:00     ` Ferruh Yigit
2019-04-29 20:14     ` Thomas Monjalon
2019-04-29 20:14       ` Thomas Monjalon
2019-04-29 22:28       ` Ferruh Yigit
2019-04-29 22:28         ` Ferruh Yigit
2019-04-29 22:34         ` Thomas Monjalon
2019-04-29 22:34           ` Thomas Monjalon
2019-04-30  7:33           ` Ferruh Yigit
2019-04-30  7:33             ` Ferruh Yigit
2019-04-30  7:55             ` Thomas Monjalon
2019-04-30  7:55               ` Thomas Monjalon
2019-04-30  8:10               ` Ferruh Yigit
2019-04-30  8:10                 ` Ferruh Yigit
2019-04-30  2:06     ` Ye Xiaolong
2019-04-30  2:06       ` Ye Xiaolong
2019-04-30  7:35       ` Ferruh Yigit
2019-04-30  7:35         ` Ferruh Yigit
2019-04-30  8:37         ` Ye Xiaolong
2019-04-30  8:37           ` Ye Xiaolong
2019-04-26  5:09 ` [dpdk-dev] [PATCH v1 2/2] net/af_xdp: set MAC addrs field to NULL Xiaolong Ye
2019-04-26  5:09   ` Xiaolong Ye
2019-04-29 17:02   ` Ferruh Yigit
2019-04-29 17:02     ` Ferruh Yigit
2019-04-30  2:04     ` Ye Xiaolong
2019-04-30  2:04       ` Ye Xiaolong
2019-04-30  8:39 ` [dpdk-dev] [PATCH v3] net/af_xdp: remove resources when port is closed Xiaolong Ye
2019-04-30  8:39   ` Xiaolong Ye
2019-04-30 11:02   ` Ferruh Yigit
2019-04-30 11:02     ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190426050912.109813-2-xiaolong.ye@intel.com \
    --to=xiaolong.ye@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).