DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mvpp2: remove resources when port is closed
@ 2019-08-05 10:16 lironh
  2019-08-05 17:28 ` Jerin Jacob Kollanukkaran
  0 siblings, 1 reply; 2+ messages in thread
From: lironh @ 2019-08-05 10:16 UTC (permalink / raw)
  To: jerinj; +Cc: dev, lironh

From: Liron Himi <lironh@marvell.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: Liron Himi <lironh@marvell.com>
Reviewed-by: Yuri Chipchev <yuric@marvell.com>
---
 drivers/net/mvpp2/mrvl_ethdev.c | 79 +++++++++++++++--------------------------
 1 file changed, 29 insertions(+), 50 deletions(-)

diff --git a/drivers/net/mvpp2/mrvl_ethdev.c b/drivers/net/mvpp2/mrvl_ethdev.c
index d1d0d41..810a703 100644
--- a/drivers/net/mvpp2/mrvl_ethdev.c
+++ b/drivers/net/mvpp2/mrvl_ethdev.c
@@ -144,6 +144,9 @@ static uint16_t mrvl_tx_pkt_burst(void *txq, struct rte_mbuf **tx_pkts,
 				  uint16_t nb_pkts);
 static uint16_t mrvl_tx_sg_pkt_burst(void *txq,	struct rte_mbuf **tx_pkts,
 				     uint16_t nb_pkts);
+static int rte_pmd_mrvl_remove(struct rte_vdev_device *vdev);
+static void mrvl_deinit_pp2(void);
+static void mrvl_deinit_hifs(void);
 
 
 #define MRVL_XSTATS_TBL_ENTRY(name) { \
@@ -898,6 +901,22 @@ mrvl_dev_close(struct rte_eth_dev *dev)
 		pp2_cls_plcr_deinit(priv->default_policer);
 		priv->default_policer = NULL;
 	}
+
+
+	if (priv->bpool) {
+		pp2_bpool_deinit(priv->bpool);
+		used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit);
+		priv->bpool = NULL;
+	}
+
+	mrvl_dev_num--;
+
+	if (mrvl_dev_num == 0) {
+		MRVL_LOG(INFO, "Perform MUSDK deinit");
+		mrvl_deinit_hifs();
+		mrvl_deinit_pp2();
+		rte_mvep_deinit(MVEP_MOD_T_PP2);
+	}
 }
 
 /**
@@ -2809,6 +2828,9 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
 	mrvl_set_tx_function(eth_dev);
 	eth_dev->dev_ops = &mrvl_ops;
 
+	/* Flag to call rte_eth_dev_release_port() in rte_eth_dev_close(). */
+	eth_dev->data->dev_flags |= RTE_ETH_DEV_CLOSE_REMOVE;
+
 	rte_eth_dev_probing_finish(eth_dev);
 	return 0;
 out_free:
@@ -2818,28 +2840,6 @@ mrvl_eth_dev_create(struct rte_vdev_device *vdev, const char *name)
 }
 
 /**
- * Cleanup previously created device representing Ethernet port.
- *
- * @param name
- *   Pointer to the port name.
- */
-static void
-mrvl_eth_dev_destroy(const char *name)
-{
-	struct rte_eth_dev *eth_dev;
-	struct mrvl_priv *priv;
-
-	eth_dev = rte_eth_dev_allocated(name);
-	if (!eth_dev)
-		return;
-
-	priv = eth_dev->data->dev_private;
-	pp2_bpool_deinit(priv->bpool);
-	used_bpools[priv->pp_id] &= ~(1 << priv->bpool_bit);
-	rte_eth_dev_release_port(eth_dev);
-}
-
-/**
  * Callback used by rte_kvargs_process() during argument parsing.
  *
  * @param key
@@ -2959,20 +2959,15 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
 		ret = mrvl_eth_dev_create(vdev, ifnames.names[i]);
 		if (ret)
 			goto out_cleanup;
+		mrvl_dev_num++;
 	}
-	mrvl_dev_num += ifnum;
 
 	rte_kvargs_free(kvlist);
 
 	return 0;
 out_cleanup:
-	for (; i > 0; i--)
-		mrvl_eth_dev_destroy(ifnames.names[i]);
+	rte_pmd_mrvl_remove(vdev);
 
-	if (mrvl_dev_num == 0) {
-		mrvl_deinit_pp2();
-		rte_mvep_deinit(MVEP_MOD_T_PP2);
-	}
 out_free_kvlist:
 	rte_kvargs_free(kvlist);
 
@@ -2991,28 +2986,12 @@ rte_pmd_mrvl_probe(struct rte_vdev_device *vdev)
 static int
 rte_pmd_mrvl_remove(struct rte_vdev_device *vdev)
 {
-	int i;
-	const char *name;
+	uint16_t port_id;
 
-	name = rte_vdev_device_name(vdev);
-	if (!name)
-		return -EINVAL;
-
-	MRVL_LOG(INFO, "Removing %s", name);
-
-	RTE_ETH_FOREACH_DEV(i) { /* FIXME: removing all devices! */
-		char ifname[RTE_ETH_NAME_MAX_LEN];
-
-		rte_eth_dev_get_name_by_port(i, ifname);
-		mrvl_eth_dev_destroy(ifname);
-		mrvl_dev_num--;
-	}
-
-	if (mrvl_dev_num == 0) {
-		MRVL_LOG(INFO, "Perform MUSDK deinit");
-		mrvl_deinit_hifs();
-		mrvl_deinit_pp2();
-		rte_mvep_deinit(MVEP_MOD_T_PP2);
+	RTE_ETH_FOREACH_DEV(port_id) {
+		if (rte_eth_devices[port_id].device != &vdev->device)
+			continue;
+		rte_eth_dev_close(port_id);
 	}
 
 	return 0;
-- 
2.7.4


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

end of thread, other threads:[~2019-08-05 17:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-05 10:16 [dpdk-dev] [PATCH] net/mvpp2: remove resources when port is closed lironh
2019-08-05 17:28 ` Jerin Jacob Kollanukkaran

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