[v3,06/16] net/ice/base: allow init without TC class sched nodes

Message ID 20240812152815.1132697-7-bruce.richardson@intel.com (mailing list archive)
State New
Delegated to: Bruce Richardson
Headers
Series Improve rte_tm support in ICE driver |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Bruce Richardson Aug. 12, 2024, 3:28 p.m. UTC
If DCB support is disabled via DDP image, there will not be any traffic
class (TC) nodes in the scheduler tree immediately above the root level.
To allow the driver to work with this scenario, we allow use of the root
node as a dummy TC0 node in case where there are no TC nodes in the
tree. For use of any other TC other than 0 (used by default in the
driver), existing behaviour of returning NULL pointer is maintained.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 drivers/net/ice/base/ice_sched.c | 6 ++++++
 drivers/net/ice/base/ice_type.h  | 1 +
 2 files changed, 7 insertions(+)
  

Patch

diff --git a/drivers/net/ice/base/ice_sched.c b/drivers/net/ice/base/ice_sched.c
index 373c32a518..f75e5ae599 100644
--- a/drivers/net/ice/base/ice_sched.c
+++ b/drivers/net/ice/base/ice_sched.c
@@ -292,6 +292,10 @@  struct ice_sched_node *ice_sched_get_tc_node(struct ice_port_info *pi, u8 tc)
 
 	if (!pi || !pi->root)
 		return NULL;
+	/* if no TC nodes, use root as TC node 0 */
+	if (pi->has_tc == 0)
+		return tc == 0 ? pi->root : NULL;
+
 	for (i = 0; i < pi->root->num_children; i++)
 		if (pi->root->children[i]->tc_num == tc)
 			return pi->root->children[i];
@@ -1306,6 +1310,8 @@  int ice_sched_init_port(struct ice_port_info *pi)
 			    ICE_AQC_ELEM_TYPE_ENTRY_POINT)
 				hw->sw_entry_point_layer = j;
 
+			if (buf[0].generic[j].data.elem_type == ICE_AQC_ELEM_TYPE_TC)
+				pi->has_tc = 1;
 			status = ice_sched_add_node(pi, j, &buf[i].generic[j], NULL);
 			if (status)
 				goto err_init_port;
diff --git a/drivers/net/ice/base/ice_type.h b/drivers/net/ice/base/ice_type.h
index 598a80155b..a70e4a8afa 100644
--- a/drivers/net/ice/base/ice_type.h
+++ b/drivers/net/ice/base/ice_type.h
@@ -1260,6 +1260,7 @@  struct ice_port_info {
 	struct ice_qos_cfg qos_cfg;
 	u8 is_vf:1;
 	u8 is_custom_tx_enabled:1;
+	u8 has_tc:1;
 };
 
 struct ice_switch_info {