[v3,16/16] net/ice: do early check on node level when adding
Checks
Commit Message
When adding a new scheduler node, the parameters for leaf nodes and
non-leaf nodes are different, and which parameter checks are done is
determined by checking the node level i.e. if it's the lowest (leaf)
node level or not. However, if the node level itself is incorrectly
specified, the error messages got can be confusing since the user may
add a leaf node using e.g. the testpmd command to explicitly add a leaf
node, yet get error messages only relevant to non-leaf nodes due to an
incorrect level parameter.
We can avoid these confusing errors by doing a check that the level
matches "parent->level + 1" before doing a more detailed parameter
check.
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
drivers/net/ice/ice_tm.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
@@ -426,6 +426,13 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
if (level_id == RTE_TM_NODE_LEVEL_ID_ANY && parent_node != NULL)
level_id = parent_node->level + 1;
+ /* check level */
+ if (parent_node != NULL && level_id != parent_node->level + 1) {
+ error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
+ error->message = "Wrong level";
+ return -EINVAL;
+ }
+
ret = ice_node_param_check(node_id, priority, weight,
params, level_id == ice_get_leaf_level(hw), error);
if (ret)
@@ -493,12 +500,6 @@ ice_tm_node_add(struct rte_eth_dev *dev, uint32_t node_id,
error->message = "parent is not valid";
return -EINVAL;
}
- /* check level */
- if (level_id != parent_node->level + 1) {
- error->type = RTE_TM_ERROR_TYPE_NODE_PARAMS;
- error->message = "Wrong level";
- return -EINVAL;
- }
/* check the max children allowed at this level */
if (parent_node->reference_count >= hw->max_children[parent_node->level]) {