DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] net/af_xdp: remove resources when port is closed
       [not found] <“20190426050912.109813-1-xiaolong.ye@intel.com”>
@ 2019-04-30  3:02 ` Xiaolong Ye
  2019-04-30  3:02   ` Xiaolong Ye
  0 siblings, 1 reply; 2+ messages in thread
From: Xiaolong Ye @ 2019-04-30  3:02 UTC (permalink / raw)
  To: dev, Ferruh Yigit, Thomas Monjalon; +Cc: Xiaolong Ye

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.

Also as af_xdp pmd doesn't allocate MAC addresses dynamically, it needs
to be set as NULL, so it won't be released by rte_eth_dev_release_port(),
otherwise, there would be "EAL: Error: Invalid memory" error.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
---

V2: merge previous 2 patches into 1 patch since the first one would
    introduce one error (second patch is the fix), it makes more sense 
    to squash the second into the first one.

 drivers/net/af_xdp/rte_eth_af_xdp.c | 47 +++++++++++++++--------------
 1 file changed, 25 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..f659c0496 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,15 @@ eth_dev_close(struct rte_eth_dev *dev)
 	}
 
 	(void)xsk_umem__delete(internals->umem->umem);
+
+	/*
+	 * MAC is not allocated dynamically, setting it to NULL would prevent
+	 * from releasing it in rte_eth_dev_release_port.
+	 */
+	dev->data->mac_addrs = NULL;
+
+	xdp_umem_destroy(internals->umem);
+
 	remove_xdp_program(internals);
 }
 
@@ -459,19 +481,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 +865,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 +934,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 +946,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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [dpdk-dev] [PATCH v2] net/af_xdp: remove resources when port is closed
  2019-04-30  3:02 ` [dpdk-dev] [PATCH v2] net/af_xdp: remove resources when port is closed Xiaolong Ye
@ 2019-04-30  3:02   ` Xiaolong Ye
  0 siblings, 0 replies; 2+ messages in thread
From: Xiaolong Ye @ 2019-04-30  3:02 UTC (permalink / raw)
  To: dev, Ferruh Yigit, Thomas Monjalon; +Cc: Xiaolong Ye

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.

Also as af_xdp pmd doesn't allocate MAC addresses dynamically, it needs
to be set as NULL, so it won't be released by rte_eth_dev_release_port(),
otherwise, there would be "EAL: Error: Invalid memory" error.

Signed-off-by: Xiaolong Ye <xiaolong.ye@intel.com>
---

V2: merge previous 2 patches into 1 patch since the first one would
    introduce one error (second patch is the fix), it makes more sense 
    to squash the second into the first one.

 drivers/net/af_xdp/rte_eth_af_xdp.c | 47 +++++++++++++++--------------
 1 file changed, 25 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..f659c0496 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,15 @@ eth_dev_close(struct rte_eth_dev *dev)
 	}
 
 	(void)xsk_umem__delete(internals->umem->umem);
+
+	/*
+	 * MAC is not allocated dynamically, setting it to NULL would prevent
+	 * from releasing it in rte_eth_dev_release_port.
+	 */
+	dev->data->mac_addrs = NULL;
+
+	xdp_umem_destroy(internals->umem);
+
 	remove_xdp_program(internals);
 }
 
@@ -459,19 +481,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 +865,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 +934,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 +946,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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-30  3:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <“20190426050912.109813-1-xiaolong.ye@intel.com”>
2019-04-30  3:02 ` [dpdk-dev] [PATCH v2] net/af_xdp: remove resources when port is closed Xiaolong Ye
2019-04-30  3:02   ` Xiaolong Ye

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).