[6/6] net/ice: support Tx sched commit before device start

Message ID 20240102194232.3614305-7-qi.z.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers
Series net/ice improve qos |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Qi Zhang Jan. 2, 2024, 7:42 p.m. UTC
  Currently Tx hierarchy commit only take effect if device
already be started, as after a dev start / stop cycle, queues
has been removed and added back which cause the Tx scheduler
tree return to original topo.

In this patch, the hierarchy commit function will simply return
if device has not be started yet and all the commit actions will
be deferred to dev_start.

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
 drivers/net/ice/ice_ethdev.c |  9 +++++++++
 drivers/net/ice/ice_ethdev.h |  4 ++++
 drivers/net/ice/ice_tm.c     | 25 ++++++++++++++++++++++---
 3 files changed, 35 insertions(+), 3 deletions(-)
  

Patch

diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c
index 3c3bc49dc2..72e13f95f8 100644
--- a/drivers/net/ice/ice_ethdev.c
+++ b/drivers/net/ice/ice_ethdev.c
@@ -3717,6 +3717,7 @@  ice_dev_start(struct rte_eth_dev *dev)
 	int mask, ret;
 	uint8_t timer = hw->func_caps.ts_func_info.tmr_index_owned;
 	uint32_t pin_idx = ad->devargs.pin_idx;
+	struct rte_tm_error tm_err;
 
 	/* program Tx queues' context in hardware */
 	for (nb_txq = 0; nb_txq < data->nb_tx_queues; nb_txq++) {
@@ -3746,6 +3747,14 @@  ice_dev_start(struct rte_eth_dev *dev)
 		}
 	}
 
+	if (pf->tm_conf.committed) {
+		ret = ice_do_hierarchy_commit(dev, pf->tm_conf.clear_on_fail, &tm_err);
+		if (ret) {
+			PMD_DRV_LOG(ERR, "fail to commit Tx scheduler");
+			goto rx_err;
+		}
+	}
+
 	ice_set_rx_function(dev);
 	ice_set_tx_function(dev);
 
diff --git a/drivers/net/ice/ice_ethdev.h b/drivers/net/ice/ice_ethdev.h
index 3b2db6aaa6..fa4981ed14 100644
--- a/drivers/net/ice/ice_ethdev.h
+++ b/drivers/net/ice/ice_ethdev.h
@@ -504,6 +504,7 @@  struct ice_tm_conf {
 	uint32_t nb_qgroup_node;
 	uint32_t nb_queue_node;
 	bool committed;
+	bool clear_on_fail;
 };
 
 struct ice_pf {
@@ -686,6 +687,9 @@  int ice_rem_rss_cfg_wrap(struct ice_pf *pf, uint16_t vsi_id,
 			 struct ice_rss_hash_cfg *cfg);
 void ice_tm_conf_init(struct rte_eth_dev *dev);
 void ice_tm_conf_uninit(struct rte_eth_dev *dev);
+int ice_do_hierarchy_commit(struct rte_eth_dev *dev,
+			    int clear_on_fail,
+			    struct rte_tm_error *error);
 extern const struct rte_tm_ops ice_tm_ops;
 
 static inline int
diff --git a/drivers/net/ice/ice_tm.c b/drivers/net/ice/ice_tm.c
index 4d8dbff2dc..aa012897ed 100644
--- a/drivers/net/ice/ice_tm.c
+++ b/drivers/net/ice/ice_tm.c
@@ -52,6 +52,7 @@  ice_tm_conf_init(struct rte_eth_dev *dev)
 	pf->tm_conf.nb_qgroup_node = 0;
 	pf->tm_conf.nb_queue_node = 0;
 	pf->tm_conf.committed = false;
+	pf->tm_conf.clear_on_fail = false;
 }
 
 void
@@ -832,9 +833,9 @@  static int ice_add_leaf_nodes(struct rte_eth_dev *dev)
 	return ret;
 }
 
-static int ice_hierarchy_commit(struct rte_eth_dev *dev,
-				 int clear_on_fail,
-				 struct rte_tm_error *error)
+int ice_do_hierarchy_commit(struct rte_eth_dev *dev,
+			    int clear_on_fail,
+			    struct rte_tm_error *error)
 {
 	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
 	struct ice_hw *hw = ICE_DEV_PRIVATE_TO_HW(dev->data->dev_private);
@@ -959,6 +960,8 @@  static int ice_hierarchy_commit(struct rte_eth_dev *dev,
 		}
 	}
 
+	pf->tm_conf.committed = true;
+
 	return ret_val;
 
 reset_leaf:
@@ -974,3 +977,19 @@  static int ice_hierarchy_commit(struct rte_eth_dev *dev,
 	}
 	return ret_val;
 }
+
+static int ice_hierarchy_commit(struct rte_eth_dev *dev,
+				 int clear_on_fail,
+				 struct rte_tm_error *error)
+{
+	struct ice_pf *pf = ICE_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+
+	/* if device not started, simply set committed flag and return. */
+	if (!dev->data->dev_started) {
+		pf->tm_conf.committed = true;
+		pf->tm_conf.clear_on_fail = clear_on_fail;
+		return 0;
+	}
+
+	return ice_do_hierarchy_commit(dev, clear_on_fail, error);
+}