[PATCH v6 4/5] net/ice: allowing stopping port to apply TM topology

Bruce Richardson bruce.richardson at intel.com
Tue Oct 29 18:01:56 CET 2024


The rte_tm topology commit requires the port to be stopped on apply.
Rather than just returning an error when the port is already started, we
can stop the port, apply the topology to it and then restart it.

Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
Acked-by: Vladimir Medvedkin <vladimir.medvedkin at intel.com>
---
 drivers/net/ice/ice_tm.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c
index a135e9db30..235eda24e5 100644
--- a/drivers/net/ice/ice_tm.c
+++ b/drivers/net/ice/ice_tm.c
@@ -836,15 +836,30 @@ ice_hierarchy_commit(struct rte_eth_dev *dev,
 				 int clear_on_fail,
 				 struct rte_tm_error *error)
 {
-	RTE_SET_USED(error);
-	/* commit should only be done to topology before start! */
-	if (dev->data->dev_started)
-		return -1;
+	bool restart = false;
+
+	/* commit should only be done to topology before start
+	 * If port is already started, stop it and then restart when done.
+	 */
+	if (dev->data->dev_started) {
+		if (rte_eth_dev_stop(dev->data->port_id) != 0) {
+			error->message = "Device failed to Stop";
+			return -1;
+		}
+		restart = true;
+	}
 
 	int ret = commit_new_hierarchy(dev);
 	if (ret < 0 && clear_on_fail) {
 		ice_tm_conf_uninit(dev);
 		ice_tm_conf_init(dev);
 	}
+
+	if (restart) {
+		if (rte_eth_dev_start(dev->data->port_id) != 0) {
+			error->message = "Device failed to Start";
+			return -1;
+		}
+	}
 	return ret;
 }
-- 
2.43.0



More information about the dev mailing list